diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-05-05 13:45:58 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-05-05 13:46:10 -0400 |
| commit | 17bd286713df8f76f7b5f3878e501a81fa4c04ee (patch) | |
| tree | 4b722c242e454332d3eef596b68f2fad9d935fe1 | |
| parent | 4b802dff0a4769e72b69a3e6f8cc6cc37b14fc31 (diff) | |
| download | stasis-17bd286713df8f76f7b5f3878e501a81fa4c04ee.tar.gz | |
Integrate into main and lib/deliveryversion-compare
| -rw-r--r-- | src/cli/stasis/stasis_main.c | 32 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_install.c | 4 | ||||
| -rw-r--r-- | src/lib/delivery/include/delivery.h | 10 |
3 files changed, 43 insertions, 3 deletions
diff --git a/src/cli/stasis/stasis_main.c b/src/cli/stasis/stasis_main.c index 78aae0c..95cb7c5 100644 --- a/src/cli/stasis/stasis_main.c +++ b/src/cli/stasis/stasis_main.c @@ -323,6 +323,37 @@ static void install_packaging_tools() { } } +static void force_conda_package_reinstallation_on_mismatch(struct Delivery *ctx, const char *env_name) { + const size_t conda_package_count = strlist_count(ctx->conda.conda_packages); + if (conda_package_count) { + msg(STASIS_MSG_L1, "Enforcing Conda package versions: %s\n", env_name); + for (size_t i = 0; i < conda_package_count; i++) { + const char *item = strlist_item(ctx->conda.conda_packages, i); + if (!item) { + msg(STASIS_MSG_L2 | STASIS_MSG_ERROR, "NULL record in conda package list\n"); + exit(1); + } + char *pkg_name = strdup(item); + if (!pkg_name) { + msg(STASIS_MSG_L2 | STASIS_MSG_ERROR, "unable to allocate memory for package name\n"); + exit(1); + } + const char *spec = find_version_spec(pkg_name); + if (spec) { + pkg_name[spec - pkg_name] = '\0'; + } + + msg(STASIS_MSG_L2, "%s\n", pkg_name); + if (delivery_conda_enforce_package_version(ctx, env_name, pkg_name)) { + msg(STASIS_MSG_L3 | STASIS_MSG_ERROR, "Failed to determine conda package version: %s\n", pkg_name); + guard_free(pkg_name); + exit(1); + } + guard_free(pkg_name); + } + } +} + static void configure_package_overlay(struct Delivery *ctx, const char *env_name) { if (!isempty(ctx->meta.based_on)) { msg(STASIS_MSG_L1, "Generating package overlay from environment: %s\n", env_name); @@ -398,6 +429,7 @@ static void release_install_conda_packages(struct Delivery *ctx, char *env_name) if (delivery_install_packages(ctx, ctx->storage.conda_install_prefix, env_name, INSTALL_PKG_CONDA, (struct StrList *[]) {ctx->conda.conda_packages, NULL})) { exit(1); } + force_conda_package_reinstallation_on_mismatch(ctx, env_name); } if (strlist_count(ctx->conda.conda_packages_defer)) { msg(STASIS_MSG_L3, "Installing deferred conda packages\n"); diff --git a/src/lib/delivery/delivery_install.c b/src/lib/delivery/delivery_install.c index d2e6a07..6ad9407 100644 --- a/src/lib/delivery/delivery_install.c +++ b/src/lib/delivery/delivery_install.c @@ -134,7 +134,7 @@ int delivery_overlay_packages_from_env(struct Delivery *ctx, const char *env_nam return 0; } -int delivery_conda_force_package_version(struct Delivery *ctx, const char *env_name, const char *name) { +int delivery_conda_enforce_package_version(struct Delivery *ctx, const char *env_name, const char *name) { char *spec_installed = NULL; char *spec_request = NULL; int status = 0; @@ -247,7 +247,7 @@ int delivery_conda_force_package_version(struct Delivery *ctx, const char *env_n } } - int stop = version_compare(NOT | EQ, spec_request, spec_installed); + const int stop = version_compare(NOT | EQ, spec_request, spec_installed); if (stop < 0) { SYSERROR("version comparison failed (spec_request: %s, spec_installed: %s)", spec_request, spec_installed); status = -1; diff --git a/src/lib/delivery/include/delivery.h b/src/lib/delivery/include/delivery.h index cff60a9..c091182 100644 --- a/src/lib/delivery/include/delivery.h +++ b/src/lib/delivery/include/delivery.h @@ -451,7 +451,15 @@ int delivery_exists(struct Delivery *ctx); int delivery_overlay_packages_from_env(struct Delivery *ctx, const char *env_name); -int delivery_conda_force_package_version(struct Delivery *ctx, const char *env_name, const char *name); +/** + * Conda does not handle version suffixes well, if at all. For example, if pkg-1.2.3rc1 is installed Conda will + * silently ignore a request to install pkg-1.2.3. This function serves as a workaround by comparing the version + * on-disk, and the requested version from the package list, and if the versions are not equal the on-disk package + * is replaced by the one in the package list. + * + * When a package is present in the list without a pinned version it will be reinstalled with whatever is available + */ +int delivery_conda_enforce_package_version(struct Delivery *ctx, const char *env_name, const char *name); /** * Retrieve remote deliveries associated with the current version series |
