diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-05-11 15:24:53 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-05-11 15:34:45 -0400 |
| commit | b7a60c5bed989a52a53b8b697203f55367f55a89 (patch) | |
| tree | 993173328bdf96eb469c2412241f202cdbc5cf53 /src/lib/delivery | |
| parent | 58d3ca17dcd3f8b3aeb50b8e4f24afc76d33ff26 (diff) | |
| download | stasis-b7a60c5bed989a52a53b8b697203f55367f55a89.tar.gz | |
Replace msg, perror, and fprintf with SYS message macrosuse-sys-macros
Diffstat (limited to 'src/lib/delivery')
| -rw-r--r-- | src/lib/delivery/delivery.c | 4 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_artifactory.c | 24 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_build.c | 26 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_conda.c | 10 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_docker.c | 18 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_export.c | 6 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_init.c | 21 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_install.c | 4 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_populate.c | 12 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_postprocess.c | 15 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_show.c | 2 | ||||
| -rw-r--r-- | src/lib/delivery/delivery_test.c | 17 |
12 files changed, 79 insertions, 80 deletions
diff --git a/src/lib/delivery/delivery.c b/src/lib/delivery/delivery.c index a150169..89074c8 100644 --- a/src/lib/delivery/delivery.c +++ b/src/lib/delivery/delivery.c @@ -449,7 +449,7 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { } if (PKG_INDEX_PROVIDES_FAILED(upstream_exists)) { - fprintf(stderr, "%s's existence command failed for '%s': %s\n", + SYSERROR("%s's existence command failed for '%s': %s", mode, name, pkg_index_provides_strerror(upstream_exists)); exit(1); } @@ -474,7 +474,7 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { } if (!strlist_count(deferred)) { - msg(STASIS_MSG_WARN | STASIS_MSG_L2, "No %s packages were filtered by test definitions\n", mode); + SYSWARN("No %s packages were filtered by test definitions\n", 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 0926d9c..3c1cff3 100644 --- a/src/lib/delivery/delivery_artifactory.c +++ b/src/lib/delivery/delivery_artifactory.c @@ -49,7 +49,7 @@ int delivery_artifact_upload(struct Delivery *ctx) { int status = 0; if (jfrt_auth_init(&ctx->deploy.jfrog_auth)) { - fprintf(stderr, "Failed to initialize Artifactory authentication context\n"); + SYSERROR("Failed to initialize Artifactory authentication context"); return -1; } @@ -60,9 +60,9 @@ int delivery_artifact_upload(struct Delivery *ctx) { jfrt_upload_init(&ctx->deploy.jfrog[i].upload_ctx); if (!globals.jfrog.repo) { - msg(STASIS_MSG_WARN, "Artifactory repository path is not configured!\n"); - fprintf(stderr, "set STASIS_JF_REPO environment variable...\nOr append to configuration file:\n\n"); - fprintf(stderr, "[deploy:artifactory]\nrepo = example/generic/repo/path\n\n"); + SYSWARN("Artifactory repository path is not configured!"); + SYSWARN("set STASIS_JF_REPO environment variable...\nOr append to configuration file:\n"); + SYSWARN("[deploy:artifactory]\nrepo = example/generic/repo/path\n"); status++; break; } else if (!ctx->deploy.jfrog[i].repo) { @@ -71,7 +71,7 @@ int delivery_artifact_upload(struct Delivery *ctx) { if (!ctx->deploy.jfrog[i].repo || isempty(ctx->deploy.jfrog[i].repo) || !strlen(ctx->deploy.jfrog[i].repo)) { // Unlikely to trigger if the config parser is working correctly - msg(STASIS_MSG_ERROR, "Artifactory repository path is empty. Cannot continue.\n"); + SYSERROR("Artifactory repository path is empty. Cannot continue."); status++; break; } @@ -81,7 +81,7 @@ int delivery_artifact_upload(struct Delivery *ctx) { ctx->deploy.jfrog[i].upload_ctx.build_number = ctx->info.build_number; if (jfrog_cli_rt_ping(&ctx->deploy.jfrog_auth)) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Unable to contact artifactory server: %s\n", ctx->deploy.jfrog_auth.url); + SYSERROR("Unable to contact artifactory server: %s", ctx->deploy.jfrog_auth.url); return -1; } @@ -104,7 +104,7 @@ int delivery_artifact_upload(struct Delivery *ctx) { ctx->deploy.jfrog[0].upload_ctx.build_number); } } else { - msg(STASIS_MSG_WARN | STASIS_MSG_L2, "Artifactory build info upload is disabled by CLI argument\n"); + SYSWARN("Artifactory build info upload is disabled by CLI argument"); } return status; @@ -112,7 +112,7 @@ int delivery_artifact_upload(struct Delivery *ctx) { int delivery_mission_render_files(struct Delivery *ctx) { if (!ctx->storage.mission_dir) { - fprintf(stderr, "Mission directory is not configured. Context not initialized?\n"); + SYSERROR("Mission directory is not configured. Context not initialized?"); return -1; } struct Data { @@ -124,7 +124,7 @@ int delivery_mission_render_files(struct Delivery *ctx) { memset(&data, 0, sizeof(data)); data.src = calloc(PATH_MAX, sizeof(*data.src)); if (!data.src) { - perror("data.src"); + SYSERROR("unable to allocate memory for data.src: %s", strerror(errno)); return -1; } @@ -154,14 +154,14 @@ int delivery_mission_render_files(struct Delivery *ctx) { char *contents = calloc(st.st_size + 1, sizeof(*contents)); if (!contents) { - perror("template file contents"); + SYSERROR("unable to allocate memory for template file contents: %s", strerror(errno)); guard_free(data.dest); continue; } FILE *fp = fopen(data.src, "rb"); if (!fp) { - perror(data.src); + SYSERROR("unable to open source template file: %s", strerror(errno)); guard_free(contents); guard_free(data.dest); continue; @@ -194,7 +194,7 @@ int delivery_series_sync(struct Delivery *ctx) { struct JFRT_Download dl = {0}; if (jfrt_auth_init(&ctx->deploy.jfrog_auth)) { - fprintf(stderr, "Failed to initialize Artifactory authentication context\n"); + SYSERROR("Failed to initialize Artifactory authentication context"); return -1; // error } diff --git a/src/lib/delivery/delivery_build.c b/src/lib/delivery/delivery_build.c index 3eb2714..66f9126 100644 --- a/src/lib/delivery/delivery_build.c +++ b/src/lib/delivery/delivery_build.c @@ -9,11 +9,11 @@ int delivery_build_recipes(struct Delivery *ctx) { char *recipe_dir = NULL; if (ctx->tests->test[i]->build_recipe) { // build a conda recipe if (recipe_clone(ctx->storage.build_recipes_dir, ctx->tests->test[i]->build_recipe, NULL, &recipe_dir)) { - fprintf(stderr, "Encountered an issue while cloning recipe for: %s\n", ctx->tests->test[i]->name); + SYSERROR("Encountered an issue while cloning recipe for: %s", ctx->tests->test[i]->name); return -1; } if (!recipe_dir) { - fprintf(stderr, "BUG: recipe_clone() succeeded but recipe_dir is NULL: %s\n", strerror(errno)); + SYSERROR("BUG: recipe_clone() succeeded but recipe_dir is NULL: %s", strerror(errno)); return -1; } int recipe_type = recipe_get_type(recipe_dir); @@ -114,7 +114,7 @@ int delivery_build_recipes(struct Delivery *ctx) { } popd(); } else { - fprintf(stderr, "Unable to enter recipe directory %s: %s\n", recipe_dir, strerror(errno)); + SYSERROR("Unable to enter recipe directory %s: %s", recipe_dir, strerror(errno)); guard_free(recipe_dir); return -1; } @@ -360,7 +360,7 @@ int delivery_build_wheels_manylinux(struct Delivery *ctx, const char *outdir) { outdir); if (manylinux_build_status) { - msg(STASIS_MSG_L2 | STASIS_MSG_ERROR, "manylinux build failed (%d)", manylinux_build_status); + SYSERROR("manylinux build failed (%d)", manylinux_build_status); guard_free(script); return -1; } @@ -376,8 +376,8 @@ struct StrList *delivery_build_wheels(struct Delivery *ctx) { const int use_builder_manylinux = strcmp(globals.wheel_builder, "manylinux") == 0 && on_linux && docker_usable; if (!use_builder_build && !use_builder_cibuildwheel && !use_builder_manylinux) { - msg(STASIS_MSG_WARN, "Cannot build wheel for platform using: %s\n", globals.wheel_builder); - msg(STASIS_MSG_WARN, "Falling back to native toolchain.\n", globals.wheel_builder); + SYSWARN("Cannot build wheel for platform using: %s", globals.wheel_builder); + SYSWARN("Falling back to native toolchain.", globals.wheel_builder); use_builder_build = 1; } @@ -386,7 +386,7 @@ struct StrList *delivery_build_wheels(struct Delivery *ctx) { result = strlist_init(); if (!result) { - perror("unable to allocate memory for string list"); + SYSERROR("unable to allocate memory for string list"); return NULL; } @@ -434,14 +434,14 @@ struct StrList *delivery_build_wheels(struct Delivery *ctx) { const int dep_status = check_python_package_dependencies("."); if (dep_status) { - fprintf(stderr, "\nPlease replace all occurrences above with standard package specs:\n" + SYSERROR("Please replace all occurrences above with standard package specs:\n" "\n" " package==x.y.z\n" " package>=x.y.z\n" " package<=x.y.z\n" " ...\n" "\n"); - COE_CHECK_ABORT(dep_status, "Unreproducible delivery"); + COE_CHECK_ABORT(true, "Unreproducible delivery"); } strncpy(dname, ctx->tests->test[i]->name, sizeof(dname) - 1); @@ -449,13 +449,13 @@ struct StrList *delivery_build_wheels(struct Delivery *ctx) { tolower_s(dname); snprintf(outdir, sizeof(outdir), "%s/%s", ctx->storage.wheel_artifact_dir, dname); if (mkdirs(outdir, 0755)) { - fprintf(stderr, "failed to create output directory: %s\n", outdir); + SYSERROR("failed to create output directory: %s", outdir); guard_strlist_free(&result); return NULL; } if (use_builder_manylinux) { if (delivery_build_wheels_manylinux(ctx, outdir)) { - fprintf(stderr, "failed to generate wheel package for %s-%s\n", ctx->tests->test[i]->name, + SYSERROR("failed to generate wheel package for %s-%s", ctx->tests->test[i]->name, ctx->tests->test[i]->version); guard_strlist_free(&result); guard_free(cmd); @@ -476,7 +476,7 @@ struct StrList *delivery_build_wheels(struct Delivery *ctx) { } if (python_exec(cmd)) { - fprintf(stderr, "failed to generate wheel package for %s-%s\n", ctx->tests->test[i]->name, + SYSERROR("failed to generate wheel package for %s-%s", ctx->tests->test[i]->name, ctx->tests->test[i]->version); guard_strlist_free(&result); guard_free(cmd); @@ -490,7 +490,7 @@ struct StrList *delivery_build_wheels(struct Delivery *ctx) { guard_free(cmd); popd(); } else { - fprintf(stderr, "Unable to enter source directory %s: %s\n", srcdir, strerror(errno)); + SYSERROR("Unable to enter source directory %s: %s", srcdir, strerror(errno)); guard_strlist_free(&result); return NULL; } diff --git a/src/lib/delivery/delivery_conda.c b/src/lib/delivery/delivery_conda.c index 6e96d56..117e6c9 100644 --- a/src/lib/delivery/delivery_conda.c +++ b/src/lib/delivery/delivery_conda.c @@ -70,7 +70,7 @@ void delivery_install_conda(char *install_script, char *conda_install_dir) { if (!access(conda_install_dir, F_OK)) { // directory exists so remove it if (rmtree(conda_install_dir)) { - perror("unable to remove previous installation"); + SYSERROR("unable to remove previous installation: %s", strerror(errno)); exit(1); } @@ -82,7 +82,7 @@ void delivery_install_conda(char *install_script, char *conda_install_dir) { install_script, conda_install_dir); if (shell_safe(&proc, cmd)) { - fprintf(stderr, "conda installation failed\n"); + SYSERROR("conda installation failed"); exit(1); } } else { @@ -94,7 +94,7 @@ void delivery_install_conda(char *install_script, char *conda_install_dir) { install_script, conda_install_dir); if (shell_safe(&proc, cmd)) { - fprintf(stderr, "conda installation failed\n"); + SYSERROR("conda installation failed"); exit(1); } } @@ -105,7 +105,7 @@ void delivery_install_conda(char *install_script, char *conda_install_dir) { void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir) { if (conda_activate(conda_install_dir, "base")) { - fprintf(stderr, "conda activation failed\n"); + SYSERROR("conda activation failed"); exit(1); } @@ -116,7 +116,7 @@ void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir) { snprintf(rcpath, sizeof(rcpath), "%s/%s", conda_install_dir, ".condarc"); setenv("CONDARC", rcpath, 1); if (runtime_replace(&ctx->runtime.environ, __environ)) { - perror("unable to replace runtime environment after activating conda"); + SYSERROR("unable to replace runtime environment after activating conda"); exit(1); } diff --git a/src/lib/delivery/delivery_docker.c b/src/lib/delivery/delivery_docker.c index 3177c96..79e9729 100644 --- a/src/lib/delivery/delivery_docker.c +++ b/src/lib/delivery/delivery_docker.c @@ -11,12 +11,12 @@ int delivery_docker(struct Delivery *ctx) { size_t total_build_args = strlist_count(ctx->deploy.docker.build_args); if (!has_registry) { - msg(STASIS_MSG_WARN | STASIS_MSG_L2, "No docker registry defined. You will need to manually re-tag the resulting image.\n"); + SYSWARN("No docker registry defined. You will need to manually re-tag the resulting image."); } if (!total_tags) { char default_tag[PATH_MAX]; - msg(STASIS_MSG_WARN | STASIS_MSG_L2, "No docker tags defined by configuration. Generating default tag(s).\n"); + SYSWARN("No docker tags defined by configuration. Generating default tag(s)."); // generate local tag memset(default_tag, 0, sizeof(default_tag)); snprintf(default_tag, sizeof(default_tag), "%s:%s-py%s", ctx->meta.name, ctx->info.build_name, ctx->meta.python_compact); @@ -68,13 +68,13 @@ int delivery_docker(struct Delivery *ctx) { snprintf(delivery_file, sizeof(delivery_file), "%s/%s.yml", ctx->storage.delivery_dir, ctx->info.release_name); if (access(delivery_file, F_OK) < 0) { - fprintf(stderr, "docker build cannot proceed without delivery file: %s\n", delivery_file); + SYSERROR("docker build cannot proceed without delivery file: %s", delivery_file); return -1; } snprintf(dest, sizeof(dest), "%s/%s.yml", ctx->storage.build_docker_dir, ctx->info.release_name); if (copy2(delivery_file, dest, CT_PERM)) { - fprintf(stderr, "Failed to copy delivery file to %s: %s\n", dest, strerror(errno)); + SYSERROR("Failed to copy delivery file to %s: %s", dest, strerror(errno)); return -1; } @@ -85,7 +85,7 @@ int delivery_docker(struct Delivery *ctx) { memset(rsync_cmd, 0, sizeof(rsync_cmd)); snprintf(rsync_cmd, sizeof(rsync_cmd), "rsync -avi --progress '%s' '%s'", ctx->storage.conda_artifact_dir, dest); if (system(rsync_cmd)) { - fprintf(stderr, "Failed to copy conda artifacts to docker build directory\n"); + SYSERROR("Failed to copy conda artifacts to docker build directory"); return -1; } @@ -93,7 +93,7 @@ int delivery_docker(struct Delivery *ctx) { memset(rsync_cmd, 0, sizeof(rsync_cmd)); snprintf(rsync_cmd, sizeof(rsync_cmd), "rsync -avi --progress '%s' '%s'", ctx->storage.wheel_artifact_dir, dest); if (system(rsync_cmd)) { - fprintf(stderr, "Failed to copy wheel artifacts to docker build directory\n"); + SYSWARN("Failed to copy wheel artifacts to docker build directory. No wheels produced?"); } if (docker_build(ctx->storage.build_docker_dir, args, ctx->deploy.docker.capabilities.build)) { @@ -110,17 +110,17 @@ int delivery_docker(struct Delivery *ctx) { msg(STASIS_MSG_L2, "Executing image test script for %s\n", tag); if (ctx->deploy.docker.test_script) { if (isempty(ctx->deploy.docker.test_script)) { - msg(STASIS_MSG_L2 | STASIS_MSG_WARN, "Image test script has no content\n"); + SYSWARN("Image test script has no content"); } else { int state; if ((state = docker_script(tag, "--rm", ctx->deploy.docker.test_script, 0))) { - msg(STASIS_MSG_L2 | STASIS_MSG_ERROR, "Non-zero exit (%d) from test script. %s image archive will not be generated.\n", state >> 8, tag); + SYSERROR("Non-zero exit (%d) from test script. %s image archive will not be generated.", state >> 8, tag); // test failed -- don't save the image return -1; } } } else { - msg(STASIS_MSG_L2 | STASIS_MSG_WARN, "No image test script defined\n"); + SYSWARN("No image test script defined"); } // Test successful, save image diff --git a/src/lib/delivery/delivery_export.c b/src/lib/delivery/delivery_export.c index a973875..0321050 100644 --- a/src/lib/delivery/delivery_export.c +++ b/src/lib/delivery/delivery_export.c @@ -14,7 +14,7 @@ static void delivery_export_configuration(const struct Delivery *ctx) { SYSDEBUG("%s: opening", filename); FILE *spec = fopen(filename, "w+"); if (!spec) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed %s\n", filename); + SYSERROR("open failed %s", filename); exit(1); } SYSDEBUG("%s: writing", filename); @@ -32,7 +32,7 @@ static void delivery_export_configuration(const struct Delivery *ctx) { SYSDEBUG("%s: opening", filename); spec = fopen(filename, "w+"); if (!spec) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed %s\n", filename); + SYSERROR("open failed %s", filename); exit(1); } SYSDEBUG("%s: writing", filename); @@ -55,7 +55,7 @@ void delivery_export(const struct Delivery *ctx, char *envs[]) { char *name = envs[i]; msg(STASIS_MSG_L2, "Exporting %s\n", name); if (conda_env_export(name, ctx->storage.delivery_dir, name)) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed %s\n", name); + SYSERROR("export failed %s", name); exit(1); } } diff --git a/src/lib/delivery/delivery_init.c b/src/lib/delivery/delivery_init.c index 8e673ff..c73e7f0 100644 --- a/src/lib/delivery/delivery_init.c +++ b/src/lib/delivery/delivery_init.c @@ -54,14 +54,14 @@ int delivery_init_tmpdir(struct Delivery *ctx) { // If the directory doesn't exist, create it if (access(tmpdir, F_OK) < 0) { if (mkdirs(tmpdir, 0755) < 0) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "Unable to create temporary storage directory: %s (%s)\n", tmpdir, strerror(errno)); + SYSERROR("Unable to create temporary storage directory: %s (%s)", tmpdir, strerror(errno)); goto l_delivery_init_tmpdir_fatal; } } // If we can't read, write, or execute, then die if (access(tmpdir, R_OK | W_OK | X_OK) < 0) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "%s requires at least 0755 permissions.\n"); + SYSERROR("%s requires at least 0755 permissions."); goto l_delivery_init_tmpdir_fatal; } @@ -73,12 +73,12 @@ int delivery_init_tmpdir(struct Delivery *ctx) { #if defined(STASIS_OS_LINUX) // If we can't execute programs, or write data to the file system at all, then die if ((st.f_flag & ST_NOEXEC) != 0) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "%s is mounted with noexec\n", tmpdir); + SYSERROR("%s is mounted with noexec", tmpdir); goto l_delivery_init_tmpdir_fatal; } #endif if ((st.f_flag & ST_RDONLY) != 0) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "%s is mounted read-only\n", tmpdir); + SYSERROR("%s is mounted read-only", tmpdir); goto l_delivery_init_tmpdir_fatal; } @@ -129,7 +129,7 @@ void delivery_init_dirs_stage1(struct Delivery *ctx) { char *rootdir = getenv("STASIS_ROOT"); if (rootdir) { if (isempty(rootdir)) { - fprintf(stderr, "STASIS_ROOT is set, but empty. Please assign a file system path to this environment variable.\n"); + SYSERROR("STASIS_ROOT is set, but empty. Please assign a file system path to this environment variable."); exit(1); } path_store(&ctx->storage.root, PATH_MAX, rootdir, ctx->info.build_name); @@ -140,9 +140,10 @@ void delivery_init_dirs_stage1(struct Delivery *ctx) { path_store(&ctx->storage.tools_dir, PATH_MAX, ctx->storage.root, "tools"); path_store(&ctx->storage.tmpdir, PATH_MAX, ctx->storage.root, "tmp"); if (delivery_init_tmpdir(ctx)) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "Set $TMPDIR to a location other than %s\n", globals.tmpdir); - if (globals.tmpdir) + SYSERROR("Set $TMPDIR to a location other than %s", globals.tmpdir); + if (globals.tmpdir) { guard_free(globals.tmpdir); + } exit(1); } @@ -189,7 +190,7 @@ int delivery_init_platform(struct Delivery *ctx) { char archsuffix[20]; struct utsname uts; if (uname(&uts)) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "uname() failed: %s\n", strerror(errno)); + SYSERROR("uname() failed: %s", strerror(errno)); return -1; } @@ -242,7 +243,7 @@ int delivery_init_platform(struct Delivery *ctx) { long cpu_count = get_cpu_count(); if (!cpu_count) { - fprintf(stderr, "Unable to determine CPU count. Falling back to 1.\n"); + SYSERROR("Unable to determine CPU count. Falling back to 1."); cpu_count = 1; } char ncpus[100] = {0}; @@ -391,7 +392,7 @@ int delivery_exists(struct Delivery *ctx) { if (globals.enable_artifactory) { if (jfrt_auth_init(&ctx->deploy.jfrog_auth)) { - fprintf(stderr, "Failed to initialize Artifactory authentication context\n"); + SYSERROR("Failed to initialize Artifactory authentication context"); return -1; // error } diff --git a/src/lib/delivery/delivery_install.c b/src/lib/delivery/delivery_install.c index 6a6b746..4d52b82 100644 --- a/src/lib/delivery/delivery_install.c +++ b/src/lib/delivery/delivery_install.c @@ -436,7 +436,7 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha exit(1); } else if (!whl) { // not found - fprintf(stderr, "No wheel packages found that match the description of '%s'", info->name); + SYSERROR("No wheel packages found that match the description of '%s'", info->name); } else { // found, replace the original version with newly detected version guard_free(info->version); @@ -471,7 +471,7 @@ int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, cha } snprintf(args + strlen(args), args_alloc_len - strlen(args), fmt, req, info->version); } else { - fprintf(stderr, "Deferred package '%s' is not present in the tested package list!\n", name); + SYSERROR("Deferred package '%s' is not present in the tested package list!", name); guard_free(args); return -1; } diff --git a/src/lib/delivery/delivery_populate.c b/src/lib/delivery/delivery_populate.c index 546ce3b..cfa3da2 100644 --- a/src/lib/delivery/delivery_populate.c +++ b/src/lib/delivery/delivery_populate.c @@ -33,18 +33,18 @@ int populate_info(struct Delivery *ctx) { if (!ctx->info.time_info) { ctx->info.time_info = malloc(sizeof(*ctx->info.time_info)); if (!ctx->info.time_info) { - msg(STASIS_MSG_ERROR, "%s: Unable to allocate memory for time_info\n", strerror(errno)); + SYSERROR("%s: Unable to allocate memory for time_info", strerror(errno)); return -1; } if (!localtime_r(&ctx->info.time_now, ctx->info.time_info)) { - msg(STASIS_MSG_ERROR, "%s: localtime_r failed\n", strerror(errno)); + SYSERROR("%s: localtime_r failed", strerror(errno)); return -1; } } ctx->info.time_str_epoch = calloc(STASIS_TIME_STR_MAX, sizeof(*ctx->info.time_str_epoch)); if (!ctx->info.time_str_epoch) { - msg(STASIS_MSG_ERROR, "%s: Unable to allocate memory for Unix epoch string\n", strerror(errno)); + SYSERROR("%s: Unable to allocate memory for Unix epoch string", strerror(errno)); return -1; } snprintf(ctx->info.time_str_epoch, STASIS_TIME_STR_MAX - 1, "%li", ctx->info.time_now); @@ -89,7 +89,7 @@ int populate_delivery_cfg(struct Delivery *ctx, int render_mode) { if (!globals.wheel_builder) { globals.wheel_builder = ini_getval_str(cfg, "default", "wheel_builder", render_mode, &err); if (err) { - msg(STASIS_MSG_WARN, "wheel_builder is undefined. Falling back to system toolchain: 'build'.\n"); + SYSWARN("wheel_builder is undefined. Falling back to system toolchain: 'build'."); globals.wheel_builder = strdup("build"); if (!globals.wheel_builder) { SYSERROR("unable to allocate memory for default wheel_builder value"); @@ -257,7 +257,7 @@ int populate_delivery_ini(struct Delivery *ctx, int render_mode) { } if (delivery_format_str(ctx, &ctx->info.release_name, STASIS_NAME_MAX, ctx->rules.release_fmt)) { - fprintf(stderr, "Failed to generate release name. Format used: %s\n", ctx->rules.release_fmt); + SYSERROR("Failed to generate release name. Format used: %s", ctx->rules.release_fmt); return -1; } @@ -387,7 +387,7 @@ int populate_mission_ini(struct Delivery **ctx, int render_mode) { (*ctx)->_stasis_ini_fp.mission = ini_open(missionfile); struct INIFILE *ini = (*ctx)->_stasis_ini_fp.mission; if (!ini) { - msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Failed to read mission configuration: %s, %s\n", missionfile, strerror(errno)); + SYSERROR("Failed to read mission configuration: %s, %s", missionfile, strerror(errno)); return -1; } (*ctx)->_stasis_ini_fp.mission_path = strdup(missionfile); diff --git a/src/lib/delivery/delivery_postprocess.c b/src/lib/delivery/delivery_postprocess.c index 0f7d948..63093b3 100644 --- a/src/lib/delivery/delivery_postprocess.c +++ b/src/lib/delivery/delivery_postprocess.c @@ -78,12 +78,12 @@ void delivery_rewrite_spec(struct Delivery *ctx, char *filename, unsigned stage) header = delivery_get_release_header(ctx); SYSDEBUG("Release header:\n%s", header); if (!header) { - msg(STASIS_MSG_ERROR, "failed to generate release header string\n", filename); + SYSERROR("failed to generate release header string", filename); exit(1); } tempfile = xmkstemp(&tp, "w+"); if (!tempfile || !tp) { - msg(STASIS_MSG_ERROR, "%s: unable to create temporary file\n", strerror(errno)); + SYSERROR("%s: unable to create temporary file", strerror(errno)); exit(1); } SYSDEBUG("Writing header to temporary file: %s", tempfile); @@ -92,7 +92,7 @@ void delivery_rewrite_spec(struct Delivery *ctx, char *filename, unsigned stage) // Read the original file char **contents = file_readlines(filename, 0, 0, NULL); if (!contents) { - msg(STASIS_MSG_ERROR, "%s: unable to read %s", filename); + SYSERROR("%s: unable to read %s", filename); exit(1); } @@ -136,7 +136,7 @@ void delivery_rewrite_spec(struct Delivery *ctx, char *filename, unsigned stage) // Replace the original file with our temporary data if (copy2(tempfile, filename, CT_PERM) < 0) { - fprintf(stderr, "%s: could not rename '%s' to '%s'\n", strerror(errno), tempfile, filename); + SYSERROR("%s: could not rename '%s' to '%s'", strerror(errno), tempfile, filename); exit(1); } SYSDEBUG("Removing file: %s", tempfile); @@ -155,7 +155,7 @@ void delivery_rewrite_spec(struct Delivery *ctx, char *filename, unsigned stage) file_replace_text(filename, "@CONDA_CHANNEL@", output, 0); } else { SYSDEBUG("Will replace conda channel with local conda artifact directory"); - msg(STASIS_MSG_WARN, "conda_staging_dir is not configured. Using fallback: '%s'\n", ctx->storage.conda_artifact_dir); + SYSWARN("conda_staging_dir is not configured. Using fallback: '%s'", ctx->storage.conda_artifact_dir); file_replace_text(filename, "@CONDA_CHANNEL@", ctx->storage.conda_artifact_dir, 0); } @@ -169,7 +169,7 @@ void delivery_rewrite_spec(struct Delivery *ctx, char *filename, unsigned stage) file_replace_text(filename, "@PIP_ARGUMENTS@", output, 0); } else { SYSDEBUG("Will replace pip arguments with local wheel artifact directory"); - msg(STASIS_MSG_WARN, "wheel_staging_dir is not configured. Using fallback: '%s'\n", ctx->storage.wheel_artifact_dir); + SYSWARN("wheel_staging_dir is not configured. Using fallback: '%s'", ctx->storage.wheel_artifact_dir); snprintf(output, sizeof(output), "--extra-index-url file://%s", ctx->storage.wheel_artifact_dir); file_replace_text(filename, "@PIP_ARGUMENTS@", output, 0); } @@ -189,8 +189,7 @@ int delivery_copy_conda_artifacts(struct Delivery *ctx) { // One must run conda build at least once to create the "conda-bld" directory. // When this directory is missing there can be no build artifacts. if (access(conda_build_dir, F_OK) < 0) { - msg(STASIS_MSG_RESTRICT | STASIS_MSG_WARN | STASIS_MSG_L3, - "Skipped: 'conda build' has never been executed.\n"); + SYSWARN("Skipped: 'conda build' has never been executed."); return 0; } diff --git a/src/lib/delivery/delivery_show.c b/src/lib/delivery/delivery_show.c index f4ac825..1740688 100644 --- a/src/lib/delivery/delivery_show.c +++ b/src/lib/delivery/delivery_show.c @@ -108,7 +108,7 @@ void delivery_runtime_show(struct Delivery *ctx) { char *item = strlist_item(rt, i); if (!item) { // not supposed to occur - msg(STASIS_MSG_WARN | STASIS_MSG_L1, "Encountered unexpected NULL at record %zu of %zu of runtime array.\n", i); + SYSWARN("Encountered unexpected NULL in record %zu of %zu in runtime array.", i, total); return; } printf("%s\n", item); diff --git a/src/lib/delivery/delivery_test.c b/src/lib/delivery/delivery_test.c index 732ec2b..65d0451 100644 --- a/src/lib/delivery/delivery_test.c +++ b/src/lib/delivery/delivery_test.c @@ -97,25 +97,25 @@ void delivery_tests_run(struct Delivery *ctx) { snprintf(globals.workaround.conda_reactivate, PATH_MAX - 1, "\nset +x; mamba activate ${CONDA_DEFAULT_ENV}; set -x\n"); if (!ctx->tests || !ctx->tests->num_used) { - msg(STASIS_MSG_WARN | STASIS_MSG_L2, "no tests are defined!\n"); + SYSWARN("no tests are defined!"); } else { pool[PARALLEL] = mp_pool_init("parallel", ctx->storage.tmpdir); if (!pool[PARALLEL]) { - perror("mp_pool_init/parallel"); + SYSERROR("mp_pool_init/parallel initialization failed"); exit(1); } pool[PARALLEL]->status_interval = globals.pool_status_interval; pool[SERIAL] = mp_pool_init("serial", ctx->storage.tmpdir); if (!pool[SERIAL]) { - perror("mp_pool_init/serial"); + SYSERROR("mp_pool_init/serial initialization failed"); exit(1); } pool[SERIAL]->status_interval = globals.pool_status_interval; pool[SETUP] = mp_pool_init("setup", ctx->storage.tmpdir); if (!pool[SETUP]) { - perror("mp_pool_init/setup"); + SYSERROR("mp_pool_init/setup initialization failed"); exit(1); } pool[SETUP]->status_interval = globals.pool_status_interval; @@ -148,8 +148,7 @@ void delivery_tests_run(struct Delivery *ctx) { } msg(STASIS_MSG_L2, "Loading tests for %s %s\n", test->name, test->version); if (!test->script || !strlen(test->script)) { - msg(STASIS_MSG_WARN | STASIS_MSG_L3, "Nothing to do. To fix, declare a 'script' in section: [test:%s]\n", - test->name); + SYSWARN("Nothing to do. To fix, declare a 'script' in section: [test:%s]", test->name); continue; } @@ -179,14 +178,14 @@ void delivery_tests_run(struct Delivery *ctx) { } else { int dep_status = check_python_package_dependencies("."); if (dep_status) { - fprintf(stderr, "\nPlease replace all occurrences above with standard package specs:\n" + SYSERROR("Please replace all occurrences above with standard package specs:\n" "\n" " package==x.y.z\n" " package>=x.y.z\n" " package<=x.y.z\n" " ...\n" "\n"); - COE_CHECK_ABORT(dep_status, "Unreproducible delivery"); + COE_CHECK_ABORT(true, "Unreproducible delivery"); } char *cmd = calloc(strlen(test->script) + STASIS_BUFSIZ, sizeof(*cmd)); @@ -387,7 +386,7 @@ int delivery_fixup_test_results(struct Delivery *ctx) { snprintf(path, sizeof(path), "%s/%s", ctx->storage.results_dir, rec->d_name); msg(STASIS_MSG_L3, "%s\n", rec->d_name); if (xml_pretty_print_in_place(path, STASIS_XML_PRETTY_PRINT_PROG, STASIS_XML_PRETTY_PRINT_ARGS)) { - msg(STASIS_MSG_L3 | STASIS_MSG_WARN, "Failed to rewrite file '%s'\n", rec->d_name); + SYSWARN("Failed to rewrite file '%s'", rec->d_name); } } |
