diff options
Diffstat (limited to 'src/lib/delivery')
| -rw-r--r-- | src/lib/delivery/delivery.c | 19 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_artifactory.c | 3 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_init.c | 14 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_install.c | 36 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_test.c | 4 | ||||
| -rw-r--r-- | src/lib/delivery/include/delivery.h | 2 |
6 files changed, 65 insertions, 13 deletions
diff --git a/src/lib/delivery/delivery.c b/src/lib/delivery/delivery.c index 89074c8..dc9e2ce 100644 --- a/src/lib/delivery/delivery.c +++ b/src/lib/delivery/delivery.c @@ -1,7 +1,7 @@ #include "delivery.h" #include "conda.h" -struct Delivery *delivery_duplicate(const struct Delivery *ctx) { +struct Delivery *delivery_duplicate(struct Delivery *ctx) { struct Delivery *result = calloc(1, sizeof(*result)); if (!result) { return NULL; @@ -56,12 +56,16 @@ struct Delivery *delivery_duplicate(const struct Delivery *ctx) { result->rules._handle = malloc(sizeof(*result->rules._handle)); if (!result->rules._handle) { SYSERROR("unable to allocate space for INIFILE handle"); + SYSERROR("%s", "unable to allocate space for INIFILE handle"); + delivery_free(ctx); return NULL; } result->rules._handle->section = malloc(ctx->rules._handle->section_count * sizeof(**ctx->rules._handle->section)); if (!result->rules._handle->section) { guard_free(result->rules._handle); SYSERROR("unable to allocate space for INIFILE section"); + SYSERROR("%s", "unable to allocate space for INIFILE section"); + delivery_free(ctx); return NULL; } memcpy(result->rules._handle, &ctx->rules._handle, sizeof(*ctx->rules._handle)); @@ -102,10 +106,18 @@ struct Delivery *delivery_duplicate(const struct Delivery *ctx) { result->system.platform = malloc(DELIVERY_PLATFORM_MAX * sizeof(*result->system.platform)); if (!result->system.platform) { SYSERROR("unable to allocate space for system platform array"); + SYSERROR("%s", "unable to allocate space for system platform array"); + delivery_free(ctx); return NULL; } for (size_t i = 0; i < DELIVERY_PLATFORM_MAX; i++) { result->system.platform[i] = strdup_maybe(ctx->system.platform[i]); + if (!result->system.platform[i]) { + SYSERROR("%s", "unable to allocate record in system platform array"); + guard_array_n_free(result->system.platform, DELIVERY_PLATFORM_MAX); + delivery_free(ctx); + return NULL; + } } } @@ -245,6 +257,9 @@ void delivery_free(struct Delivery *ctx) { guard_free(ctx->rules.release_fmt); guard_free(ctx->rules.build_name_fmt); guard_free(ctx->rules.build_number_fmt); + if (ctx->rules._handle) { + ini_free(&ctx->rules._handle); + } guard_free(ctx->deploy.docker.test_script); guard_free(ctx->deploy.docker.registry); @@ -474,7 +489,7 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { } if (!strlist_count(deferred)) { - SYSWARN("No %s packages were filtered by test definitions\n", mode); + SYSWARN("No %s packages were filtered by test definitions", mode); } else { if (DEFER_CONDA == type) { guard_strlist_free(&ctx->conda.conda_packages); diff --git a/src/lib/delivery/delivery_artifactory.c b/src/lib/delivery/delivery_artifactory.c index 3c1cff3..d7a5457 100644 --- a/src/lib/delivery/delivery_artifactory.c +++ b/src/lib/delivery/delivery_artifactory.c @@ -61,7 +61,8 @@ int delivery_artifact_upload(struct Delivery *ctx) { if (!globals.jfrog.repo) { SYSWARN("Artifactory repository path is not configured!"); - SYSWARN("set STASIS_JF_REPO environment variable...\nOr append to configuration file:\n"); + SYSWARN("set STASIS_JF_REPO environment variable...\nOr append to configuration file:"); + SYSWARN(""); SYSWARN("[deploy:artifactory]\nrepo = example/generic/repo/path\n"); status++; break; diff --git a/src/lib/delivery/delivery_init.c b/src/lib/delivery/delivery_init.c index c73e7f0..5bc326d 100644 --- a/src/lib/delivery/delivery_init.c +++ b/src/lib/delivery/delivery_init.c @@ -201,11 +201,18 @@ int delivery_init_platform(struct Delivery *ctx) { } for (size_t i = 0; i < DELIVERY_PLATFORM_MAX; i++) { ctx->system.platform[i] = calloc(DELIVERY_PLATFORM_MAXLEN, sizeof(*ctx->system.platform[0])); + if (!ctx->system.platform[i]) { + SYSERROR("Unable to allocate record %zu in platform array", i); + guard_array_n_free(ctx->system.platform, i); + return -1; + } } ctx->system.arch = strdup(uts.machine); if (!ctx->system.arch) { // memory error + guard_array_n_free(ctx->system.platform, DELIVERY_PLATFORM_MAX); + ctx->system.platform = NULL; return -1; } @@ -218,6 +225,8 @@ int delivery_init_platform(struct Delivery *ctx) { SYSDEBUG("Setting platform"); strncpy(ctx->system.platform[DELIVERY_PLATFORM], uts.sysname, DELIVERY_PLATFORM_MAXLEN - 1); + ctx->system.platform[DELIVERY_PLATFORM][DELIVERY_PLATFORM_MAXLEN - 1] = '\0'; + if (!strcmp(ctx->system.platform[DELIVERY_PLATFORM], "Darwin")) { snprintf(ctx->system.platform[DELIVERY_PLATFORM_CONDA_SUBDIR], DELIVERY_PLATFORM_MAXLEN, "osx-%s", archsuffix); strncpy(ctx->system.platform[DELIVERY_PLATFORM_CONDA_INSTALLER], "MacOSX", DELIVERY_PLATFORM_MAXLEN - 1); @@ -290,7 +299,10 @@ int delivery_init(struct Delivery *ctx, int render_mode) { } // Configure architecture and platform information - delivery_init_platform(ctx); + if (delivery_init_platform(ctx)) { + // memory error + return -1; + } // Create STASIS directory structure delivery_init_dirs_stage1(ctx); diff --git a/src/lib/delivery/delivery_install.c b/src/lib/delivery/delivery_install.c index 4d52b82..efdb819 100644 --- a/src/lib/delivery/delivery_install.c +++ b/src/lib/delivery/delivery_install.c @@ -235,12 +235,16 @@ int delivery_conda_enforce_package_version(struct Delivery *ctx, const char *env goto cleanup; } if (strstr(item, name)) { - char *spec_tmp = find_version_spec((char *) item); - while (!isalnum(*spec_tmp)) { - spec_tmp++; + const char *spec_tmp = find_version_spec((char *) item); + if (spec_tmp) { + while (!isalnum(*spec_tmp)) { + spec_tmp++; + } + spec_request = strdup(spec_tmp); + } else { + spec_request = strdup(item); } - spec_request = strdup(spec_tmp); if (!spec_request) { SYSERROR("unable to allocate memory for conda package spec request"); status = -1; @@ -261,9 +265,17 @@ int delivery_conda_enforce_package_version(struct Delivery *ctx, const char *env } snprintf(cmd, PATH_MAX, "remove --name %s %s", env_name, name); - conda_exec(cmd); + if (conda_exec(cmd)) { + SYSERROR("unable to remove package %s from %s", name, env_name); + status = -1; + goto cleanup; + } snprintf(cmd, PATH_MAX, "install --name %s %s=%s", env_name, name, spec_request); - conda_exec(cmd); + if (conda_exec(cmd)) { + SYSERROR("unable to install package %s into %s", name, env_name); + status = -1; + goto cleanup; + } cleanup: guard_free(spec_request); @@ -376,14 +388,16 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha if (INSTALL_PKG_CONDA_DEFERRED & type) { strncat(command_base, " --use-local", sizeof(command_base) - strlen(command_base) - 1); + command_base[sizeof(command_base) - 1] = '\0'; } else if (INSTALL_PKG_PIP_DEFERRED & type) { // Don't change the baseline package set unless we're working with a // new build. Release candidates will need to keep packages as stable // as possible between releases. if (!ctx->meta.based_on) { strncat(command_base, " --upgrade", sizeof(command_base) - strlen(command_base) - 1); + command_base[sizeof(command_base) - 1] = '\0'; } - snprintf(command_base + strlen(command_base), sizeof(command_base), " --extra-index-url 'file://%s'", ctx->storage.wheel_artifact_dir); + snprintf(command_base + strlen(command_base), sizeof(command_base) - strlen(command_base), " --extra-index-url 'file://%s'", ctx->storage.wheel_artifact_dir); } size_t args_alloc_len = STASIS_BUFSIZ; @@ -402,15 +416,18 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha continue; } if (INSTALL_PKG_PIP_DEFERRED & type) { + SYSDEBUG("Getting requirements for test: %s", name); struct Test *info = requirement_from_test(ctx, name); if (info) { if (!strcmp(info->version, "HEAD") || is_git_sha(info->version)) { + SYSDEBUG("Using version: %s", info->version); struct StrList *tag_data = strlist_init(); if (!tag_data) { SYSERROR("Unable to allocate memory for tag data"); guard_free(args); return -1; } + SYSDEBUG("Tokenizing repository info tag: %s", info->repository_info_tag); strlist_append_tokenize(tag_data, info->repository_info_tag, "-"); struct WheelInfo *whl = NULL; @@ -418,13 +435,16 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha char *hash = NULL; if (strlist_count(tag_data) > 1) { post_commit = strlist_item(tag_data, 1); + SYSDEBUG("post_commit: %s", post_commit); hash = strlist_item(tag_data, 2); + SYSDEBUG("hash: %s", hash); } // We can't match on version here (index 0). The wheel's version is not guaranteed to be // equal to the tag; setuptools_scm auto-increments the value, the user can change it manually, // etc. errno = 0; + SYSDEBUG("%s", "Getting wheel information"); whl = wheelinfo_get(ctx->storage.wheel_artifact_dir, info->name, (char *[]) {ctx->meta.python_compact, ctx->system.arch, "none", "any", @@ -439,8 +459,10 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha SYSERROR("No wheel packages found that match the description of '%s'", info->name); } else { // found, replace the original version with newly detected version + SYSDEBUG("Replacing version: %s", whl->version); guard_free(info->version); info->version = strdup(whl->version); + SYSDEBUG("Version replaced with: %s", whl->version); } guard_strlist_free(&tag_data); wheelinfo_free(&whl); diff --git a/src/lib/delivery/delivery_test.c b/src/lib/delivery/delivery_test.c index 65d0451..f59a62e 100644 --- a/src/lib/delivery/delivery_test.c +++ b/src/lib/delivery/delivery_test.c @@ -8,6 +8,7 @@ struct Tests *tests_init(const size_t num_tests) { tests->test = calloc(num_tests, sizeof(*tests->test)); if (!tests->test) { + guard_free(tests); return NULL; } tests->num_used = 0; @@ -41,6 +42,7 @@ struct Test *test_init() { result->runtime = calloc(1, sizeof(*result->runtime)); if (!result->runtime) { + guard_free(result); return NULL; } @@ -176,7 +178,7 @@ void delivery_tests_run(struct Delivery *ctx) { if (pushd(destdir)) { COE_CHECK_ABORT(1, "Unable to enter repository directory\n"); } else { - int dep_status = check_python_package_dependencies("."); + const int dep_status = check_python_package_dependencies("."); if (dep_status) { SYSERROR("Please replace all occurrences above with standard package specs:\n" "\n" diff --git a/src/lib/delivery/include/delivery.h b/src/lib/delivery/include/delivery.h index f234750..3103a86 100644 --- a/src/lib/delivery/include/delivery.h +++ b/src/lib/delivery/include/delivery.h @@ -499,7 +499,7 @@ void delivery_rewrite_stage2(struct Delivery *ctx, char *specfile); * @param ctx Delivery context * @return a copy */ -struct Delivery *delivery_duplicate(const struct Delivery *ctx); +struct Delivery *delivery_duplicate(struct Delivery *ctx); /** * Initialize a `Tests` structure |
