From 4307e297cb567d70a0369e66af2c0d7f42725574 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 20 Mar 2025 09:35:13 -0400 Subject: Remove extras from spec in overlay generator --- src/lib/delivery/delivery_install.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/lib/delivery/delivery_install.c') diff --git a/src/lib/delivery/delivery_install.c b/src/lib/delivery/delivery_install.c index bb9bb48..fec30ac 100644 --- a/src/lib/delivery/delivery_install.c +++ b/src/lib/delivery/delivery_install.c @@ -41,6 +41,25 @@ static char *have_spec_in_config(const struct Delivery *ctx, const char *name) { return NULL; } +static char *remove_extras(char *s) { + char *extra_stop = NULL; + char *extra_start = strchr(s, '['); + size_t len = strlen(s); + if (extra_start) { + extra_stop = strchr(extra_start, ']'); + if (extra_stop) { + size_t last = strlen(s); + if (last) { + extra_stop++; + last = strlen(extra_stop); + } + memmove(extra_start, extra_stop, last); + s[len - (extra_stop - extra_start)] = 0; + } + } + return s; +} + int delivery_overlay_packages_from_env(struct Delivery *ctx, const char *env_name) { char *current_env = conda_get_active_environment(); int need_restore = current_env && strcmp(env_name, current_env) != 0; @@ -80,6 +99,8 @@ int delivery_overlay_packages_from_env(struct Delivery *ctx, const char *env_nam } else { strncpy(spec_name, spec, sizeof(spec_name) - 1); } + remove_extras(spec_name); + struct Test *test_block = requirement_from_test(ctx, spec_name); if (!test_block) { msg(STASIS_MSG_L2 | STASIS_MSG_WARN, "from config without test: %s\n", spec); -- cgit From 5126b191b6d1a53d3a402478472fd1d357ace293 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 20 Mar 2025 11:52:22 -0400 Subject: Remove extras usage where applicable --- src/lib/delivery/delivery_install.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'src/lib/delivery/delivery_install.c') diff --git a/src/lib/delivery/delivery_install.c b/src/lib/delivery/delivery_install.c index fec30ac..cf6ccaa 100644 --- a/src/lib/delivery/delivery_install.c +++ b/src/lib/delivery/delivery_install.c @@ -9,6 +9,7 @@ static struct Test *requirement_from_test(struct Delivery *ctx, const char *name if (spec) { *spec = '\0'; } + remove_extras(package_name); if (ctx->tests[i].name && !strcmp(package_name, ctx->tests[i].name)) { result = &ctx->tests[i]; @@ -41,25 +42,6 @@ static char *have_spec_in_config(const struct Delivery *ctx, const char *name) { return NULL; } -static char *remove_extras(char *s) { - char *extra_stop = NULL; - char *extra_start = strchr(s, '['); - size_t len = strlen(s); - if (extra_start) { - extra_stop = strchr(extra_start, ']'); - if (extra_stop) { - size_t last = strlen(s); - if (last) { - extra_stop++; - last = strlen(extra_stop); - } - memmove(extra_start, extra_stop, last); - s[len - (extra_stop - extra_start)] = 0; - } - } - return s; -} - int delivery_overlay_packages_from_env(struct Delivery *ctx, const char *env_name) { char *current_env = conda_get_active_environment(); int need_restore = current_env && strcmp(env_name, current_env) != 0; @@ -99,7 +81,6 @@ int delivery_overlay_packages_from_env(struct Delivery *ctx, const char *env_nam } else { strncpy(spec_name, spec, sizeof(spec_name) - 1); } - remove_extras(spec_name); struct Test *test_block = requirement_from_test(ctx, spec_name); if (!test_block) { @@ -293,9 +274,21 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha } wheel_free(&whl); } + + char req[255] = {0}; + if (!strcmp(name, info->name)) { + strcpy(req, info->name); + } else { + strcpy(req, name); + char *spec = find_version_spec(req); + if (spec) { + *spec = 0; + } + } + snprintf(cmd + strlen(cmd), sizeof(cmd) - strlen(cmd) - strlen(info->name) - strlen(info->version) + 5, - " '%s==%s'", info->name, info->version); + " '%s==%s'", req, info->version); } else { fprintf(stderr, "Deferred package '%s' is not present in the tested package list!\n", name); return -1; -- cgit