diff options
| author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2026-06-18 14:05:46 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-18 14:05:46 -0400 |
| commit | e2008513b5fb4ae71d87ca6d05bdab5f3cb3a53f (patch) | |
| tree | 46faf70adbcbe727f6f74f07f387f8330ee390ab /src/cli/stasis_indexer | |
| parent | 252b9646c1cb0538123d51ced4a733f3dcfc266b (diff) | |
| download | stasis-e2008513b5fb4ae71d87ca6d05bdab5f3cb3a53f.tar.gz | |
* Update micromamba installation logic
* Split installation from micromamba() into micromamba_install()
* Return -1 when micromamba cannot be installed
* Add stasis.ini option "indexer.micromamba_download_url"
* Add global variable micromamba_download_url
* The installation function attempts two known-good URLs by default
*
* Add indexer arugment '--micromamba-download-url'
* Add is_file_compressed() function to utils
* Call micromamba_install() from tests
* Add space in usage statement
* Fix usage output when option array contains arguments without short options
* Add --micromamba-download-url to README.md
Diffstat (limited to 'src/cli/stasis_indexer')
| -rw-r--r-- | src/cli/stasis_indexer/args.c | 18 | ||||
| -rw-r--r-- | src/cli/stasis_indexer/helpers.c | 6 | ||||
| -rw-r--r-- | src/cli/stasis_indexer/include/args.h | 2 | ||||
| -rw-r--r-- | src/cli/stasis_indexer/stasis_indexer_main.c | 31 |
4 files changed, 52 insertions, 5 deletions
diff --git a/src/cli/stasis_indexer/args.c b/src/cli/stasis_indexer/args.c index 0d0e9b9..440c671 100644 --- a/src/cli/stasis_indexer/args.c +++ b/src/cli/stasis_indexer/args.c @@ -7,6 +7,7 @@ struct option long_options[] = { {"verbose", no_argument, 0, 'v'}, {"unbuffered", no_argument, 0, 'U'}, {"web", no_argument, 0, 'w'}, + {"micromamba-download-url", required_argument, 0, OPT_MICROMAMBA_DOWNLOAD_URL}, {0, 0, 0, 0}, }; @@ -16,6 +17,7 @@ const char *long_options_help[] = { "Increase output verbosity", "Disable line buffering", "Generate HTML indexes (requires pandoc)", + "Set micromamba download URL", NULL, }; @@ -26,17 +28,23 @@ void usage(char *name) { SYSERROR("Unable to allocate memory for options array"); exit(1); } - for (int i = 0; i < maxopts; i++) { - opts[i] = (char) long_options[i].val; + for (int i = 0, n = 0; i < maxopts; i++) { + if (isalnum(long_options[i].val)) { + opts[n] = (char) long_options[i].val; + n++; + } } - printf("usage: %s [-%s] {{STASIS_ROOT}...}\n", name, opts); + printf("usage: %s [-%s] {{STASIS_ROOT} ...}\n", name, opts); guard_free(opts); for (int i = 0; i < maxopts - 1; i++) { char line[255] = {0}; - snprintf(line, sizeof(line), " --%s -%c %-20s", long_options[i].name, long_options[i].val, long_options_help[i]); + snprintf(line, sizeof(line), " --%s %s%c %s", + long_options[i].name, + isalnum(long_options[i].val) ? "-" : "", + isalnum(long_options[i].val) ? long_options[i].val : ' ', + long_options_help[i]); puts(line); } } - diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c index 3ef96e4..b89622b 100644 --- a/src/cli/stasis_indexer/helpers.c +++ b/src/cli/stasis_indexer/helpers.c @@ -157,6 +157,7 @@ int micromamba_configure(const struct Delivery *ctx, struct MicromambaInfo *m) { m->conda_prefix = globals.conda_install_prefix; m->micromamba_prefix = micromamba_prefix; m->download_dir = ctx->storage.tmpdir; + m->download_url = globals.micromamba_download_url; const size_t pathvar_len = strlen(getenv("PATH")) + strlen(m->micromamba_prefix) + strlen(m->conda_prefix) + 3 + 4 + 1; // ^^^^^^^^^^^^^^^^^^ @@ -172,6 +173,11 @@ int micromamba_configure(const struct Delivery *ctx, struct MicromambaInfo *m) { setenv("PATH", pathvar, 1); guard_free(pathvar); + if (micromamba_install(m)) { + SYSERROR("Micromamba installation failed"); + return -1; + } + status += micromamba(m, "config prepend --env channels conda-forge"); if (!globals.verbose) { status += micromamba(m, "config set --env quiet true"); diff --git a/src/cli/stasis_indexer/include/args.h b/src/cli/stasis_indexer/include/args.h index 543aa4b..080863c 100644 --- a/src/cli/stasis_indexer/include/args.h +++ b/src/cli/stasis_indexer/include/args.h @@ -3,6 +3,8 @@ #include <getopt.h> +#define OPT_MICROMAMBA_DOWNLOAD_URL 1000 + extern struct option long_options[]; void usage(char *name); diff --git a/src/cli/stasis_indexer/stasis_indexer_main.c b/src/cli/stasis_indexer/stasis_indexer_main.c index 45bbb6c..5d86f29 100644 --- a/src/cli/stasis_indexer/stasis_indexer_main.c +++ b/src/cli/stasis_indexer/stasis_indexer_main.c @@ -197,6 +197,13 @@ int main(const int argc, char *argv[]) { case 'w': do_html = 1; break; + case OPT_MICROMAMBA_DOWNLOAD_URL: + globals.micromamba_download_url = strdup(optarg); + if (!globals.micromamba_download_url) { + SYSERROR("unable to allocate memory for micromamba_download_url"); + exit(1); + } + break; case '?': default: exit(1); @@ -309,6 +316,30 @@ int main(const int argc, char *argv[]) { printf(BANNER, version, AUTHOR); guard_free(version); + char *cfg_path = NULL; + if (asprintf(&cfg_path, "%s/stasis.ini", globals.sysconfdir) < 0) { + SYSERROR("Unable to allocate memory for cfg path"); + exit(1); + } + ctx._stasis_ini_fp.cfg_path = cfg_path; + ctx._stasis_ini_fp.cfg = ini_open(ctx._stasis_ini_fp.cfg_path); + if (ctx._stasis_ini_fp.cfg) { + if (populate_delivery_cfg(&ctx, INI_READ_RENDER)) { + SYSERROR("Unable to apply stasis configuration"); + exit(1); + } + } + else { + SYSWARN("Unable to open stasis configuration file: %s", cfg_path); + } + + if (globals.micromamba_download_url && isempty(globals.micromamba_download_url)) { + // safeguard against supplying a zero-length URL + // this covers the case where the user supplied it as an argument and/or in the config file + SYSERROR("micromamba download URL cannot be empty"); + exit(1); + } + indexer_init_dirs(&ctx, workdir); msg(STASIS_MSG_L1, "%s delivery root %s\n", |
