diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 20 | ||||
-rw-r--r-- | src/artifactory.c | 60 | ||||
-rw-r--r-- | src/conda.c | 24 | ||||
-rw-r--r-- | src/copy.c | 2 | ||||
-rw-r--r-- | src/delivery.c (renamed from src/deliverable.c) | 202 | ||||
-rw-r--r-- | src/docker.c | 22 | ||||
-rw-r--r-- | src/download.c | 2 | ||||
-rw-r--r-- | src/environment.c | 6 | ||||
-rw-r--r-- | src/globals.c | 31 | ||||
-rw-r--r-- | src/ini.c | 12 | ||||
-rw-r--r-- | src/recipe.c | 2 | ||||
-rw-r--r-- | src/relocation.c | 4 | ||||
-rw-r--r-- | src/stasis_indexer.c (renamed from src/omc_indexer.c) | 38 | ||||
-rw-r--r-- | src/stasis_main.c (renamed from src/omc_main.c) | 206 | ||||
-rw-r--r-- | src/str.c | 12 | ||||
-rw-r--r-- | src/system.c | 8 | ||||
-rw-r--r-- | src/template.c | 2 | ||||
-rw-r--r-- | src/utils.c | 52 |
18 files changed, 352 insertions, 353 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f075102..c42bb0f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,7 @@ include_directories(${CMAKE_BINARY_DIR}/include) include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${PROJECT_BINARY_DIR}) -add_library(ohmycal STATIC +add_library(stasis_core STATIC globals.c str.c strlist.c @@ -12,7 +12,7 @@ add_library(ohmycal STATIC utils.c system.c download.c - deliverable.c + delivery.c recipe.c relocation.c wheel.c @@ -24,13 +24,13 @@ add_library(ohmycal STATIC junitxml.c ) -add_executable(omc - omc_main.c +add_executable(stasis + stasis_main.c ) -target_link_libraries(omc PRIVATE ohmycal) -target_link_libraries(omc PUBLIC LibXml2::LibXml2) -add_executable(omc_indexer - omc_indexer.c +target_link_libraries(stasis PRIVATE stasis_core) +target_link_libraries(stasis PUBLIC LibXml2::LibXml2) +add_executable(stasis_indexer + stasis_indexer.c ) -target_link_libraries(omc_indexer PRIVATE ohmycal) -install(TARGETS omc omc_indexer RUNTIME) +target_link_libraries(stasis_indexer PRIVATE stasis_core) +install(TARGETS stasis stasis_indexer RUNTIME) diff --git a/src/artifactory.c b/src/artifactory.c index 5678d64..bd9aa99 100644 --- a/src/artifactory.c +++ b/src/artifactory.c @@ -1,6 +1,6 @@ -#include "omc.h" +#include "core.h" -extern struct OMC_GLOBAL globals; +extern struct STASIS_GLOBAL globals; int artifactory_download_cli(char *dest, char *jfrog_artifactory_base_url, @@ -12,8 +12,8 @@ int artifactory_download_cli(char *dest, char *remote_filename) { char url[PATH_MAX] = {0}; char path[PATH_MAX] = {0}; - char os_ident[OMC_NAME_MAX] = {0}; - char arch_ident[OMC_NAME_MAX] = {0}; + char os_ident[STASIS_NAME_MAX] = {0}; + char arch_ident[STASIS_NAME_MAX] = {0}; // convert platform string to lower-case strcpy(os_ident, os); @@ -73,7 +73,7 @@ int artifactory_download_cli(char *dest, } void jfrt_register_opt_str(char *jfrt_val, const char *opt_name, struct StrList **opt_map) { - char data[OMC_BUFSIZ]; + char data[STASIS_BUFSIZ]; memset(data, 0, sizeof(data)); if (jfrt_val == NULL) { @@ -85,7 +85,7 @@ void jfrt_register_opt_str(char *jfrt_val, const char *opt_name, struct StrList } void jfrt_register_opt_bool(bool jfrt_val, const char *opt_name, struct StrList **opt_map) { - char data[OMC_BUFSIZ]; + char data[STASIS_BUFSIZ]; memset(data, 0, sizeof(data)); if (jfrt_val == false) { @@ -97,7 +97,7 @@ void jfrt_register_opt_bool(bool jfrt_val, const char *opt_name, struct StrList } void jfrt_register_opt_int(int jfrt_val, const char *opt_name, struct StrList **opt_map) { - char data[OMC_BUFSIZ]; + char data[STASIS_BUFSIZ]; memset(data, 0, sizeof(data)); if (jfrt_val == 0) { @@ -109,7 +109,7 @@ void jfrt_register_opt_int(int jfrt_val, const char *opt_name, struct StrList ** } void jfrt_register_opt_long(long jfrt_val, const char *opt_name, struct StrList **opt_map) { - char data[OMC_BUFSIZ]; + char data[STASIS_BUFSIZ]; memset(data, 0, sizeof(data)); if (jfrt_val == 0) { @@ -141,18 +141,18 @@ static int auth_required(char *cmd) { } int jfrt_auth_init(struct JFRT_Auth *auth_ctx) { - char *url = getenv("OMC_JF_ARTIFACTORY_URL"); - char *user = getenv("OMC_JF_USER"); - char *access_token = getenv("OMC_JF_ACCESS_TOKEN"); - char *password = getenv("OMC_JF_PASSWORD"); - char *ssh_key_path = getenv("OMC_JF_SSH_KEY_PATH"); - char *ssh_passphrase = getenv("OMC_JF_SSH_PASSPHRASE"); - char *client_cert_key_path = getenv("OMC_JF_CLIENT_CERT_KEY_PATH"); - char *client_cert_path = getenv("OMC_JF_CLIENT_CERT_PATH"); + char *url = getenv("STASIS_JF_ARTIFACTORY_URL"); + char *user = getenv("STASIS_JF_USER"); + char *access_token = getenv("STASIS_JF_ACCESS_TOKEN"); + char *password = getenv("STASIS_JF_PASSWORD"); + char *ssh_key_path = getenv("STASIS_JF_SSH_KEY_PATH"); + char *ssh_passphrase = getenv("STASIS_JF_SSH_PASSPHRASE"); + char *client_cert_key_path = getenv("STASIS_JF_CLIENT_CERT_KEY_PATH"); + char *client_cert_path = getenv("STASIS_JF_CLIENT_CERT_PATH"); if (!url) { fprintf(stderr, "Artifactory URL is not configured:\n"); - fprintf(stderr, "please set OMC_JF_ARTIFACTORY_URL\n"); + fprintf(stderr, "please set STASIS_JF_ARTIFACTORY_URL\n"); return -1; } auth_ctx->url = url; @@ -184,10 +184,10 @@ int jfrt_auth_init(struct JFRT_Auth *auth_ctx) { auth_ctx->client_cert_path = client_cert_path; } else { fprintf(stderr, "Artifactory authentication is not configured:\n"); - fprintf(stderr, "set OMC_JF_USER and OMC_JF_PASSWORD\n"); - fprintf(stderr, "or, set OMC_JF_ACCESS_TOKEN\n"); - fprintf(stderr, "or, set OMC_JF_SSH_KEY_PATH and OMC_JF_SSH_KEY_PASSPHRASE\n"); - fprintf(stderr, "or, set OMC_JF_CLIENT_CERT_KEY_PATH and OMC_JF_CLIENT_CERT_PATH\n"); + fprintf(stderr, "set STASIS_JF_USER and STASIS_JF_PASSWORD\n"); + fprintf(stderr, "or, set STASIS_JF_ACCESS_TOKEN\n"); + fprintf(stderr, "or, set STASIS_JF_SSH_KEY_PATH and STASIS_JF_SSH_KEY_PASSPHRASE\n"); + fprintf(stderr, "or, set STASIS_JF_CLIENT_CERT_KEY_PATH and STASIS_JF_CLIENT_CERT_PATH\n"); return -1; } return 0; @@ -195,8 +195,8 @@ int jfrt_auth_init(struct JFRT_Auth *auth_ctx) { int jfrog_cli(struct JFRT_Auth *auth, char *args) { struct Process proc; - char cmd[OMC_BUFSIZ]; - char cmd_redacted[OMC_BUFSIZ]; + char cmd[STASIS_BUFSIZ]; + char cmd_redacted[STASIS_BUFSIZ]; int status; memset(&proc, 0, sizeof(proc)); @@ -244,7 +244,7 @@ int jfrog_cli(struct JFRT_Auth *auth, char *args) { // Pings are noisy. Squelch them. if (!strstr(args, "rt ping")) { - msg(OMC_MSG_L2, "Executing: %s\n", cmd_redacted); + msg(STASIS_MSG_L2, "Executing: %s\n", cmd_redacted); } if (!globals.verbose) { @@ -256,28 +256,28 @@ int jfrog_cli(struct JFRT_Auth *auth, char *args) { } int jfrog_cli_rt(struct JFRT_Auth *auth, char *args) { - char cmd[OMC_BUFSIZ]; + char cmd[STASIS_BUFSIZ]; memset(cmd, 0, sizeof(cmd)); snprintf(cmd, sizeof(cmd) - 1, "rt %s", args); return jfrog_cli(auth, args); } int jfrog_cli_rt_build_collect_env(struct JFRT_Auth *auth, char *build_name, char *build_number) { - char cmd[OMC_BUFSIZ]; + char cmd[STASIS_BUFSIZ]; memset(cmd, 0, sizeof(cmd)); snprintf(cmd, sizeof(cmd) - 1, "rt build-collect-env \"%s\" \"%s\"", build_name, build_number); return jfrog_cli(auth, cmd); } int jfrog_cli_rt_build_publish(struct JFRT_Auth *auth, char *build_name, char *build_number) { - char cmd[OMC_BUFSIZ]; + char cmd[STASIS_BUFSIZ]; memset(cmd, 0, sizeof(cmd)); snprintf(cmd, sizeof(cmd) - 1, "rt build-publish \"%s\" \"%s\"", build_name, build_number); return jfrog_cli(auth, cmd); } int jfrog_cli_rt_ping(struct JFRT_Auth *auth) { - char cmd[OMC_BUFSIZ]; + char cmd[STASIS_BUFSIZ]; memset(cmd, 0, sizeof(cmd)); snprintf(cmd, sizeof(cmd) - 1, "rt ping"); @@ -285,7 +285,7 @@ int jfrog_cli_rt_ping(struct JFRT_Auth *auth) { } int jfrog_cli_rt_download(struct JFRT_Auth *auth, struct JFRT_Download *ctx, char *repo_path, char *dest) { - char cmd[OMC_BUFSIZ]; + char cmd[STASIS_BUFSIZ]; memset(cmd, 0, sizeof(cmd)); if (isempty(repo_path)) { @@ -352,7 +352,7 @@ int jfrog_cli_rt_download(struct JFRT_Auth *auth, struct JFRT_Download *ctx, cha } int jfrog_cli_rt_upload(struct JFRT_Auth *auth, struct JFRT_Upload *ctx, char *src, char *repo_path) { - char cmd[OMC_BUFSIZ]; + char cmd[STASIS_BUFSIZ]; memset(cmd, 0, sizeof(cmd)); if (isempty(src)) { diff --git a/src/conda.c b/src/conda.c index efb42fa..342b6af 100644 --- a/src/conda.c +++ b/src/conda.c @@ -5,13 +5,11 @@ #include <unistd.h> #include "conda.h" -extern struct OMC_GLOBAL globals; - int python_exec(const char *args) { char command[PATH_MAX]; memset(command, 0, sizeof(command)); snprintf(command, sizeof(command) - 1, "python %s", args); - msg(OMC_MSG_L3, "Executing: %s\n", command); + msg(STASIS_MSG_L3, "Executing: %s\n", command); return system(command); } @@ -19,7 +17,7 @@ int pip_exec(const char *args) { char command[PATH_MAX]; memset(command, 0, sizeof(command)); snprintf(command, sizeof(command) - 1, "python -m pip %s", args); - msg(OMC_MSG_L3, "Executing: %s\n", command); + msg(STASIS_MSG_L3, "Executing: %s\n", command); return system(command); } @@ -51,7 +49,7 @@ int conda_exec(const char *args) { } snprintf(command, sizeof(command) - 1, "%s %s", conda_as, args); - msg(OMC_MSG_L3, "Executing: %s\n", command); + msg(STASIS_MSG_L3, "Executing: %s\n", command); return system(command); } @@ -109,7 +107,7 @@ int conda_activate(const char *root, const char *env_name) { // Parse the log file: // 1. Extract the environment keys and values from the sub-shell - // 2. Apply it to OMC's runtime environment + // 2. Apply it to STASIS's runtime environment // 3. Now we're ready to execute conda commands anywhere fp = fopen(proc.f_stdout, "r"); if (!fp) { @@ -118,7 +116,7 @@ int conda_activate(const char *root, const char *env_name) { } int i = 0; while (!feof(fp)) { - char buf[OMC_BUFSIZ] = {0}; + char buf[STASIS_BUFSIZ] = {0}; int ch = 0; size_t z = 0; // We are ingesting output from "env -0", can't use fgets() @@ -142,10 +140,10 @@ int conda_activate(const char *root, const char *env_name) { return -1; } if (!part[0]) { - msg(OMC_MSG_WARN | OMC_MSG_L1, "Invalid environment variable key ignored: '%s'\n", buf); + msg(STASIS_MSG_WARN | STASIS_MSG_L1, "Invalid environment variable key ignored: '%s'\n", buf); i++; } else if (!part[1]) { - msg(OMC_MSG_WARN | OMC_MSG_L1, "Invalid environment variable value ignored: '%s'\n", buf); + msg(STASIS_MSG_WARN | STASIS_MSG_L1, "Invalid environment variable value ignored: '%s'\n", buf); i++; } else { setenv(part[0], part[1], 1); @@ -193,7 +191,7 @@ int conda_check_required() { guard_free(cmd_out); guard_strlist_free(&result); } else { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "The base package requirement check could not be performed\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "The base package requirement check could not be performed\n"); return 2; } return 0; @@ -234,7 +232,7 @@ void conda_setup_headless() { } if (conda_exec(cmd)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "Unable to install user-defined base packages (conda)\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Unable to install user-defined base packages (conda)\n"); exit(1); } } @@ -256,13 +254,13 @@ void conda_setup_headless() { } if (pip_exec(cmd)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "Unable to install user-defined base packages (pip)\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Unable to install user-defined base packages (pip)\n"); exit(1); } } if (conda_check_required()) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "Your OMC configuration lacks the bare" + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Your STASIS configuration lacks the bare" " minimum software required to build conda packages." " Please fix it.\n"); exit(1); @@ -3,7 +3,7 @@ int copy2(const char *src, const char *dest, unsigned int op) { size_t bytes_read; size_t bytes_written; - char buf[OMC_BUFSIZ]; + char buf[STASIS_BUFSIZ]; struct stat src_stat, dnamest; FILE *fp1, *fp2; diff --git a/src/deliverable.c b/src/delivery.c index f72f535..e77d41c 100644 --- a/src/deliverable.c +++ b/src/delivery.c @@ -1,9 +1,9 @@ #define _GNU_SOURCE #include <fnmatch.h> -#include "omc.h" +#include "core.h" -extern struct OMC_GLOBAL globals; +extern struct STASIS_GLOBAL globals; static void ini_has_key_required(struct INIFILE *ini, const char *section_name, char *key) { int status = ini_has_key(ini, section_name, key); @@ -87,14 +87,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(OMC_MSG_ERROR | OMC_MSG_L1, "Unable to create temporary storage directory: %s (%s)\n", tmpdir, strerror(errno)); + msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "Unable to create temporary storage directory: %s (%s)\n", 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(OMC_MSG_ERROR | OMC_MSG_L1, "%s requires at least 0755 permissions.\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "%s requires at least 0755 permissions.\n"); goto l_delivery_init_tmpdir_fatal; } @@ -103,15 +103,15 @@ int delivery_init_tmpdir(struct Delivery *ctx) { goto l_delivery_init_tmpdir_fatal; } -#if defined(OMC_OS_LINUX) +#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(OMC_MSG_ERROR | OMC_MSG_L1, "%s is mounted with noexec\n", tmpdir); + msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "%s is mounted with noexec\n", tmpdir); goto l_delivery_init_tmpdir_fatal; } #endif if ((st.f_flag & ST_RDONLY) != 0) { - msg(OMC_MSG_ERROR | OMC_MSG_L1, "%s is mounted read-only\n", tmpdir); + msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "%s is mounted read-only\n", tmpdir); goto l_delivery_init_tmpdir_fatal; } @@ -208,21 +208,21 @@ void delivery_free(struct Delivery *ctx) { guard_strlist_free(&ctx->deploy.jfrog[i].files); } - if (ctx->_omc_ini_fp.delivery) { - ini_free(&ctx->_omc_ini_fp.delivery); + if (ctx->_stasis_ini_fp.delivery) { + ini_free(&ctx->_stasis_ini_fp.delivery); } - guard_free(ctx->_omc_ini_fp.delivery_path); + guard_free(ctx->_stasis_ini_fp.delivery_path); - if (ctx->_omc_ini_fp.cfg) { + if (ctx->_stasis_ini_fp.cfg) { // optional extras - ini_free(&ctx->_omc_ini_fp.cfg); + ini_free(&ctx->_stasis_ini_fp.cfg); } - guard_free(ctx->_omc_ini_fp.cfg_path); + guard_free(ctx->_stasis_ini_fp.cfg_path); - if (ctx->_omc_ini_fp.mission) { - ini_free(&ctx->_omc_ini_fp.mission); + if (ctx->_stasis_ini_fp.mission) { + ini_free(&ctx->_stasis_ini_fp.mission); } - guard_free(ctx->_omc_ini_fp.mission_path); + guard_free(ctx->_stasis_ini_fp.mission_path); } void delivery_init_dirs_stage2(struct Delivery *ctx) { @@ -243,21 +243,21 @@ void delivery_init_dirs_stage2(struct Delivery *ctx) { } void delivery_init_dirs_stage1(struct Delivery *ctx) { - char *rootdir = getenv("OMC_ROOT"); + char *rootdir = getenv("STASIS_ROOT"); if (rootdir) { if (isempty(rootdir)) { - fprintf(stderr, "OMC_ROOT is set, but empty. Please assign a file system path to this environment variable.\n"); + fprintf(stderr, "STASIS_ROOT is set, but empty. Please assign a file system path to this environment variable.\n"); exit(1); } path_store(&ctx->storage.root, PATH_MAX, rootdir, ctx->info.build_name); } else { - // use "omc" in current working directory - path_store(&ctx->storage.root, PATH_MAX, "omc", ctx->info.build_name); + // use "stasis" in current working directory + path_store(&ctx->storage.root, PATH_MAX, "stasis", ctx->info.build_name); } 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(OMC_MSG_ERROR | OMC_MSG_L1, "Set $TMPDIR to a location other than %s\n", globals.tmpdir); + msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "Set $TMPDIR to a location other than %s\n", globals.tmpdir); if (globals.tmpdir) guard_free(globals.tmpdir); exit(1); @@ -271,7 +271,7 @@ void delivery_init_dirs_stage1(struct Delivery *ctx) { } if (access(ctx->storage.mission_dir, F_OK)) { - msg(OMC_MSG_L1, "%s: %s\n", ctx->storage.mission_dir, strerror(errno)); + msg(STASIS_MSG_L1, "%s: %s\n", ctx->storage.mission_dir, strerror(errno)); exit(1); } @@ -281,7 +281,7 @@ void delivery_init_dirs_stage1(struct Delivery *ctx) { globals.conda_fresh_start = false; /* if (mkdirs(globals.conda_install_prefix, 0755)) { - msg(OMC_MSG_ERROR | OMC_MSG_L1, "Unable to create directory: %s: %s\n", + msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "Unable to create directory: %s: %s\n", strerror(errno), globals.conda_install_prefix); exit(1); } @@ -289,24 +289,24 @@ void delivery_init_dirs_stage1(struct Delivery *ctx) { /* ctx->storage.conda_install_prefix = realpath(globals.conda_install_prefix, NULL); if (!ctx->storage.conda_install_prefix) { - msg(OMC_MSG_ERROR | OMC_MSG_L1, "realpath(): Conda installation prefix reassignment failed\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "realpath(): Conda installation prefix reassignment failed\n"); exit(1); } ctx->storage.conda_install_prefix = strdup(globals.conda_install_prefix); */ path_store(&ctx->storage.conda_install_prefix, PATH_MAX, globals.conda_install_prefix, "conda"); } else { - // install conda under the OMC tree + // install conda under the STASIS tree path_store(&ctx->storage.conda_install_prefix, PATH_MAX, ctx->storage.tools_dir, "conda"); } } int delivery_init_platform(struct Delivery *ctx) { - msg(OMC_MSG_L2, "Setting architecture\n"); + msg(STASIS_MSG_L2, "Setting architecture\n"); char archsuffix[20]; struct utsname uts; if (uname(&uts)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "uname() failed: %s\n", strerror(errno)); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "uname() failed: %s\n", strerror(errno)); return -1; } @@ -331,7 +331,7 @@ int delivery_init_platform(struct Delivery *ctx) { strcpy(archsuffix, ctx->system.arch); } - msg(OMC_MSG_L2, "Setting platform\n"); + msg(STASIS_MSG_L2, "Setting platform\n"); strcpy(ctx->system.platform[DELIVERY_PLATFORM], uts.sysname); if (!strcmp(ctx->system.platform[DELIVERY_PLATFORM], "Darwin")) { sprintf(ctx->system.platform[DELIVERY_PLATFORM_CONDA_SUBDIR], "osx-%s", archsuffix); @@ -350,11 +350,11 @@ int delivery_init_platform(struct Delivery *ctx) { } // Declare some important bits as environment variables - setenv("OMC_ARCH", ctx->system.arch, 1); - setenv("OMC_PLATFORM", ctx->system.platform[DELIVERY_PLATFORM], 1); - setenv("OMC_CONDA_ARCH", ctx->system.arch, 1); - setenv("OMC_CONDA_PLATFORM", ctx->system.platform[DELIVERY_PLATFORM_CONDA_INSTALLER], 1); - setenv("OMC_CONDA_PLATFORM_SUBDIR", ctx->system.platform[DELIVERY_PLATFORM_CONDA_SUBDIR], 1); + setenv("STASIS_ARCH", ctx->system.arch, 1); + setenv("STASIS_PLATFORM", ctx->system.platform[DELIVERY_PLATFORM], 1); + setenv("STASIS_CONDA_ARCH", ctx->system.arch, 1); + setenv("STASIS_CONDA_PLATFORM", ctx->system.platform[DELIVERY_PLATFORM_CONDA_INSTALLER], 1); + setenv("STASIS_CONDA_PLATFORM_SUBDIR", ctx->system.platform[DELIVERY_PLATFORM_CONDA_SUBDIR], 1); // Register template variables // These were moved out of main() because we can't take the address of system.platform[x] @@ -369,28 +369,28 @@ static int populate_mission_ini(struct Delivery **ctx) { union INIVal val; struct INIFILE *ini; - if ((*ctx)->_omc_ini_fp.mission) { + if ((*ctx)->_stasis_ini_fp.mission) { return 0; } // Now populate the rules char missionfile[PATH_MAX] = {0}; - if (getenv("OMC_SYSCONFDIR")) { + if (getenv("STASIS_SYSCONFDIR")) { sprintf(missionfile, "%s/%s/%s/%s.ini", - getenv("OMC_SYSCONFDIR"), "mission", (*ctx)->meta.mission, (*ctx)->meta.mission); + getenv("STASIS_SYSCONFDIR"), "mission", (*ctx)->meta.mission, (*ctx)->meta.mission); } else { sprintf(missionfile, "%s/%s/%s/%s.ini", globals.sysconfdir, "mission", (*ctx)->meta.mission, (*ctx)->meta.mission); } - msg(OMC_MSG_L2, "Reading mission configuration: %s\n", missionfile); - (*ctx)->_omc_ini_fp.mission = ini_open(missionfile); - ini = (*ctx)->_omc_ini_fp.mission; + msg(STASIS_MSG_L2, "Reading mission configuration: %s\n", missionfile); + (*ctx)->_stasis_ini_fp.mission = ini_open(missionfile); + ini = (*ctx)->_stasis_ini_fp.mission; if (!ini) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "Failed to read misson configuration: %s, %s\n", missionfile, strerror(errno)); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Failed to read misson configuration: %s, %s\n", missionfile, strerror(errno)); exit(1); } - (*ctx)->_omc_ini_fp.mission_path = strdup(missionfile); + (*ctx)->_stasis_ini_fp.mission_path = strdup(missionfile); ini_getval_required(ini, "meta", "release_fmt", INIVAL_TYPE_STR, &val); conv_str(&(*ctx)->rules.release_fmt, val); @@ -455,7 +455,7 @@ void validate_delivery_ini(struct INIFILE *ini) { static int populate_delivery_ini(struct Delivery *ctx) { union INIVal val; - struct INIFILE *ini = ctx->_omc_ini_fp.delivery; + struct INIFILE *ini = ctx->_stasis_ini_fp.delivery; struct INIData *rtdata; RuntimeEnv *rt; @@ -464,7 +464,7 @@ static int populate_delivery_ini(struct Delivery *ctx) { // keys in the configuration rt = runtime_copy(__environ); while ((rtdata = ini_getall(ini, "runtime")) != NULL) { - char rec[OMC_BUFSIZ]; + char rec[STASIS_BUFSIZ]; sprintf(rec, "%s=%s", lstrip(strip(rtdata->key)), lstrip(strip(rtdata->value))); runtime_set(rt, rtdata->key, rtdata->value); } @@ -680,7 +680,7 @@ static int populate_delivery_ini(struct Delivery *ctx) { static int populate_delivery_cfg(struct Delivery *ctx) { union INIVal val; - struct INIFILE *cfg = ctx->_omc_ini_fp.cfg; + struct INIFILE *cfg = ctx->_stasis_ini_fp.cfg; if (!cfg) { return -1; } @@ -734,12 +734,12 @@ static int populate_info(struct Delivery *ctx) { time(&ctx->info.time_now); ctx->info.time_info = localtime(&ctx->info.time_now); - ctx->info.time_str_epoch = calloc(OMC_TIME_STR_MAX, sizeof(*ctx->info.time_str_epoch)); + ctx->info.time_str_epoch = calloc(STASIS_TIME_STR_MAX, sizeof(*ctx->info.time_str_epoch)); if (!ctx->info.time_str_epoch) { - msg(OMC_MSG_ERROR, "Unable to allocate memory for Unix epoch string\n"); + msg(STASIS_MSG_ERROR, "Unable to allocate memory for Unix epoch string\n"); return -1; } - snprintf(ctx->info.time_str_epoch, OMC_TIME_STR_MAX - 1, "%li", ctx->info.time_now); + snprintf(ctx->info.time_str_epoch, STASIS_TIME_STR_MAX - 1, "%li", ctx->info.time_now); } return 0; } @@ -747,8 +747,8 @@ static int populate_info(struct Delivery *ctx) { int *bootstrap_build_info(struct Delivery *ctx) { struct Delivery local; memset(&local, 0, sizeof(local)); - local._omc_ini_fp.cfg = ini_open(ctx->_omc_ini_fp.cfg_path); - local._omc_ini_fp.delivery = ini_open(ctx->_omc_ini_fp.delivery_path); + local._stasis_ini_fp.cfg = ini_open(ctx->_stasis_ini_fp.cfg_path); + local._stasis_ini_fp.delivery = ini_open(ctx->_stasis_ini_fp.delivery_path); delivery_init_platform(&local); populate_delivery_cfg(&local); populate_delivery_ini(&local); @@ -768,7 +768,7 @@ int delivery_init(struct Delivery *ctx) { populate_delivery_cfg(ctx); // Set artifactory URL via environment variable if possible - char *jfurl = getenv("OMC_JF_ARTIFACTORY_URL"); + char *jfurl = getenv("STASIS_JF_ARTIFACTORY_URL"); if (jfurl) { if (globals.jfrog.url) { guard_free(globals.jfrog.url); @@ -777,7 +777,7 @@ int delivery_init(struct Delivery *ctx) { } // Set artifactory repository via environment if possible - char *jfrepo = getenv("OMC_JF_REPO"); + char *jfrepo = getenv("STASIS_JF_REPO"); if (jfrepo) { if (globals.jfrog.repo) { guard_free(globals.jfrog.repo); @@ -788,7 +788,7 @@ int delivery_init(struct Delivery *ctx) { // Configure architecture and platform information delivery_init_platform(ctx); - // Create OMC directory structure + // Create STASIS directory structure delivery_init_dirs_stage1(ctx); char config_local[PATH_MAX]; @@ -800,7 +800,7 @@ int delivery_init(struct Delivery *ctx) { setenv("XDG_CACHE_HOME", ctx->storage.tmpdir, 1); // add tools to PATH - char pathvar_tmp[OMC_BUFSIZ]; + char pathvar_tmp[STASIS_BUFSIZ]; sprintf(pathvar_tmp, "%s/bin:%s", ctx->storage.tools_dir, getenv("PATH")); setenv("PATH", pathvar_tmp, 1); @@ -829,7 +829,7 @@ int delivery_format_str(struct Delivery *ctx, char **dest, const char *fmt) { size_t fmt_len = strlen(fmt); if (!*dest) { - *dest = calloc(OMC_NAME_MAX, sizeof(**dest)); + *dest = calloc(STASIS_NAME_MAX, sizeof(**dest)); if (!*dest) { return -1; } @@ -968,13 +968,13 @@ void delivery_runtime_show(struct Delivery *ctx) { // no data return; } - strlist_sort(rt, OMC_SORT_ALPHA); + strlist_sort(rt, STASIS_SORT_ALPHA); size_t total = strlist_count(rt); for (size_t i = 0; i < total; i++) { char *item = strlist_item(rt, i); if (!item) { // not supposed to occur - msg(OMC_MSG_WARN | OMC_MSG_L1, "Encountered unexpected NULL at record %zu of %zu of runtime array.\n", i); + msg(STASIS_MSG_WARN | STASIS_MSG_L1, "Encountered unexpected NULL at record %zu of %zu of runtime array.\n", i); return; } printf("%s\n", item); @@ -1150,7 +1150,7 @@ static const struct Test *requirement_from_test(struct Delivery *ctx, const char int delivery_install_packages(struct Delivery *ctx, char *conda_install_dir, char *env_name, int type, struct StrList **manifest) { char cmd[PATH_MAX]; - char pkgs[OMC_BUFSIZ]; + char pkgs[STASIS_BUFSIZ]; char *env_current = getenv("CONDA_DEFAULT_ENV"); if (env_current) { @@ -1251,7 +1251,7 @@ int delivery_get_installer(struct Delivery *ctx, char *installer_url) { return -1; } } else { - msg(OMC_MSG_RESTRICT | OMC_MSG_L3, "Skipped, installer already exists\n", script_path); + msg(STASIS_MSG_RESTRICT | STASIS_MSG_L3, "Skipped, installer already exists\n", script_path); } ctx->conda.installer_path = strdup(script_path); @@ -1264,7 +1264,7 @@ int delivery_get_installer(struct Delivery *ctx, char *installer_url) { } int delivery_copy_conda_artifacts(struct Delivery *ctx) { - char cmd[OMC_BUFSIZ]; + char cmd[STASIS_BUFSIZ]; char conda_build_dir[PATH_MAX]; char subdir[PATH_MAX]; memset(cmd, 0, sizeof(cmd)); @@ -1275,7 +1275,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(OMC_MSG_RESTRICT | OMC_MSG_WARN | OMC_MSG_L3, + msg(STASIS_MSG_RESTRICT | STASIS_MSG_WARN | STASIS_MSG_L3, "Skipped: 'conda build' has never been executed.\n"); return 0; } @@ -1393,7 +1393,7 @@ void delivery_install_conda(char *install_script, char *conda_install_dir) { } } } else { - msg(OMC_MSG_L3, "Conda removal disabled by configuration\n"); + msg(STASIS_MSG_L3, "Conda removal disabled by configuration\n"); } } @@ -1405,7 +1405,7 @@ void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir) { // Setting the CONDARC environment variable appears to be the only consistent // way to make sure the file is used. Not setting this variable leads to strange - // behavior, especially if a conda environment is already active when OMC is loaded. + // behavior, especially if a conda environment is already active when STASIS is loaded. char rcpath[PATH_MAX]; sprintf(rcpath, "%s/%s", conda_install_dir, ".condarc"); setenv("CONDARC", rcpath, 1); @@ -1435,7 +1435,7 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { deferred = ctx->conda.pip_packages_defer; strcpy(mode, "pip"); } - msg(OMC_MSG_L2, "Filtering %s packages by test definition...\n", mode); + msg(STASIS_MSG_L2, "Filtering %s packages by test definition...\n", mode); struct StrList *filtered = NULL; filtered = strlist_init(); @@ -1447,7 +1447,7 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { // no data continue; } - msg(OMC_MSG_L3, "package '%s': ", name); + msg(STASIS_MSG_L3, "package '%s': ", name); // Compile a list of packages that are *also* to be tested. char *version; @@ -1479,7 +1479,7 @@ void delivery_defer_packages(struct Delivery *ctx, int type) { } if (!strlist_count(deferred)) { - msg(OMC_MSG_WARN | OMC_MSG_L2, "No %s packages were filtered by test definitions\n", mode); + msg(STASIS_MSG_WARN | STASIS_MSG_L2, "No %s packages were filtered by test definitions\n", mode); } else { if (DEFER_CONDA == type) { strlist_free(&ctx->conda.conda_packages); @@ -1501,7 +1501,7 @@ const char *release_header = "# delivery_name: %s\n" "# conda_build_ident: %s\n"; char *delivery_get_release_header(struct Delivery *ctx) { - char output[OMC_BUFSIZ]; + char output[STASIS_BUFSIZ]; char stamp[100]; strftime(stamp, sizeof(stamp) - 1, "%c", ctx->info.time_info); sprintf(output, release_header, @@ -1516,7 +1516,7 @@ char *delivery_get_release_header(struct Delivery *ctx) { int delivery_dump_metadata(struct Delivery *ctx) { FILE *fp; char filename[PATH_MAX]; - sprintf(filename, "%s/meta-%s.omc", ctx->storage.meta_dir, ctx->info.release_name); + sprintf(filename, "%s/meta-%s.stasis", ctx->storage.meta_dir, ctx->info.release_name); fp = fopen(filename, "w+"); if (!fp) { return -1; @@ -1563,12 +1563,12 @@ void delivery_rewrite_spec(struct Delivery *ctx, char *filename, unsigned stage) if (stage == DELIVERY_REWRITE_SPEC_STAGE_1) { header = delivery_get_release_header(ctx); if (!header) { - msg(OMC_MSG_ERROR, "failed to generate release header string\n", filename); + msg(STASIS_MSG_ERROR, "failed to generate release header string\n", filename); exit(1); } tempfile = xmkstemp(&tp, "w+"); if (!tempfile || !tp) { - msg(OMC_MSG_ERROR, "%s: unable to create temporary file\n", strerror(errno)); + msg(STASIS_MSG_ERROR, "%s: unable to create temporary file\n", strerror(errno)); exit(1); } fprintf(tp, "%s", header); @@ -1576,7 +1576,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(OMC_MSG_ERROR, "%s: unable to read %s", filename); + msg(STASIS_MSG_ERROR, "%s: unable to read %s", filename); exit(1); } @@ -1629,7 +1629,7 @@ void delivery_rewrite_spec(struct Delivery *ctx, char *filename, unsigned stage) sprintf(output, "%s/%s/%s/%s/packages/conda", globals.jfrog.url, globals.jfrog.repo, ctx->meta.mission, ctx->info.build_name); file_replace_text(filename, "@CONDA_CHANNEL@", output, 0); } else { - msg(OMC_MSG_WARN, "conda_staging_url is not configured\n", filename); + msg(STASIS_MSG_WARN, "conda_staging_url is not configured\n", filename); file_replace_text(filename, " - @CONDA_CHANNEL@", "", 0); } @@ -1651,16 +1651,16 @@ void delivery_tests_run(struct Delivery *ctx) { memset(&proc, 0, sizeof(proc)); if (!ctx->tests[0].name) { - msg(OMC_MSG_WARN | OMC_MSG_L2, "no tests are defined!\n"); + msg(STASIS_MSG_WARN | STASIS_MSG_L2, "no tests are defined!\n"); } else { for (size_t i = 0; i < sizeof(ctx->tests) / sizeof(ctx->tests[0]); i++) { if (!ctx->tests[i].name && !ctx->tests[i].repository && !ctx->tests[i].script) { // skip unused test records continue; } - msg(OMC_MSG_L2, "Executing tests for %s %s\n", ctx->tests[i].name, ctx->tests[i].version); + msg(STASIS_MSG_L2, "Executing tests for %s %s\n", ctx->tests[i].name, ctx->tests[i].version); if (!ctx->tests[i].script || !strlen(ctx->tests[i].script)) { - msg(OMC_MSG_WARN | OMC_MSG_L3, "Nothing to do. To fix, declare a 'script' in section: [test:%s]\n", + msg(STASIS_MSG_WARN | STASIS_MSG_L3, "Nothing to do. To fix, declare a 'script' in section: [test:%s]\n", ctx->tests[i].name); continue; } @@ -1669,12 +1669,12 @@ void delivery_tests_run(struct Delivery *ctx) { sprintf(destdir, "%s/%s", ctx->storage.build_sources_dir, path_basename(ctx->tests[i].repository)); if (!access(destdir, F_OK)) { - msg(OMC_MSG_L3, "Purging repository %s\n", destdir); + msg(STASIS_MSG_L3, "Purging repository %s\n", destdir); if (rmtree(destdir)) { COE_CHECK_ABORT(1, "Unable to remove repository\n"); } } - msg(OMC_MSG_L3, "Cloning repository %s\n", ctx->tests[i].repository); + msg(STASIS_MSG_L3, "Cloning repository %s\n", ctx->tests[i].repository); if (!git_clone(&proc, ctx->tests[i].repository, destdir, ctx->tests[i].version)) { ctx->tests[i].repository_info_tag = strdup(git_describe(destdir)); ctx->tests[i].repository_info_ref = strdup(git_rev_parse(destdir, "HEAD")); @@ -1693,14 +1693,14 @@ void delivery_tests_run(struct Delivery *ctx) { int status; char cmd[PATH_MAX]; - msg(OMC_MSG_L3, "Testing %s\n", ctx->tests[i].name); + msg(STASIS_MSG_L3, "Testing %s\n", ctx->tests[i].name); memset(&proc, 0, sizeof(proc)); // Apply workaround for tox positional arguments char *toxconf = NULL; if (!access("tox.ini", F_OK)) { if (!fix_tox_conf("tox.ini", &toxconf)) { - msg(OMC_MSG_L3, "Fixing tox positional arguments\n"); + msg(STASIS_MSG_L3, "Fixing tox positional arguments\n"); if (!globals.workaround.tox_posargs) { globals.workaround.tox_posargs = calloc(PATH_MAX, sizeof(*globals.workaround.tox_posargs)); } else { @@ -1724,7 +1724,7 @@ void delivery_tests_run(struct Delivery *ctx) { status = shell(&proc, cmd); if (status) { - msg(OMC_MSG_ERROR, "Script failure: %s\n%s\n\nExit code: %d\n", ctx->tests[i].name, ctx->tests[i].script, status); + msg(STASIS_MSG_ERROR, "Script failure: %s\n%s\n\nExit code: %d\n", ctx->tests[i].name, ctx->tests[i].script, status); COE_CHECK_ABORT(1, "Test failure"); } @@ -1734,7 +1734,7 @@ void delivery_tests_run(struct Delivery *ctx) { } popd(); #else - msg(OMC_MSG_WARNING | OMC_MSG_L3, "TESTING DISABLED BY CODE!\n"); + msg(STASIS_MSG_WARNING | STASIS_MSG_L3, "TESTING DISABLED BY CODE!\n"); #endif } } @@ -1763,12 +1763,12 @@ int delivery_init_artifactory(struct Delivery *ctx) { if (!access(filepath, F_OK)) { // already have it - msg(OMC_MSG_L3, "Skipped download, %s already exists\n", filepath); + msg(STASIS_MSG_L3, "Skipped download, %s already exists\n", filepath); goto delivery_init_artifactory_envsetup; } char *platform = ctx->system.platform[DELIVERY_PLATFORM]; - msg(OMC_MSG_L3, "Downloading %s for %s %s\n", globals.jfrog.remote_filename, platform, ctx->system.arch); + msg(STASIS_MSG_L3, "Downloading %s for %s %s\n", globals.jfrog.remote_filename, platform, ctx->system.arch); if ((status = artifactory_download_cli(dest, globals.jfrog.jfrog_artifactory_base_url, globals.jfrog.jfrog_artifactory_product, @@ -1809,8 +1809,8 @@ int delivery_artifact_upload(struct Delivery *ctx) { jfrt_upload_init(&ctx->deploy.jfrog[i].upload_ctx); if (!globals.jfrog.repo) { - msg(OMC_MSG_WARN, "Artifactory repository path is not configured!\n"); - fprintf(stderr, "set OMC_JF_REPO environment variable...\nOr append to configuration file:\n\n"); + 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"); status++; break; @@ -1820,7 +1820,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(OMC_MSG_ERROR, "Artifactory repository path is empty. Cannot continue.\n"); + msg(STASIS_MSG_ERROR, "Artifactory repository path is empty. Cannot continue.\n"); status++; break; } @@ -1833,7 +1833,7 @@ int delivery_artifact_upload(struct Delivery *ctx) { char dest[PATH_MAX]; // repo + remote dir if (jfrog_cli_rt_ping(&ctx->deploy.jfrog_auth)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "Unable to contact artifactory server: %s\n", ctx->deploy.jfrog_auth.url); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Unable to contact artifactory server: %s\n", ctx->deploy.jfrog_auth.url); return -1; } @@ -1865,7 +1865,7 @@ int delivery_mission_render_files(struct Delivery *ctx) { char *src; char *dest; } data; - struct INIFILE *cfg = ctx->_omc_ini_fp.mission; + struct INIFILE *cfg = ctx->_stasis_ini_fp.mission; union INIVal val; memset(&data, 0, sizeof(data)); @@ -1886,7 +1886,7 @@ int delivery_mission_render_files(struct Delivery *ctx) { return 1; } sprintf(data.src, "%s/%s/%s", ctx->storage.mission_dir, ctx->meta.mission, val.as_char_p); - msg(OMC_MSG_L2, "%s\n", data.src); + msg(STASIS_MSG_L2, "%s\n", data.src); ini_getval_required(cfg, section_name, "destination", INIVAL_TYPE_STR, &val); conv_str(&data.dest, val); @@ -1924,7 +1924,7 @@ int delivery_mission_render_files(struct Delivery *ctx) { } fclose(fp); - msg(OMC_MSG_L3, "Writing %s\n", data.dest); + msg(STASIS_MSG_L3, "Writing %s\n", data.dest); if (tpl_render_to_file(contents, data.dest)) { guard_free(contents); guard_free(data.dest); @@ -1942,19 +1942,19 @@ int delivery_docker(struct Delivery *ctx) { if (!docker_capable(&ctx->deploy.docker.capabilities)) { return -1; } - char tag[OMC_NAME_MAX]; + char tag[STASIS_NAME_MAX]; char args[PATH_MAX]; int has_registry = ctx->deploy.docker.registry != NULL; size_t total_tags = strlist_count(ctx->deploy.docker.tags); size_t total_build_args = strlist_count(ctx->deploy.docker.build_args); if (!has_registry) { - msg(OMC_MSG_WARN | OMC_MSG_L2, "No docker registry defined. You will need to manually retag the resulting image.\n"); + msg(STASIS_MSG_WARN | STASIS_MSG_L2, "No docker registry defined. You will need to manually retag the resulting image.\n"); } if (!total_tags) { char default_tag[PATH_MAX]; - msg(OMC_MSG_WARN | OMC_MSG_L2, "No docker tags defined by configuration. Generating default tag(s).\n"); + msg(STASIS_MSG_WARN | STASIS_MSG_L2, "No docker tags defined by configuration. Generating default tag(s).\n"); // generate local tag memset(default_tag, 0, sizeof(default_tag)); sprintf(default_tag, "%s:%s-py%s", ctx->meta.name, ctx->info.build_name, ctx->meta.python_compact); @@ -2018,7 +2018,7 @@ int delivery_docker(struct Delivery *ctx) { memset(dest, 0, sizeof(dest)); sprintf(dest, "%s/packages", ctx->storage.build_docker_dir); - msg(OMC_MSG_L2, "Copying conda packages\n"); + msg(STASIS_MSG_L2, "Copying conda packages\n"); memset(rsync_cmd, 0, sizeof(rsync_cmd)); sprintf(rsync_cmd, "rsync -avi --progress '%s' '%s'", ctx->storage.conda_artifact_dir, dest); if (system(rsync_cmd)) { @@ -2026,7 +2026,7 @@ int delivery_docker(struct Delivery *ctx) { return -1; } - msg(OMC_MSG_L2, "Copying wheel packages\n"); + msg(STASIS_MSG_L2, "Copying wheel packages\n"); memset(rsync_cmd, 0, sizeof(rsync_cmd)); sprintf(rsync_cmd, "rsync -avi --progress '%s' '%s'", ctx->storage.wheel_artifact_dir, dest); if (system(rsync_cmd)) { @@ -2043,20 +2043,20 @@ int delivery_docker(struct Delivery *ctx) { strcpy(tag, strlist_item(ctx->deploy.docker.tags, 0)); docker_sanitize_tag(tag); - msg(OMC_MSG_L2, "Executing image test script for %s\n", tag); + 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(OMC_MSG_L2 | OMC_MSG_WARN, "Image test script has no content\n"); + msg(STASIS_MSG_L2 | STASIS_MSG_WARN, "Image test script has no content\n"); } else { int state; if ((state = docker_script(tag, ctx->deploy.docker.test_script, 0))) { - msg(OMC_MSG_L2 | OMC_MSG_ERROR, "Non-zero exit (%d) from test script. %s image archive will not be generated.\n", state >> 8, tag); + 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); // test failed -- don't save the image return -1; } } } else { - msg(OMC_MSG_L2 | OMC_MSG_WARN, "No image test script defined\n"); + msg(STASIS_MSG_L2 | STASIS_MSG_WARN, "No image test script defined\n"); } // Test successful, save image @@ -2089,9 +2089,9 @@ int delivery_fixup_test_results(struct Delivery *ctx) { } sprintf(path, "%s/%s", ctx->storage.results_dir, rec->d_name); - msg(OMC_MSG_L2, "%s\n", rec->d_name); - if (xml_pretty_print_in_place(path, OMC_XML_PRETTY_PRINT_PROG, OMC_XML_PRETTY_PRINT_ARGS)) { - msg(OMC_MSG_L3 | OMC_MSG_WARN, "Failed to rewrite file '%s'\n", rec->d_name); + msg(STASIS_MSG_L2, "%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); } } diff --git a/src/docker.c b/src/docker.c index 308fbc7..da7c1ce 100644 --- a/src/docker.c +++ b/src/docker.c @@ -1,4 +1,4 @@ -#include "omc.h" +#include "core.h" #include "docker.h" @@ -9,11 +9,11 @@ int docker_exec(const char *args, unsigned flags) { memset(&proc, 0, sizeof(proc)); memset(cmd, 0, sizeof(cmd)); snprintf(cmd, sizeof(cmd) - 1, "docker %s", args); - if (flags & OMC_DOCKER_QUIET) { + if (flags & STASIS_DOCKER_QUIET) { strcpy(proc.f_stdout, "/dev/null"); strcpy(proc.f_stderr, "/dev/null"); } else { - msg(OMC_MSG_L2, "Executing: %s\n", cmd); + msg(STASIS_MSG_L2, "Executing: %s\n", cmd); } shell(&proc, cmd); @@ -25,7 +25,7 @@ int docker_script(const char *image, char *data, unsigned flags) { FILE *infile; FILE *outfile; char cmd[PATH_MAX]; - char buffer[OMC_BUFSIZ]; + char buffer[STASIS_BUFSIZ]; memset(cmd, 0, sizeof(cmd)); snprintf(cmd, sizeof(cmd) - 1, "docker run --rm -i %s /bin/sh -", image); @@ -59,10 +59,10 @@ int docker_build(const char *dirpath, const char *args, int engine) { memset(build, 0, sizeof(build)); memset(cmd, 0, sizeof(cmd)); - if (engine & OMC_DOCKER_BUILD) { + if (engine & STASIS_DOCKER_BUILD) { strcpy(build, "build"); } - if (engine & OMC_DOCKER_BUILD_X) { + if (engine & STASIS_DOCKER_BUILD_X) { strcpy(build, "buildx build"); } snprintf(cmd, sizeof(cmd) - 1, "%s %s %s", build, args, dirpath); @@ -149,7 +149,7 @@ int docker_capable(struct DockerCapabilities *result) { } result->available = true; - if (docker_exec("ps", OMC_DOCKER_QUIET)) { + if (docker_exec("ps", STASIS_DOCKER_QUIET)) { // user cannot connect to the socket return false; } @@ -160,11 +160,11 @@ int docker_capable(struct DockerCapabilities *result) { } guard_free(version); - if (!docker_exec("buildx build --help", OMC_DOCKER_QUIET)) { - result->build |= OMC_DOCKER_BUILD_X; + if (!docker_exec("buildx build --help", STASIS_DOCKER_QUIET)) { + result->build |= STASIS_DOCKER_BUILD_X; } - if (!docker_exec("build --help", OMC_DOCKER_QUIET)) { - result->build |= OMC_DOCKER_BUILD; + if (!docker_exec("build --help", STASIS_DOCKER_QUIET)) { + result->build |= STASIS_DOCKER_BUILD; } if (!result->build) { // can't use docker without a build plugin diff --git a/src/download.c b/src/download.c index cbb617f..1623560 100644 --- a/src/download.c +++ b/src/download.c @@ -17,7 +17,7 @@ long download(char *url, const char *filename, char **errmsg) { long http_code = -1; FILE *fp; char user_agent[20]; - sprintf(user_agent, "omc/%s", VERSION); + sprintf(user_agent, "stasis/%s", VERSION); curl_global_init(CURL_GLOBAL_ALL); c = curl_easy_init(); diff --git a/src/environment.c b/src/environment.c index 824b447..924fbf8 100644 --- a/src/environment.c +++ b/src/environment.c @@ -70,7 +70,7 @@ void runtime_export(RuntimeEnv *env, char **keys) { NULL, }; - char output[OMC_BUFSIZ]; + char output[STASIS_BUFSIZ]; char export_command[7]; // export=6 and setenv=6... convenient char *_sh = getenv("SHELL"); char *sh = path_basename(_sh); @@ -290,9 +290,9 @@ char *runtime_expand_var(RuntimeEnv *env, char *input) { return input; } - expanded = calloc(OMC_BUFSIZ, sizeof(char)); + expanded = calloc(STASIS_BUFSIZ, sizeof(char)); if (expanded == NULL) { - SYSERROR("could not allocate %d bytes for runtime_expand_var buffer", OMC_BUFSIZ); + SYSERROR("could not allocate %d bytes for runtime_expand_var buffer", STASIS_BUFSIZ); return NULL; } diff --git a/src/globals.c b/src/globals.c index 27c8aff..7ed7c3c 100644 --- a/src/globals.c +++ b/src/globals.c @@ -1,29 +1,30 @@ #include <stdlib.h> #include <stdbool.h> -#include "omc.h" +#include "core.h" const char *VERSION = "1.0.0"; const char *AUTHOR = "Joseph Hunkeler"; const char *BANNER = - "---------------------------------------------------------------------\n" -#if defined(OMC_DUMB_TERMINAL) - " OH MY CAL \n" + "------------------------------------------------------------------------\n" +#if defined(STASIS_DUMB_TERMINAL) + " STASIS \n" #else - " ██████╗ ██╗ ██╗ ███╗ ███╗██╗ ██╗ ██████╗ █████╗ ██╗ \n" - "██╔═══██╗██║ ██║ ████╗ ████║╚██╗ ██╔╝ ██╔════╝██╔══██╗██║ \n" - "██║ ██║███████║ ██╔████╔██║ ╚████╔╝ ██║ ███████║██║ \n" - "██║ ██║██╔══██║ ██║╚██╔╝██║ ╚██╔╝ ██║ ██╔══██║██║ \n" - "╚██████╔╝██║ ██║ ██║ ╚═╝ ██║ ██║ ╚██████╗██║ ██║███████╗\n" - " ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝\n" + " _____ _______ _____ _____ _____ \n" + " / ____|__ __|/\\ / ____|_ _|/ ____| \n" + " | (___ | | / \\ | (___ | | | (___ \n" + " \\___ \\ | | / /\\ \\ \\___ \\ | | \\___ \\ \n" + " ____) | | |/ ____ \\ ____) |_| |_ ____) | \n" + " |_____/ |_/_/ \\_\\_____/|_____|_____/ \n" + "\n" #endif - "---------------------------------------------------------------------\n" - " Delivery Generator \n" - " v%s \n" - "---------------------------------------------------------------------\n" + "------------------------------------------------------------------------\n" + " Delivery Generator \n" + " v%s \n" + "------------------------------------------------------------------------\n" "Copyright (C) 2023-2024 %s,\n" "Association of Universities for Research in Astronomy (AURA)\n"; -struct OMC_GLOBAL globals = { +struct STASIS_GLOBAL globals = { .verbose = false, .continue_on_error = false, .always_update_base_environment = false, @@ -2,7 +2,7 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> -#include "omc.h" +#include "core.h" #include "ini.h" struct INIFILE *ini_init() { @@ -114,7 +114,7 @@ struct INIData *ini_getall(struct INIFILE *ini, char *section_name) { int ini_getval(struct INIFILE *ini, char *section_name, char *key, int type, union INIVal *result) { char *token = NULL; - char tbuf[OMC_BUFSIZ]; + char tbuf[STASIS_BUFSIZ]; char *tbufp = tbuf; struct INIData *data; data = ini_data_get(ini, section_name, key); @@ -282,7 +282,7 @@ int ini_write(struct INIFILE *ini, FILE **stream, unsigned mode) { for (size_t x = 0; x < ini->section_count; x++) { fprintf(*stream, "[%s]" LINE_SEP, ini->section[x]->key); for (size_t y = 0; y < ini->section[x]->data_count; y++) { - char outvalue[OMC_BUFSIZ]; + char outvalue[STASIS_BUFSIZ]; memset(outvalue, 0, sizeof(outvalue)); if (ini->section[x]->data[y]->value) { char **parts = split(ini->section[x]->data[y]->value, LINE_SEP, 0); @@ -354,8 +354,8 @@ void ini_free(struct INIFILE **ini) { struct INIFILE *ini_open(const char *filename) { FILE *fp; - char line[OMC_BUFSIZ] = {0}; - char current_section[OMC_BUFSIZ] = {0}; + char line[STASIS_BUFSIZ] = {0}; + char current_section[STASIS_BUFSIZ] = {0}; char reading_value = 0; struct INIFILE *ini = ini_init(); @@ -382,7 +382,7 @@ struct INIFILE *ini_open(const char *filename) { char inikey[2][255]; char *key = inikey[0]; char *key_last = inikey[1]; - char value[OMC_BUFSIZ]; + char value[STASIS_BUFSIZ]; memset(value, 0, sizeof(value)); memset(inikey, 0, sizeof(inikey)); diff --git a/src/recipe.c b/src/recipe.c index 43899b8..e51fde6 100644 --- a/src/recipe.c +++ b/src/recipe.c @@ -20,7 +20,7 @@ int recipe_clone(char *recipe_dir, char *url, char *gitref, char **result) { if (!access(destdir, F_OK)) { if (!strcmp(destdir, "/")) { - fprintf(stderr, "OMC is misconfigured. Please check your output path(s) immediately.\n"); + fprintf(stderr, "STASIS is misconfigured. Please check your output path(s) immediately.\n"); fprintf(stderr, "recipe_dir = '%s'\nreponame = '%s'\ndestdir = '%s'\n", recipe_dir, reponame, destdir); exit(1); diff --git a/src/relocation.c b/src/relocation.c index 586d1ba..a86530d 100644 --- a/src/relocation.c +++ b/src/relocation.c @@ -24,7 +24,7 @@ * @return 0 on success, -1 on error */ int replace_text(char *original, const char *target, const char *replacement, unsigned flags) { - char buffer[OMC_BUFSIZ]; + char buffer[STASIS_BUFSIZ]; char *pos = original; char *match = NULL; size_t original_len = strlen(original); @@ -104,7 +104,7 @@ int replace_text(char *original, const char *target, const char *replacement, un */ int file_replace_text(const char* filename, const char* target, const char* replacement, unsigned flags) { int result; - char buffer[OMC_BUFSIZ]; + char buffer[STASIS_BUFSIZ]; char tempfilename[] = "tempfileXXXXXX"; FILE *fp; FILE *tfp; diff --git a/src/omc_indexer.c b/src/stasis_indexer.c index 971f389..fb231e0 100644 --- a/src/omc_indexer.c +++ b/src/stasis_indexer.c @@ -1,6 +1,6 @@ #include <getopt.h> #include <fnmatch.h> -#include "omc.h" +#include "core.h" static struct option long_options[] = { {"help", no_argument, 0, 'h'}, @@ -26,7 +26,7 @@ static void usage(char *name) { for (int i = 0; i < maxopts; i++) { opts[i] = long_options[i].val; } - printf("usage: %s [-%s] {{OMC_ROOT}...}\n", name, opts); + printf("usage: %s [-%s] {{STASIS_ROOT}...}\n", name, opts); guard_free(opts); for (int i = 0; i < maxopts - 1; i++) { @@ -62,7 +62,7 @@ int indexer_wheels(struct Delivery *ctx) { } int indexer_load_metadata(struct Delivery *ctx, const char *filename) { - char line[OMC_NAME_MAX] = {0}; + char line[STASIS_NAME_MAX] = {0}; FILE *fp; fp = fopen(filename, "r"); @@ -229,7 +229,7 @@ int micromamba(const char *write_to, const char *prefix, char *command, ...) { system(untarcmd); } - char cmd[OMC_BUFSIZ]; + char cmd[STASIS_BUFSIZ]; memset(cmd, 0, sizeof(cmd)); sprintf(cmd, "%s -r %s -p %s ", mmbin, prefix, prefix); va_list args; @@ -615,7 +615,7 @@ int main(int argc, char *argv[]) { } if (!rootdirs || !rootdirs_total) { - fprintf(stderr, "You must specify at least one OMC root directory to index\n"); + fprintf(stderr, "You must specify at least one STASIS root directory to index\n"); exit(1); } else { for (size_t i = 0; i < rootdirs_total; i++) { @@ -634,7 +634,7 @@ int main(int argc, char *argv[]) { } else { strcat(workdir_template, "/tmp"); } - strcat(workdir_template, "/omc-combine.XXXXXX"); + strcat(workdir_template, "/stasis-combine.XXXXXX"); workdir = mkdtemp(workdir_template); if (!workdir) { SYSERROR("Unable to create temporary directory: %s", workdir_template); @@ -651,7 +651,7 @@ int main(int argc, char *argv[]) { indexer_init_dirs(&ctx, workdir); - msg(OMC_MSG_L1, "%s delivery root %s\n", + msg(STASIS_MSG_L1, "%s delivery root %s\n", rootdirs_total > 1 ? "Merging" : "Indexing", rootdirs_total > 1 ? "directories" : "directory"); if (indexer_combine_rootdirs(workdir, rootdirs, rootdirs_total)) { @@ -668,22 +668,22 @@ int main(int argc, char *argv[]) { mkdirs(ctx.storage.wheel_artifact_dir, 0755); } - msg(OMC_MSG_L1, "Indexing conda packages\n"); + msg(STASIS_MSG_L1, "Indexing conda packages\n"); if (indexer_conda(&ctx)) { SYSERROR("%s", "Conda package indexing operation failed"); exit(1); } - msg(OMC_MSG_L1, "Indexing wheel packages\n"); + msg(STASIS_MSG_L1, "Indexing wheel packages\n"); if (indexer_wheels(&ctx)) { SYSERROR("%s", "Python package indexing operation failed"); exit(1); } - msg(OMC_MSG_L1, "Loading metadata\n"); + msg(STASIS_MSG_L1, "Loading metadata\n"); struct StrList *metafiles = NULL; - indexer_get_files(&metafiles, ctx.storage.meta_dir, "*.omc"); - strlist_sort(metafiles, OMC_SORT_LEN_ASCENDING); + indexer_get_files(&metafiles, ctx.storage.meta_dir, "*.stasis"); + strlist_sort(metafiles, STASIS_SORT_LEN_ASCENDING); struct Delivery local[strlist_count(metafiles)]; for (size_t i = 0; i < strlist_count(metafiles); i++) { @@ -698,33 +698,33 @@ int main(int argc, char *argv[]) { indexer_load_metadata(&local[i], path); } - msg(OMC_MSG_L1, "Generating links to latest release iteration\n"); + msg(STASIS_MSG_L1, "Generating links to latest release iteration\n"); if (indexer_symlinks(local, strlist_count(metafiles))) { SYSERROR("%s", "Link generation failed"); exit(1); } - msg(OMC_MSG_L1, "Generating README.md\n"); + msg(STASIS_MSG_L1, "Generating README.md\n"); if (indexer_readmes(local, strlist_count(metafiles))) { SYSERROR("%s", "README indexing operation failed"); exit(1); } - msg(OMC_MSG_L1, "Indexing test results\n"); + msg(STASIS_MSG_L1, "Indexing test results\n"); if (indexer_junitxml_report(local, strlist_count(metafiles))) { SYSERROR("%s", "Test result indexing operation failed"); exit(1); } if (do_html) { - msg(OMC_MSG_L1, "Generating HTML indexes\n"); + msg(STASIS_MSG_L1, "Generating HTML indexes\n"); if (indexer_make_website(local)) { SYSERROR("%s", "Site creation failed"); exit(1); } } - msg(OMC_MSG_L1, "Copying indexed delivery to '%s'\n", destdir); + msg(STASIS_MSG_L1, "Copying indexed delivery to '%s'\n", destdir); char cmd[PATH_MAX]; memset(cmd, 0, sizeof(cmd)); sprintf(cmd, "rsync -ah%s --delete --exclude 'tmp/' --exclude 'tools/' '%s/' '%s/'", globals.verbose ? "v" : "q", workdir, destdir); @@ -740,7 +740,7 @@ int main(int argc, char *argv[]) { exit(1); } - msg(OMC_MSG_L1, "Removing work directory: %s\n", workdir); + msg(STASIS_MSG_L1, "Removing work directory: %s\n", workdir); if (rmtree(workdir)) { SYSERROR("Failed to remove work directory: %s", strerror(errno)); } @@ -748,6 +748,6 @@ int main(int argc, char *argv[]) { guard_strlist_free(&metafiles); delivery_free(&ctx); globals_free(); - msg(OMC_MSG_L1, "Done!\n"); + msg(STASIS_MSG_L1, "Done!\n"); return 0; } diff --git a/src/omc_main.c b/src/stasis_main.c index 90460ee..8b13b98 100644 --- a/src/omc_main.c +++ b/src/stasis_main.c @@ -3,7 +3,7 @@ #include <string.h> #include <limits.h> #include <getopt.h> -#include "omc.h" +#include "core.h" #define OPT_ALWAYS_UPDATE_BASE 1000 #define OPT_NO_DOCKER 1001 @@ -32,7 +32,7 @@ const char *long_options_help[] = { "Override version of Python in configuration", "Increase output verbosity", "Disable line buffering", - "Update conda installation prior to OMC environment creation", + "Update conda installation prior to STASIS environment creation", "Do not build docker images", "Do not upload artifacts to Artifactory", "Do not execute test scripts", @@ -68,7 +68,7 @@ static void usage(char *progname) { int width = get_option_max_width(long_options); for (int x = 0; long_options[x].name != 0; x++) { - char tmp[OMC_NAME_MAX] = {0}; + char tmp[STASIS_NAME_MAX] = {0}; char output[sizeof(tmp)] = {0}; char opt_long[50] = {0}; // --? [ARG]? char opt_short[50] = {0}; // -? [ARG]? @@ -103,10 +103,10 @@ static void check_system_requirements(struct Delivery *ctx) { NULL, }; - msg(OMC_MSG_L1, "Checking system requirements\n"); + msg(STASIS_MSG_L1, "Checking system requirements\n"); for (size_t i = 0; tools_required[i] != NULL; i++) { if (!find_program(tools_required[i])) { - msg(OMC_MSG_L2 | OMC_MSG_ERROR, "'%s' must be installed.\n", tools_required[i]); + msg(STASIS_MSG_L2 | STASIS_MSG_ERROR, "'%s' must be installed.\n", tools_required[i]); exit(1); } } @@ -117,16 +117,16 @@ static void check_system_requirements(struct Delivery *ctx) { struct DockerCapabilities dcap; if (!docker_capable(&dcap)) { - msg(OMC_MSG_L2 | OMC_MSG_WARN, "Docker is broken\n"); - msg(OMC_MSG_L3, "Available: %s\n", dcap.available ? "Yes" : "No"); - msg(OMC_MSG_L3, "Usable: %s\n", dcap.usable ? "Yes" : "No"); - msg(OMC_MSG_L3, "Podman [Docker Emulation]: %s\n", dcap.podman ? "Yes" : "No"); - msg(OMC_MSG_L3, "Build plugin(s): "); + msg(STASIS_MSG_L2 | STASIS_MSG_WARN, "Docker is broken\n"); + msg(STASIS_MSG_L3, "Available: %s\n", dcap.available ? "Yes" : "No"); + msg(STASIS_MSG_L3, "Usable: %s\n", dcap.usable ? "Yes" : "No"); + msg(STASIS_MSG_L3, "Podman [Docker Emulation]: %s\n", dcap.podman ? "Yes" : "No"); + msg(STASIS_MSG_L3, "Build plugin(s): "); if (dcap.usable) { - if (dcap.build & OMC_DOCKER_BUILD) { + if (dcap.build & STASIS_DOCKER_BUILD) { printf("build "); } - if (dcap.build & OMC_DOCKER_BUILD_X) { + if (dcap.build & STASIS_DOCKER_BUILD_X) { printf("buildx "); } puts(""); @@ -146,12 +146,12 @@ int main(int argc, char *argv[]) { .f_stderr = "", .redirect_stderr = 0, }; - char env_name[OMC_NAME_MAX] = {0}; - char env_name_testing[OMC_NAME_MAX] = {0}; + char env_name[STASIS_NAME_MAX] = {0}; + char env_name_testing[STASIS_NAME_MAX] = {0}; char *delivery_input = NULL; char *config_input = NULL; char installer_url[PATH_MAX]; - char python_override_version[OMC_NAME_MAX]; + char python_override_version[STASIS_NAME_MAX]; int user_disabled_docker = false; memset(env_name, 0, sizeof(env_name)); @@ -225,7 +225,7 @@ int main(int argc, char *argv[]) { printf(BANNER, VERSION, AUTHOR); - msg(OMC_MSG_L1, "Setup\n"); + msg(STASIS_MSG_L1, "Setup\n"); // Expose variables for use with the template engine // NOTE: These pointers are populated by delivery_init() so please avoid using @@ -259,18 +259,18 @@ int main(int argc, char *argv[]) { tpl_register("workaround.tox_posargs", &globals.workaround.tox_posargs); // Set up PREFIX/etc directory information - // The user may manipulate the base directory path with OMC_SYSCONFDIR + // The user may manipulate the base directory path with STASIS_SYSCONFDIR // environment variable - char omc_sysconfdir_tmp[PATH_MAX]; - if (getenv("OMC_SYSCONFDIR")) { - strncpy(omc_sysconfdir_tmp, getenv("OMC_SYSCONFDIR"), sizeof(omc_sysconfdir_tmp) - 1); + char stasis_sysconfdir_tmp[PATH_MAX]; + if (getenv("STASIS_SYSCONFDIR")) { + strncpy(stasis_sysconfdir_tmp, getenv("STASIS_SYSCONFDIR"), sizeof(stasis_sysconfdir_tmp) - 1); } else { - strncpy(omc_sysconfdir_tmp, OMC_SYSCONFDIR, sizeof(omc_sysconfdir_tmp) - 1); + strncpy(stasis_sysconfdir_tmp, STASIS_SYSCONFDIR, sizeof(stasis_sysconfdir_tmp) - 1); } - globals.sysconfdir = realpath(omc_sysconfdir_tmp, NULL); + globals.sysconfdir = realpath(stasis_sysconfdir_tmp, NULL); if (!globals.sysconfdir) { - msg(OMC_MSG_ERROR | OMC_MSG_L1, "Unable to resolve path to configuration directory: %s\n", omc_sysconfdir_tmp); + msg(STASIS_MSG_ERROR | STASIS_MSG_L1, "Unable to resolve path to configuration directory: %s\n", stasis_sysconfdir_tmp); exit(1); } @@ -285,49 +285,49 @@ int main(int argc, char *argv[]) { if (!config_input) { // no configuration passed by argument. use basic config. char cfgfile[PATH_MAX * 2]; - sprintf(cfgfile, "%s/%s", globals.sysconfdir, "omc.ini"); + sprintf(cfgfile, "%s/%s", globals.sysconfdir, "stasis.ini"); if (!access(cfgfile, F_OK | R_OK)) { config_input = strdup(cfgfile); } else { - msg(OMC_MSG_WARN, "OMC global configuration is not readable, or does not exist: %s", cfgfile); + msg(STASIS_MSG_WARN, "STASIS global configuration is not readable, or does not exist: %s", cfgfile); } } if (config_input) { - msg(OMC_MSG_L2, "Reading OMC global configuration: %s\n", config_input); - ctx._omc_ini_fp.cfg = ini_open(config_input); - if (!ctx._omc_ini_fp.cfg) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "Failed to read config file: %s, %s\n", delivery_input, strerror(errno)); + msg(STASIS_MSG_L2, "Reading STASIS global configuration: %s\n", config_input); + ctx._stasis_ini_fp.cfg = ini_open(config_input); + if (!ctx._stasis_ini_fp.cfg) { + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Failed to read config file: %s, %s\n", delivery_input, strerror(errno)); exit(1); } - ctx._omc_ini_fp.cfg_path = strdup(config_input); + ctx._stasis_ini_fp.cfg_path = strdup(config_input); guard_free(config_input); } - msg(OMC_MSG_L2, "Reading OMC delivery configuration: %s\n", delivery_input); - ctx._omc_ini_fp.delivery = ini_open(delivery_input); - if (!ctx._omc_ini_fp.delivery) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "Failed to read delivery file: %s, %s\n", delivery_input, strerror(errno)); + msg(STASIS_MSG_L2, "Reading STASIS delivery configuration: %s\n", delivery_input); + ctx._stasis_ini_fp.delivery = ini_open(delivery_input); + if (!ctx._stasis_ini_fp.delivery) { + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Failed to read delivery file: %s, %s\n", delivery_input, strerror(errno)); exit(1); } - ctx._omc_ini_fp.delivery_path = strdup(delivery_input); + ctx._stasis_ini_fp.delivery_path = strdup(delivery_input); - msg(OMC_MSG_L2, "Bootstrapping delivery context\n"); + msg(STASIS_MSG_L2, "Bootstrapping delivery context\n"); if (bootstrap_build_info(&ctx)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "Failed to bootstrap delivery context\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Failed to bootstrap delivery context\n"); exit(1); } - msg(OMC_MSG_L2, "Initializing delivery context\n"); + msg(STASIS_MSG_L2, "Initializing delivery context\n"); if (delivery_init(&ctx)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "Failed to initialize delivery context\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Failed to initialize delivery context\n"); exit(1); } check_system_requirements(&ctx); - msg(OMC_MSG_L2, "Configuring JFrog CLI\n"); + msg(STASIS_MSG_L2, "Configuring JFrog CLI\n"); if (delivery_init_artifactory(&ctx)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "JFrog CLI configuration failed\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "JFrog CLI configuration failed\n"); exit(1); } @@ -336,7 +336,7 @@ int main(int argc, char *argv[]) { strcpy(env_name_testing, env_name); strcat(env_name_testing, "-test"); - msg(OMC_MSG_L1, "Overview\n"); + msg(STASIS_MSG_L1, "Overview\n"); delivery_meta_show(&ctx); delivery_conda_show(&ctx); delivery_tests_show(&ctx); @@ -344,11 +344,11 @@ int main(int argc, char *argv[]) { //delivery_runtime_show(&ctx); } - msg(OMC_MSG_L1, "Conda setup\n"); + msg(STASIS_MSG_L1, "Conda setup\n"); delivery_get_installer_url(&ctx, installer_url); - msg(OMC_MSG_L2, "Downloading: %s\n", installer_url); + msg(STASIS_MSG_L2, "Downloading: %s\n", installer_url); if (delivery_get_installer(&ctx, installer_url)) { - msg(OMC_MSG_ERROR, "download failed: %s\n", installer_url); + msg(STASIS_MSG_ERROR, "download failed: %s\n", installer_url); exit(1); } @@ -360,57 +360,57 @@ int main(int argc, char *argv[]) { exit(1); } - msg(OMC_MSG_L2, "Installing: %s\n", ctx.conda.installer_name); + msg(STASIS_MSG_L2, "Installing: %s\n", ctx.conda.installer_name); delivery_install_conda(ctx.conda.installer_path, ctx.storage.conda_install_prefix); - msg(OMC_MSG_L2, "Configuring: %s\n", ctx.storage.conda_install_prefix); + msg(STASIS_MSG_L2, "Configuring: %s\n", ctx.storage.conda_install_prefix); delivery_conda_enable(&ctx, ctx.storage.conda_install_prefix); char *pathvar = NULL; pathvar = getenv("PATH"); if (!pathvar) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "PATH variable is not set. Cannot continue.\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "PATH variable is not set. Cannot continue.\n"); exit(1); } else { - char pathvar_tmp[OMC_BUFSIZ]; + char pathvar_tmp[STASIS_BUFSIZ]; sprintf(pathvar_tmp, "%s/bin:%s", ctx.storage.conda_install_prefix, pathvar); setenv("PATH", pathvar_tmp, 1); pathvar = NULL; } - msg(OMC_MSG_L1, "Creating release environment(s)\n"); + msg(STASIS_MSG_L1, "Creating release environment(s)\n"); if (ctx.meta.based_on && strlen(ctx.meta.based_on)) { if (conda_env_remove(env_name)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "failed to remove release environment: %s\n", env_name_testing); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed to remove release environment: %s\n", env_name_testing); exit(1); } - msg(OMC_MSG_L2, "Based on release: %s\n", ctx.meta.based_on); + msg(STASIS_MSG_L2, "Based on release: %s\n", ctx.meta.based_on); if (conda_env_create_from_uri(env_name, ctx.meta.based_on)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "unable to install release environment using configuration file\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "unable to install release environment using configuration file\n"); exit(1); } if (conda_env_remove(env_name_testing)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "failed to remove testing environment\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed to remove testing environment\n"); exit(1); } if (conda_env_create_from_uri(env_name_testing, ctx.meta.based_on)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "unable to install testing environment using configuration file\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "unable to install testing environment using configuration file\n"); exit(1); } } else { if (conda_env_create(env_name, ctx.meta.python, NULL)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "failed to create release environment\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed to create release environment\n"); exit(1); } if (conda_env_create(env_name_testing, ctx.meta.python, NULL)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "failed to create release environment\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed to create release environment\n"); exit(1); } } // Activate test environment - msg(OMC_MSG_L1, "Activating test environment\n"); + msg(STASIS_MSG_L1, "Activating test environment\n"); if (conda_activate(ctx.storage.conda_install_prefix, env_name_testing)) { fprintf(stderr, "failed to activate test environment\n"); exit(1); @@ -418,44 +418,44 @@ int main(int argc, char *argv[]) { delivery_gather_tool_versions(&ctx); if (!ctx.conda.tool_version) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "Could not determine conda version\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Could not determine conda version\n"); exit(1); } if (!ctx.conda.tool_build_version) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "Could not determine conda-build version\n"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Could not determine conda-build version\n"); exit(1); } if (pip_exec("install build")) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "'build' tool installation failed"); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "'build' tool installation failed"); exit(1); } // Execute configuration-defined tests if (globals.enable_testing) { - msg(OMC_MSG_L1, "Begin test execution\n"); + msg(STASIS_MSG_L1, "Begin test execution\n"); delivery_tests_run(&ctx); - msg(OMC_MSG_L1, "Rewriting test results\n"); + msg(STASIS_MSG_L1, "Rewriting test results\n"); delivery_fixup_test_results(&ctx); } else { - msg(OMC_MSG_L1 | OMC_MSG_WARN, "Test execution is disabled\n"); + msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Test execution is disabled\n"); } - msg(OMC_MSG_L1, "Generating deferred package listing\n"); + msg(STASIS_MSG_L1, "Generating deferred package listing\n"); // Test succeeded so move on to producing package artifacts delivery_defer_packages(&ctx, DEFER_CONDA); delivery_defer_packages(&ctx, DEFER_PIP); if (ctx.conda.conda_packages_defer && strlist_count(ctx.conda.conda_packages_defer)) { - msg(OMC_MSG_L2, "Building Conda recipe(s)\n"); + msg(STASIS_MSG_L2, "Building Conda recipe(s)\n"); if (delivery_build_recipes(&ctx)) { exit(1); } - msg(OMC_MSG_L3, "Copying artifacts\n"); + msg(STASIS_MSG_L3, "Copying artifacts\n"); if (delivery_copy_conda_artifacts(&ctx)) { exit(1); } - msg(OMC_MSG_L3, "Indexing artifacts\n"); + msg(STASIS_MSG_L3, "Indexing artifacts\n"); if (delivery_index_conda_artifacts(&ctx)) { exit(1); } @@ -472,23 +472,23 @@ int main(int argc, char *argv[]) { } // Populate the release environment - msg(OMC_MSG_L1, "Populating release environment\n"); - msg(OMC_MSG_L2, "Installing conda packages\n"); + msg(STASIS_MSG_L1, "Populating release environment\n"); + msg(STASIS_MSG_L2, "Installing conda packages\n"); if (strlist_count(ctx.conda.conda_packages)) { if (delivery_install_packages(&ctx, ctx.storage.conda_install_prefix, env_name, INSTALL_PKG_CONDA, (struct StrList *[]) {ctx.conda.conda_packages, NULL})) { exit(1); } } if (strlist_count(ctx.conda.conda_packages_defer)) { - msg(OMC_MSG_L3, "Installing deferred conda packages\n"); + msg(STASIS_MSG_L3, "Installing deferred conda packages\n"); if (delivery_install_packages(&ctx, ctx.storage.conda_install_prefix, env_name, INSTALL_PKG_CONDA | INSTALL_PKG_CONDA_DEFERRED, (struct StrList *[]) {ctx.conda.conda_packages_defer, NULL})) { exit(1); } } else { - msg(OMC_MSG_L3, "No deferred conda packages\n"); + msg(STASIS_MSG_L3, "No deferred conda packages\n"); } - msg(OMC_MSG_L2, "Installing pip packages\n"); + msg(STASIS_MSG_L2, "Installing pip packages\n"); if (strlist_count(ctx.conda.pip_packages)) { if (delivery_install_packages(&ctx, ctx.storage.conda_install_prefix, env_name, INSTALL_PKG_PIP, (struct StrList *[]) {ctx.conda.pip_packages, NULL})) { exit(1); @@ -496,37 +496,37 @@ int main(int argc, char *argv[]) { } if (strlist_count(ctx.conda.pip_packages_defer)) { - msg(OMC_MSG_L3, "Installing deferred pip packages\n"); + msg(STASIS_MSG_L3, "Installing deferred pip packages\n"); if (delivery_install_packages(&ctx, ctx.storage.conda_install_prefix, env_name, INSTALL_PKG_PIP | INSTALL_PKG_PIP_DEFERRED, (struct StrList *[]) {ctx.conda.pip_packages_defer, NULL})) { exit(1); } } else { - msg(OMC_MSG_L3, "No deferred pip packages\n"); + msg(STASIS_MSG_L3, "No deferred pip packages\n"); } conda_exec("list"); - msg(OMC_MSG_L1, "Creating release\n"); - msg(OMC_MSG_L2, "Exporting delivery configuration\n"); + msg(STASIS_MSG_L1, "Creating release\n"); + msg(STASIS_MSG_L2, "Exporting delivery configuration\n"); if (!pushd(ctx.storage.cfgdump_dir)) { char filename[PATH_MAX] = {0}; sprintf(filename, "%s.ini", ctx.info.release_name); FILE *spec = fopen(filename, "w+"); if (!spec) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "failed %s\n", filename); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed %s\n", filename); exit(1); } - ini_write(ctx._omc_ini_fp.delivery, &spec, INI_WRITE_RAW); + ini_write(ctx._stasis_ini_fp.delivery, &spec, INI_WRITE_RAW); fclose(spec); memset(filename, 0, sizeof(filename)); sprintf(filename, "%s-rendered.ini", ctx.info.release_name); spec = fopen(filename, "w+"); if (!spec) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "failed %s\n", filename); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed %s\n", filename); exit(1); } - ini_write(ctx._omc_ini_fp.delivery, &spec, INI_WRITE_PRESERVE); + ini_write(ctx._stasis_ini_fp.delivery, &spec, INI_WRITE_PRESERVE); fclose(spec); popd(); } else { @@ -534,79 +534,79 @@ int main(int argc, char *argv[]) { exit(1); } - msg(OMC_MSG_L2, "Exporting %s\n", env_name_testing); + msg(STASIS_MSG_L2, "Exporting %s\n", env_name_testing); if (conda_env_export(env_name_testing, ctx.storage.delivery_dir, env_name_testing)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "failed %s\n", env_name_testing); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed %s\n", env_name_testing); exit(1); } - msg(OMC_MSG_L2, "Exporting %s\n", env_name); + msg(STASIS_MSG_L2, "Exporting %s\n", env_name); if (conda_env_export(env_name, ctx.storage.delivery_dir, env_name)) { - msg(OMC_MSG_ERROR | OMC_MSG_L2, "failed %s\n", env_name); + msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed %s\n", env_name); exit(1); } // Rewrite release environment output (i.e. set package origin(s) to point to the deployment server, etc.) char specfile[PATH_MAX]; sprintf(specfile, "%s/%s.yml", ctx.storage.delivery_dir, env_name); - msg(OMC_MSG_L3, "Rewriting release spec file (stage 1): %s\n", path_basename(specfile)); + msg(STASIS_MSG_L3, "Rewriting release spec file (stage 1): %s\n", path_basename(specfile)); delivery_rewrite_spec(&ctx, specfile, DELIVERY_REWRITE_SPEC_STAGE_1); - msg(OMC_MSG_L1, "Rendering mission templates\n"); + msg(STASIS_MSG_L1, "Rendering mission templates\n"); delivery_mission_render_files(&ctx); - int want_docker = ini_section_search(&ctx._omc_ini_fp.delivery, INI_SEARCH_BEGINS, "deploy:docker") ? true : false; - int want_artifactory = ini_section_search(&ctx._omc_ini_fp.delivery, INI_SEARCH_BEGINS, "deploy:artifactory") ? true : false; + int want_docker = ini_section_search(&ctx._stasis_ini_fp.delivery, INI_SEARCH_BEGINS, "deploy:docker") ? true : false; + int want_artifactory = ini_section_search(&ctx._stasis_ini_fp.delivery, INI_SEARCH_BEGINS, "deploy:artifactory") ? true : false; if (want_docker) { if (user_disabled_docker) { - msg(OMC_MSG_L1 | OMC_MSG_WARN, "Docker image building is disabled by CLI argument\n"); + msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Docker image building is disabled by CLI argument\n"); } else { char dockerfile[PATH_MAX] = {0}; sprintf(dockerfile, "%s/%s", ctx.storage.build_docker_dir, "Dockerfile"); if (globals.enable_docker) { if (!access(dockerfile, F_OK)) { - msg(OMC_MSG_L1, "Building Docker image\n"); + msg(STASIS_MSG_L1, "Building Docker image\n"); if (delivery_docker(&ctx)) { - msg(OMC_MSG_L1 | OMC_MSG_ERROR, "Failed to build docker image!\n"); + msg(STASIS_MSG_L1 | STASIS_MSG_ERROR, "Failed to build docker image!\n"); COE_CHECK_ABORT(1, "Failed to build docker image"); } } else { - msg(OMC_MSG_L1 | OMC_MSG_WARN, "Docker image building is disabled. No Dockerfile found in %s\n", ctx.storage.build_docker_dir); + msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Docker image building is disabled. No Dockerfile found in %s\n", ctx.storage.build_docker_dir); } } else { - msg(OMC_MSG_L1 | OMC_MSG_WARN, "Docker image building is disabled. System configuration error\n"); + msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Docker image building is disabled. System configuration error\n"); } } } else { - msg(OMC_MSG_L1 | OMC_MSG_WARN, "Docker image building is disabled. deploy:docker is not configured\n"); + msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Docker image building is disabled. deploy:docker is not configured\n"); } - msg(OMC_MSG_L3, "Rewriting release spec file (stage 2): %s\n", path_basename(specfile)); + msg(STASIS_MSG_L3, "Rewriting release spec file (stage 2): %s\n", path_basename(specfile)); delivery_rewrite_spec(&ctx, specfile, DELIVERY_REWRITE_SPEC_STAGE_2); - msg(OMC_MSG_L1, "Dumping metadata\n"); + msg(STASIS_MSG_L1, "Dumping metadata\n"); if (delivery_dump_metadata(&ctx)) { - msg(OMC_MSG_L1 | OMC_MSG_ERROR, "Metadata dump failed\n"); + msg(STASIS_MSG_L1 | STASIS_MSG_ERROR, "Metadata dump failed\n"); } if (want_artifactory) { if (globals.enable_artifactory) { - msg(OMC_MSG_L1, "Uploading artifacts\n"); + msg(STASIS_MSG_L1, "Uploading artifacts\n"); delivery_artifact_upload(&ctx); } else { - msg(OMC_MSG_L1 | OMC_MSG_WARN, "Artifact uploading is disabled\n"); + msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Artifact uploading is disabled\n"); } } else { - msg(OMC_MSG_L1 | OMC_MSG_WARN, "Artifact uploading is disabled. deploy:artifactory is not configured\n"); + msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "Artifact uploading is disabled. deploy:artifactory is not configured\n"); } - msg(OMC_MSG_L1, "Cleaning up\n"); + msg(STASIS_MSG_L1, "Cleaning up\n"); delivery_free(&ctx); globals_free(); tpl_free(); - msg(OMC_MSG_L1, "Done!\n"); + msg(STASIS_MSG_L1, "Done!\n"); return 0; } @@ -115,7 +115,7 @@ char** split(char *_sptr, const char* delim, size_t max) pos = token - sptr; break; } - result[i] = calloc(OMC_BUFSIZ, sizeof(char)); + result[i] = calloc(STASIS_BUFSIZ, sizeof(char)); if (!result[i]) { return NULL; } @@ -125,7 +125,7 @@ char** split(char *_sptr, const char* delim, size_t max) // pos is non-zero when maximum split is reached if (pos) { // append the remaining string contents to array - result[i] = calloc(OMC_BUFSIZ, sizeof(char)); + result[i] = calloc(STASIS_BUFSIZ, sizeof(char)); if (!result[i]) { return NULL; } @@ -319,13 +319,13 @@ void strsort(char **arr, unsigned int sort_mode) { // Default mode is alphabetic sort compar fn = _strsort_alpha_compare; - if (sort_mode == OMC_SORT_LEN_DESCENDING) { + if (sort_mode == STASIS_SORT_LEN_DESCENDING) { fn = _strsort_dsc_compare; - } else if (sort_mode == OMC_SORT_LEN_ASCENDING) { + } else if (sort_mode == STASIS_SORT_LEN_ASCENDING) { fn = _strsort_asc_compare; - } else if (sort_mode == OMC_SORT_ALPHA) { + } else if (sort_mode == STASIS_SORT_ALPHA) { fn = _strsort_alpha_compare; // ^ still selectable though ^ - } else if (sort_mode == OMC_SORT_NUMERIC) { + } else if (sort_mode == STASIS_SORT_NUMERIC) { fn = _strsort_numeric_compare; } diff --git a/src/system.c b/src/system.c index d5e77ce..526f0ec 100644 --- a/src/system.c +++ b/src/system.c @@ -1,5 +1,5 @@ #include "system.h" -#include "omc.h" +#include "core.h" int shell(struct Process *proc, char *args) { struct Process selfproc; @@ -106,7 +106,7 @@ int shell_safe(struct Process *proc, char *args) { char buf[1024] = {0}; int result; - char *invalid_ch = strpbrk(args, OMC_SHELL_SAFE_RESTRICT); + char *invalid_ch = strpbrk(args, STASIS_SHELL_SAFE_RESTRICT); if (invalid_ch) { args = NULL; } @@ -138,10 +138,10 @@ int shell_safe(struct Process *proc, char *args) { } char *shell_output(const char *command, int *status) { - const size_t initial_size = OMC_BUFSIZ; + const size_t initial_size = STASIS_BUFSIZ; size_t current_size = initial_size; char *result = NULL; - char line[OMC_BUFSIZ]; + char line[STASIS_BUFSIZ]; FILE *pp; errno = 0; diff --git a/src/template.c b/src/template.c index 0a57232..819fe92 100644 --- a/src/template.c +++ b/src/template.c @@ -216,7 +216,7 @@ char *tpl_render(char *str) { char *env_val = getenv(key); value = strdup(env_val ? env_val : ""); } else if (do_func) { // {{ func:NAME(a, ...) }} - char func_name_temp[OMC_NAME_MAX] = {0}; + char func_name_temp[STASIS_NAME_MAX] = {0}; strcpy(func_name_temp, type_stop + 1); char *param_begin = strchr(func_name_temp, '('); if (!param_begin) { diff --git a/src/utils.c b/src/utils.c index 86622ad..fb22f59 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,7 +1,7 @@ #include <stdarg.h> -#include "omc.h" +#include "core.h" -char *dirstack[OMC_DIRSTACK_MAX]; +char *dirstack[STASIS_DIRSTACK_MAX]; const ssize_t dirstack_max = sizeof(dirstack) / sizeof(dirstack[0]); ssize_t dirstack_len = 0; @@ -186,8 +186,8 @@ char **file_readlines(const char *filename, size_t start, size_t limit, ReaderFn } // Allocate buffer - if ((buffer = calloc(OMC_BUFSIZ, sizeof(char))) == NULL) { - SYSERROR("unable to allocate %d bytes for buffer", OMC_BUFSIZ); + if ((buffer = calloc(STASIS_BUFSIZ, sizeof(char))) == NULL) { + SYSERROR("unable to allocate %d bytes for buffer", STASIS_BUFSIZ); if (!use_stdin) { fclose(fp); } @@ -195,7 +195,7 @@ char **file_readlines(const char *filename, size_t start, size_t limit, ReaderFn } // count number the of lines in the file - while ((fgets(buffer, OMC_BUFSIZ - 1, fp)) != NULL) { + while ((fgets(buffer, STASIS_BUFSIZ - 1, fp)) != NULL) { lines++; } @@ -232,7 +232,7 @@ char **file_readlines(const char *filename, size_t start, size_t limit, ReaderFn continue; } - if (fgets(buffer, OMC_BUFSIZ - 1, fp) == NULL) { + if (fgets(buffer, STASIS_BUFSIZ - 1, fp) == NULL) { break; } @@ -249,7 +249,7 @@ char **file_readlines(const char *filename, size_t start, size_t limit, ReaderFn } } result[i] = strdup(buffer); - memset(buffer, '\0', OMC_BUFSIZ); + memset(buffer, '\0', STASIS_BUFSIZ); } guard_free(buffer); @@ -396,12 +396,12 @@ void msg(unsigned type, char *fmt, ...) { char header[255]; char status[20]; - if (type & OMC_MSG_NOP) { + if (type & STASIS_MSG_NOP) { // quiet mode return; } - if (!globals.verbose && type & OMC_MSG_RESTRICT) { + if (!globals.verbose && type & STASIS_MSG_RESTRICT) { // Verbose mode is not active return; } @@ -413,39 +413,39 @@ void msg(unsigned type, char *fmt, ...) { va_start(args, fmt); stream = stdout; - fprintf(stream, "%s", OMC_COLOR_RESET); - if (type & OMC_MSG_ERROR) { + fprintf(stream, "%s", STASIS_COLOR_RESET); + if (type & STASIS_MSG_ERROR) { // for error output stream = stderr; - fprintf(stream, "%s", OMC_COLOR_RED); + fprintf(stream, "%s", STASIS_COLOR_RED); strcpy(status, " ERROR: "); - } else if (type & OMC_MSG_WARN) { + } else if (type & STASIS_MSG_WARN) { stream = stderr; - fprintf(stream, "%s", OMC_COLOR_YELLOW); + fprintf(stream, "%s", STASIS_COLOR_YELLOW); strcpy(status, " WARNING: "); } else { - fprintf(stream, "%s", OMC_COLOR_GREEN); + fprintf(stream, "%s", STASIS_COLOR_GREEN); strcpy(status, " "); } - if (type & OMC_MSG_L1) { - sprintf(header, "==>%s" OMC_COLOR_RESET OMC_COLOR_WHITE, status); - } else if (type & OMC_MSG_L2) { - sprintf(header, " ->%s" OMC_COLOR_RESET, status); - } else if (type & OMC_MSG_L3) { - sprintf(header, OMC_COLOR_BLUE " ->%s" OMC_COLOR_RESET, status); + if (type & STASIS_MSG_L1) { + sprintf(header, "==>%s" STASIS_COLOR_RESET STASIS_COLOR_WHITE, status); + } else if (type & STASIS_MSG_L2) { + sprintf(header, " ->%s" STASIS_COLOR_RESET, status); + } else if (type & STASIS_MSG_L3) { + sprintf(header, STASIS_COLOR_BLUE " ->%s" STASIS_COLOR_RESET, status); } fprintf(stream, "%s", header); vfprintf(stream, fmt, args); - fprintf(stream, "%s", OMC_COLOR_RESET); + fprintf(stream, "%s", STASIS_COLOR_RESET); va_end(args); } void debug_shell() { - msg(OMC_MSG_L1 | OMC_MSG_WARN, "ENTERING OMC DEBUG SHELL\n" OMC_COLOR_RESET); - system("/bin/bash -c 'PS1=\"(OMC DEBUG) \\W $ \" bash --norc --noprofile'"); - msg(OMC_MSG_L1 | OMC_MSG_WARN, "EXITING OMC DEBUG SHELL\n" OMC_COLOR_RESET); + msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "ENTERING STASIS DEBUG SHELL\n" STASIS_COLOR_RESET); + system("/bin/bash -c 'PS1=\"(STASIS DEBUG) \\W $ \" bash --norc --noprofile'"); + msg(STASIS_MSG_L1 | STASIS_MSG_WARN, "EXITING STASIS DEBUG SHELL\n" STASIS_COLOR_RESET); exit(255); } @@ -460,7 +460,7 @@ char *xmkstemp(FILE **fp, const char *mode) { strcpy(tmpdir, "/tmp"); } memset(t_name, 0, sizeof(t_name)); - sprintf(t_name, "%s/%s", tmpdir, "OMC.XXXXXX"); + sprintf(t_name, "%s/%s", tmpdir, "STASIS.XXXXXX"); fd = mkstemp(t_name); *fp = fdopen(fd, mode); |