diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-27 09:20:06 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-27 09:20:06 -0400 |
| commit | 11bc498b5bca18662a582a163d3e9aaed1a17b79 (patch) | |
| tree | 271ee66c289408e8e6afa3392dc03f43dbc94987 /src | |
| parent | a47bff056b6439367362abe8a7859ed8b9d63ea2 (diff) | |
| download | stasis-11bc498b5bca18662a582a163d3e9aaed1a17b79.tar.gz | |
Add download_dir member to MicroMambaInfo struct.
* TMPDIR and hardcoded path is too unpredictable.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cli/stasis_indexer/helpers.c | 1 | ||||
| -rw-r--r-- | src/lib/core/conda.c | 19 | ||||
| -rw-r--r-- | src/lib/core/include/conda.h | 1 |
3 files changed, 18 insertions, 3 deletions
diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c index 86a20e4..425d209 100644 --- a/src/cli/stasis_indexer/helpers.c +++ b/src/cli/stasis_indexer/helpers.c @@ -156,6 +156,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; const size_t pathvar_len = strlen(getenv("PATH")) + strlen(m->micromamba_prefix) + strlen(m->conda_prefix) + 3 + 4 + 1; // ^^^^^^^^^^^^^^^^^^ diff --git a/src/lib/core/conda.c b/src/lib/core/conda.c index d15b6a6..4557c5c 100644 --- a/src/lib/core/conda.c +++ b/src/lib/core/conda.c @@ -19,11 +19,22 @@ int micromamba(const struct MicromambaInfo *info, char *command, ...) { sys.machine[sizeof(sys.machine) - 1] = '\0'; } + if (!info->download_dir || isempty(info->download_dir)) { + SYSERROR("%s", "micromamba inf->download_dir is NULL, or empty"); + return -1; + } + + if (mkdirs(info->download_dir, 0755) < 0) { + SYSERROR("Unable to create info->download_dir: %s", info->download_dir); + return -1; + } + char url[PATH_MAX] = {0}; snprintf(url, sizeof(url), "https://micro.mamba.pm/api/micromamba/%s-%s/latest", sys.sysname, sys.machine); - char installer_path[PATH_MAX]; - snprintf(installer_path, sizeof(installer_path), "%s/latest", getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp"); + const char installer_name[] = "mm_latest"; + char installer_path[PATH_MAX] = {0}; + snprintf(installer_path, sizeof(installer_path), "%s/%s", info->download_dir, installer_name); if (access(installer_path, F_OK)) { char *errmsg = NULL; @@ -41,7 +52,9 @@ int micromamba(const struct MicromambaInfo *info, char *command, ...) { if (access(mmbin, F_OK)) { char untarcmd[PATH_MAX * 2]; mkdirs(info->micromamba_prefix, 0755); - snprintf(untarcmd, sizeof(untarcmd), "tar -xvf %s -C %s --strip-components=1 bin/micromamba 1>/dev/null", installer_path, info->micromamba_prefix); + snprintf(untarcmd, sizeof(untarcmd), + "tar -xvf %s -C %s --strip-components=1 bin/micromamba 1>/dev/null", + installer_path, info->micromamba_prefix); int untarcmd_status = system(untarcmd); if (untarcmd_status) { return -1; diff --git a/src/lib/core/include/conda.h b/src/lib/core/include/conda.h index ccab060..cc9426d 100644 --- a/src/lib/core/include/conda.h +++ b/src/lib/core/include/conda.h @@ -29,6 +29,7 @@ struct MicromambaInfo { char *micromamba_prefix; //!< Path to write micromamba binary char *conda_prefix; //!< Path to install conda base tree + char *download_dir; //!< Path to store micromamba installer }; /** |
