aboutsummaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/stasis/stasis_main.c28
-rw-r--r--src/cli/stasis_indexer/args.c2
-rw-r--r--src/cli/stasis_indexer/helpers.c10
-rw-r--r--src/cli/stasis_indexer/include/helpers.h1
-rw-r--r--src/cli/stasis_indexer/junitxml_report.c4
-rw-r--r--src/cli/stasis_indexer/readmes.c4
-rw-r--r--src/cli/stasis_indexer/stasis_indexer_main.c29
7 files changed, 44 insertions, 34 deletions
diff --git a/src/cli/stasis/stasis_main.c b/src/cli/stasis/stasis_main.c
index 95cb7c5..8a222c1 100644
--- a/src/cli/stasis/stasis_main.c
+++ b/src/cli/stasis/stasis_main.c
@@ -7,6 +7,7 @@
// local includes
#include "args.h"
+#include "conda.h"
#include "system_requirements.h"
#include "tpl.h"
@@ -35,13 +36,13 @@ static void setup_python_version_override(struct Delivery *ctx, const char *vers
guard_free(ctx->meta.python);
ctx->meta.python = strdup(version);
if (!ctx->meta.python) {
- SYSERROR("%s", "Unable to allocate bytes for python version override");
+ SYSERROR("Unable to allocate bytes for python version override");
exit(1);
}
guard_free(ctx->meta.python_compact);
ctx->meta.python_compact = to_short_version(ctx->meta.python);
if (!ctx->meta.python_compact) {
- SYSERROR("%s", "Unable to allocate bytes for python compact version override");
+ SYSERROR("Unable to allocate bytes for python compact version override");
exit(1);
}
}
@@ -49,7 +50,7 @@ static void setup_python_version_override(struct Delivery *ctx, const char *vers
static void configure_stasis_ini(struct Delivery *ctx, char **config_input) {
if (!*config_input) {
- SYSDEBUG("%s", "No configuration passed by argument. Using basic config.");
+ SYSDEBUG("No configuration passed by argument. Using basic config.");
char cfgfile[PATH_MAX * 2];
snprintf(cfgfile, sizeof(cfgfile), "%s/%s", globals.sysconfdir, "stasis.ini");
SYSDEBUG("cfgfile: %s", cfgfile);
@@ -60,16 +61,16 @@ static void configure_stasis_ini(struct Delivery *ctx, char **config_input) {
}
}
- SYSDEBUG("Reading STASIS global configuration: %s\n", *config_input);
+ SYSDEBUG("Reading STASIS global configuration: %s", *config_input);
ctx->_stasis_ini_fp.cfg = ini_open(*config_input);
if (!ctx->_stasis_ini_fp.cfg) {
msg(STASIS_MSG_ERROR, "Failed to read global config file: %s, %s\n", *config_input, strerror(errno));
- SYSERROR("Failed to read global config file: %s\n", *config_input);
+ SYSERROR("Failed to read global config file: %s", *config_input);
exit(1);
}
ctx->_stasis_ini_fp.cfg_path = strdup(*config_input);
if (!ctx->_stasis_ini_fp.cfg_path) {
- SYSERROR("%s", "Failed to allocate memory delivery context global config file name");
+ SYSERROR("Failed to allocate memory delivery context global config file name");
exit(1);
}
guard_free(*config_input);
@@ -209,7 +210,7 @@ static void configure_conda_base(struct Delivery *ctx, char *envs[]) {
char *mission_base_orig = NULL;
if (asprintf(&mission_base_orig, "%s/%s/base.yml", ctx->storage.mission_dir, ctx->meta.mission) < 0) {
- SYSERROR("Unable to allocate bytes for %s/%s/base.yml path\n", ctx->storage.mission_dir, ctx->meta.mission);
+ SYSERROR("Unable to allocate bytes for %s/%s/base.yml path", ctx->storage.mission_dir, ctx->meta.mission);
exit(1);
}
@@ -220,7 +221,7 @@ static void configure_conda_base(struct Delivery *ctx, char *envs[]) {
} else {
msg(STASIS_MSG_L2, "Using base environment configuration: %s\n", mission_base_orig);
if (asprintf(&mission_base, "%s/%s-base.yml", ctx->storage.tmpdir, ctx->info.release_name) < 0) {
- SYSERROR("%s", "Unable to allocate bytes for temporary base.yml configuration");
+ SYSERROR("Unable to allocate bytes for temporary base.yml configuration");
remove(mission_base);
exit(1);
}
@@ -527,7 +528,7 @@ static void transfer_artifacts(struct Delivery *ctx) {
static char *center_text(const char *s, const size_t maxwidth) {
if (maxwidth < 2) {
- SYSERROR("%s", "maximum width must be greater than 0");
+ SYSERROR("maximum width must be greater than 0");
return NULL;
}
@@ -544,7 +545,7 @@ static char *center_text(const char *s, const size_t maxwidth) {
char *result = calloc(maxwidth + 1, sizeof(*result));
if (!result) {
- SYSERROR("%s", "unable to allocate bytes for centered text string");
+ SYSERROR("unable to allocate bytes for centered text string");
return NULL;
}
const size_t middle = (maxwidth / 2) - s_len / 2;
@@ -652,6 +653,7 @@ int main(int argc, char *argv[]) {
break;
case 'v':
globals.verbose = true;
+ LOG_LEVEL++;
break;
case OPT_OVERWRITE:
globals.enable_overwrite = true;
@@ -710,16 +712,18 @@ int main(int argc, char *argv[]) {
char *version = center_text(VERSION, strlen(STASIS_BANNER_HEADER));
if (!version) {
- SYSERROR("%s", "version too long?");
+ SYSERROR("version too long?");
version = strdup(VERSION);
if (!version) {
- SYSERROR("%s", "unable to allocate uncentered fallback version string");
+ SYSERROR("unable to allocate uncentered fallback version string");
exit(1);
}
}
printf(BANNER, version, AUTHOR);
guard_free(version);
+ SYSDEBUG("LOG_LEVEL is %s", log_get_level_str());
+
setup_python_version_override(&ctx, python_override_version);
configure_stasis_ini(&ctx, &config_input);
check_system_path();
diff --git a/src/cli/stasis_indexer/args.c b/src/cli/stasis_indexer/args.c
index e77c0b7..0d0e9b9 100644
--- a/src/cli/stasis_indexer/args.c
+++ b/src/cli/stasis_indexer/args.c
@@ -23,7 +23,7 @@ void usage(char *name) {
const int maxopts = sizeof(long_options) / sizeof(long_options[0]);
char *opts = calloc(maxopts + 1, sizeof(char));
if (!opts) {
- SYSERROR("%s", "Unable to allocate memory for options array");
+ SYSERROR("Unable to allocate memory for options array");
exit(1);
}
for (int i = 0; i < maxopts; i++) {
diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c
index 425d209..1bb5862 100644
--- a/src/cli/stasis_indexer/helpers.c
+++ b/src/cli/stasis_indexer/helpers.c
@@ -2,6 +2,8 @@
// Created by jhunk on 11/15/24.
//
+#include <fnmatch.h>
+
#include "core.h"
#include "helpers.h"
@@ -165,7 +167,7 @@ int micromamba_configure(const struct Delivery *ctx, struct MicromambaInfo *m) {
// 1 = nul terminator
char *pathvar = calloc(pathvar_len, sizeof(*pathvar));
if (!pathvar) {
- SYSERROR("%s", "Unable to allocate bytes for temporary path string");
+ SYSERROR("Unable to allocate bytes for temporary path string");
exit(1);
}
snprintf(pathvar, pathvar_len, "%s/bin:%s:%s", m->conda_prefix, m->micromamba_prefix, getenv("PATH"));
@@ -250,12 +252,12 @@ int get_files(struct StrList **out, const char *path, const char *pattern, ...)
char userpattern[PATH_MAX] = {0};
const int len = vsnprintf(userpattern, sizeof(userpattern), pattern, args);
if (len < 0) {
- SYSERROR("%s", "vsnprintf failed\n");
+ SYSERROR("vsnprintf failed");
va_end(args);
return -1;
}
if ((size_t) len > sizeof(userpattern)) {
- fprintf(stderr, "WARNING: %s: userpattern truncated!\n", __FUNCTION__);
+ SYSWARN("%s: userpattern truncated!", __FUNCTION__);
}
va_end(args);
if (!strlen(userpattern)) {
@@ -297,7 +299,7 @@ struct StrList *get_docker_images(struct Delivery *ctx, char *pattern) {
char *tarball = NULL;
asprintf(&tarball, "%s*.tar*", pattern);
if (!tarball) {
- SYSERROR("%s", "Unable to allocate bytes for docker image wildcard pattern");
+ SYSERROR("Unable to allocate bytes for docker image wildcard pattern");
return NULL;
}
tolower_s(tarball);
diff --git a/src/cli/stasis_indexer/include/helpers.h b/src/cli/stasis_indexer/include/helpers.h
index 6e2f93c..4a51f8f 100644
--- a/src/cli/stasis_indexer/include/helpers.h
+++ b/src/cli/stasis_indexer/include/helpers.h
@@ -2,6 +2,7 @@
#define HELPERS_H
#include "delivery.h"
+#include "conda.h"
#define ARRAY_COUNT_DYNAMIC(X, COUNTER) \
do { \
diff --git a/src/cli/stasis_indexer/junitxml_report.c b/src/cli/stasis_indexer/junitxml_report.c
index c6cf4b0..b767179 100644
--- a/src/cli/stasis_indexer/junitxml_report.c
+++ b/src/cli/stasis_indexer/junitxml_report.c
@@ -2,6 +2,8 @@
// Created by jhunk on 11/15/24.
//
+#include <fnmatch.h>
+
#include "core.h"
#include "callbacks.h"
#include "junitxml.h"
@@ -37,7 +39,7 @@ static int write_report_output(struct Delivery *ctx, FILE *destfp, const char *x
char result_outfile[PATH_MAX] = {0};
char *short_name_pattern = NULL;
if (asprintf(&short_name_pattern, "-%s", ctx->info.release_name) < 0 || !short_name_pattern) {
- SYSERROR("%s", "unable to allocate bytes for short name pattern");
+ SYSERROR("unable to allocate bytes for short name pattern");
guard_free(bname);
return -1;
}
diff --git a/src/cli/stasis_indexer/readmes.c b/src/cli/stasis_indexer/readmes.c
index 7357fca..d740367 100644
--- a/src/cli/stasis_indexer/readmes.c
+++ b/src/cli/stasis_indexer/readmes.c
@@ -66,7 +66,7 @@ int indexer_readmes(struct Delivery **ctx, const size_t nelem) {
if (asprintf(&pattern, "*%s*%s*",
latest_deliveries[i]->info.build_number,
strstr((*ctx)->rules.release_fmt, "%p") ? latest_deliveries[i]->meta.python_compact : "" ) < 0) {
- SYSERROR("%s", "Unable to allocate bytes for pattern");
+ SYSERROR("Unable to allocate bytes for pattern");
fclose(indexfp);
return -1;
}
@@ -105,7 +105,7 @@ int indexer_readmes(struct Delivery **ctx, const size_t nelem) {
current->info.build_number,
strstr((*ctx)->rules.release_fmt, "%p") ? current->meta.python_compact : "" );
if (!pattern) {
- SYSERROR("%s", "Unable to allocate bytes for pattern");
+ SYSERROR("Unable to allocate bytes for pattern");
fclose(indexfp);
return -1;
}
diff --git a/src/cli/stasis_indexer/stasis_indexer_main.c b/src/cli/stasis_indexer/stasis_indexer_main.c
index ed938b7..56be257 100644
--- a/src/cli/stasis_indexer/stasis_indexer_main.c
+++ b/src/cli/stasis_indexer/stasis_indexer_main.c
@@ -143,7 +143,7 @@ void indexer_init_dirs(struct Delivery *ctx, const char *workdir) {
char *user_dir = expandpath("~/.stasis/indexer");
if (!user_dir) {
- SYSERROR("%s", "expandpath failed");
+ SYSERROR("expandpath failed");
}
path_store(&ctx->storage.output_dir, PATH_MAX, ctx->storage.root, "");
@@ -164,7 +164,7 @@ void indexer_init_dirs(struct Delivery *ctx, const char *workdir) {
snprintf(newpath, sizeof(newpath), "%s/bin:%s", ctx->storage.tools_dir, getenv("PATH"));
setenv("PATH", newpath, 1);
} else {
- SYSERROR("%s", "environment variable PATH is undefined. Unable to continue.");
+ SYSERROR("environment variable PATH is undefined. Unable to continue.");
exit(1);
}
}
@@ -198,6 +198,7 @@ int main(const int argc, char *argv[]) {
break;
case 'v':
globals.verbose = 1;
+ LOG_LEVEL++;
break;
case 'w':
do_html = 1;
@@ -213,7 +214,7 @@ int main(const int argc, char *argv[]) {
rootdirs_total = argc - current_index;
rootdirs = calloc(rootdirs_total + 1, sizeof(*rootdirs));
if (!rootdirs) {
- SYSERROR("%s", "unable to allocate memory for rootdirs array");
+ SYSERROR("unable to allocate memory for rootdirs array");
exit(1);
}
@@ -228,7 +229,7 @@ int main(const int argc, char *argv[]) {
// use first positional argument
rootdirs[i] = realpath(argv[optind], NULL);
if (!rootdirs[i]) {
- SYSERROR("%s", "Unable to allocate memory for root directory");
+ SYSERROR("Unable to allocate memory for root directory");
exit(1);
}
optind++;
@@ -311,7 +312,7 @@ int main(const int argc, char *argv[]) {
rootdirs_total > 1 ? "Merging" : "Indexing",
rootdirs_total > 1 ? "directories" : "directory");
if (indexer_combine_rootdirs(workdir, rootdirs, rootdirs_total)) {
- SYSERROR("%s", "Copy operation failed");
+ SYSERROR("Copy operation failed");
rmtree(workdir);
exit(1);
}
@@ -326,19 +327,19 @@ int main(const int argc, char *argv[]) {
struct MicromambaInfo m;
if (micromamba_configure(&ctx, &m)) {
- SYSERROR("%s", "Unable to configure micromamba");
+ SYSERROR("Unable to configure micromamba");
exit(1);
}
msg(STASIS_MSG_L1, "Indexing conda packages\n");
if (indexer_conda(&ctx, m)) {
- SYSERROR("%s", "Conda package indexing operation failed");
+ SYSERROR("Conda package indexing operation failed");
exit(1);
}
msg(STASIS_MSG_L1, "Indexing wheel packages\n");
if (indexer_wheels(&ctx)) {
- SYSERROR("%s", "Python package indexing operation failed");
+ SYSERROR("Python package indexing operation failed");
exit(1);
}
@@ -354,7 +355,7 @@ int main(const int argc, char *argv[]) {
struct Delivery **local = calloc(strlist_count(metafiles) + 1, sizeof(*local));
if (!local) {
- SYSERROR("%s", "Unable to allocate bytes for local delivery context array");
+ SYSERROR("Unable to allocate bytes for local delivery context array");
exit(1);
}
@@ -375,26 +376,26 @@ int main(const int argc, char *argv[]) {
msg(STASIS_MSG_L1, "Generating links to latest release iteration\n");
if (indexer_symlinks(local, strlist_count(metafiles))) {
- SYSERROR("%s", "Link generation failed");
+ SYSERROR("Link generation failed");
exit(1);
}
msg(STASIS_MSG_L1, "Generating README.md\n");
if (indexer_readmes(local, strlist_count(metafiles))) {
- SYSERROR("%s", "README indexing operation failed");
+ SYSERROR("README indexing operation failed");
exit(1);
}
msg(STASIS_MSG_L1, "Indexing test results\n");
if (indexer_junitxml_report(local, strlist_count(metafiles))) {
- SYSERROR("%s", "Test result indexing operation failed");
+ SYSERROR("Test result indexing operation failed");
exit(1);
}
if (do_html) {
msg(STASIS_MSG_L1, "Generating HTML indexes\n");
if (indexer_make_website(local)) {
- SYSERROR("%s", "Site creation failed");
+ SYSERROR("Site creation failed");
exit(1);
}
}
@@ -449,7 +450,7 @@ int main(const int argc, char *argv[]) {
}
if (system(cmd)) {
- SYSERROR("%s", "Copy operation failed");
+ SYSERROR("Copy operation failed");
rmtree(workdir);
exit(1);
}