diff options
| author | dacctal <donotcontactmevia@email.invalid> | 2026-08-25 13:46:17 +0000 |
|---|---|---|
| committer | dacctal <donotcontactmevia@email.invalid> | 2026-08-25 13:46:17 +0000 |
| commit | fa9e048dc65f246c165d820b983baf62d201c264 (patch) | |
| tree | add08cbef5180ea83dba0d646e576fa2b68a3791 /src/pkg.c | |
| parent | d62326ee93521de490e5bc8d37bf234111187e20 (diff) | |
[checkpoint] small changes that i'm pretty sure break reinstalls
Diffstat (limited to 'src/pkg.c')
| -rw-r--r-- | src/pkg.c | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -23,6 +23,7 @@ #include <unistd.h> #include "common.h" +#include "files.h" #include "log.h" #include "pkg.h" #include "state.h" @@ -30,7 +31,9 @@ static str get_destdir(str *cwd, str *arg) { str result = {0}; - if (str_first(arg) == '.' && arg->len == 1) { + if (is_directory(arg->data)) { + result = str_format("%.*s", str_fmt(arg)); + } else if (str_first(arg) == '.' && arg->len == 1) { result = str_format("%.*s/%.*s", str_fmt(&config.inst_dirs.src), str_fmt(cwd)); } else { str name = {0}; @@ -44,10 +47,11 @@ static str get_destdir(str *cwd, str *arg) { return result; } -static void set_pkgsrc(package_t *pkg) { +static void set_pkgsrc(package_t *pkg, str *cwd, bool is_installed_locally) { pkg->root = str_format("%.*s/%.*s", str_fmt(&config.inst_dirs.src), str_fmt(&pkg->name)); - if (pkg->is_local) pkg->src = pkg->root; + if (is_installed_locally) str_copy_into(&pkg->src, cwd); + else if (pkg->is_local) pkg->src = pkg->root; else pkg->src = str_format("%.*s/%.*s/%.*s", str_fmt(&config.inst_dirs.src), str_fmt(&pkg->name), str_fmt(&pkg->version)); @@ -69,6 +73,7 @@ package_t pkg_create(str *arg) { getcwd(cwd_cstr, MAX_PATH_LEN); str cwd = mstr(cwd_cstr); str destdir = get_destdir(&cwd, arg); + bool is_installed_locally = is_directory(destdir.data); if (strncmp(arg->data, "http", 4) == 0 || strncmp(arg->data, "ssh", 3) == 0) { @@ -81,19 +86,19 @@ package_t pkg_create(str *arg) { } else if (pkg_exists(arg)) { str_copy_into(&pkg.name, arg); pkg.url = pkg_get_url(&pkg); -// } else if (is_installed_locally) { -// str_copy_cstr_into(&pkg.url, ""); -// pkg.name = str_from_after_delim(&destdir, '/'); -// pkg.is_local = true; + } else if (is_installed_locally) { + str_copy_cstr_into(&pkg.url, ""); + pkg.name = str_from_after_delim(&destdir, '/'); + pkg.is_local = true; } else { log_error("'%.*s' is not a valid package", str_fmt(arg)); str_free(&cwd); str_free(&destdir); str_free(arg); - abort(); + exit(1); } - set_pkgsrc(&pkg); + set_pkgsrc(&pkg, &cwd, is_installed_locally); str_free(&cwd); str_free(&destdir); |
