aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cli/stasis/stasis_main.c17
-rw-r--r--src/lib/core/conda.c15
-rw-r--r--src/lib/core/delivery.c14
-rw-r--r--src/lib/core/delivery_init.c2
-rw-r--r--src/lib/core/multiprocessing.c12
5 files changed, 41 insertions, 19 deletions
diff --git a/src/cli/stasis/stasis_main.c b/src/cli/stasis/stasis_main.c
index 5325892..c2443d7 100644
--- a/src/cli/stasis/stasis_main.c
+++ b/src/cli/stasis/stasis_main.c
@@ -332,14 +332,15 @@ int main(int argc, char *argv[]) {
exit(1);
}
- delivery_gather_tool_versions(&ctx);
- if (!ctx.conda.tool_version) {
- msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Could not determine conda version\n");
- exit(1);
- }
- if (!ctx.conda.tool_build_version) {
- msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Could not determine conda-build version\n");
- exit(1);
+ if (delivery_gather_tool_versions(&ctx)) {
+ if (!ctx.conda.tool_version) {
+ msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Could not determine conda version\n");
+ exit(1);
+ }
+ if (!ctx.conda.tool_build_version) {
+ msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Could not determine conda-build version\n");
+ exit(1);
+ }
}
if (pip_exec("install build")) {
diff --git a/src/lib/core/conda.c b/src/lib/core/conda.c
index 35caf02..25069f8 100644
--- a/src/lib/core/conda.c
+++ b/src/lib/core/conda.c
@@ -109,7 +109,7 @@ int pip_index_provides(const char *index_url, const char *spec) {
strcpy(proc.f_stdout, logfile);
// Do an installation in dry-run mode to see if the package exists in the given index.
- snprintf(cmd, sizeof(cmd) - 1, "python -m pip install --dry-run --no-deps --index-url=%s %s", index_url, spec_local);
+ snprintf(cmd, sizeof(cmd) - 1, "python -m pip install --dry-run --no-cache --no-deps --index-url=%s '%s'", index_url, spec_local);
status = shell(&proc, cmd);
// Print errors only when shell() itself throws one
@@ -443,6 +443,15 @@ char *conda_get_active_environment() {
int conda_provides(const char *spec) {
struct Process proc;
memset(&proc, 0, sizeof(proc));
+
+ // Short circuit:
+ // Running "mamba search" without an argument will print every package in
+ // all channels, then return "found". Prevent this.
+ // No data implies "not found".
+ if (isempty((char *) spec)) {
+ return 0;
+ }
+
strcpy(proc.f_stdout, "/dev/null");
strcpy(proc.f_stderr, "/dev/null");
@@ -450,12 +459,12 @@ int conda_provides(const char *spec) {
// conda_exec() expects the program output to be visible to the user.
// For this operation we only need the exit value.
char cmd[PATH_MAX] = {0};
- snprintf(cmd, sizeof(cmd) - 1, "mamba search --use-index-cache %s", spec);
+ snprintf(cmd, sizeof(cmd) - 1, "mamba search %s", spec);
if (shell(&proc, cmd) < 0) {
fprintf(stderr, "shell: %s", strerror(errno));
return -1;
}
- return proc.returncode == 0;
+ return proc.returncode == 0; // 0=not_found, 1=found
}
int conda_index(const char *path) {
diff --git a/src/lib/core/delivery.c b/src/lib/core/delivery.c
index e32ed4c..5645dcc 100644
--- a/src/lib/core/delivery.c
+++ b/src/lib/core/delivery.c
@@ -302,16 +302,22 @@ void delivery_defer_packages(struct Delivery *ctx, int type) {
}
}
-void delivery_gather_tool_versions(struct Delivery *ctx) {
- int status = 0;
+int delivery_gather_tool_versions(struct Delivery *ctx) {
+ int status_tool_version = 0;
+ int status_tool_build_version = 0;
// Extract version from tool output
- ctx->conda.tool_version = shell_output("conda --version", &status);
+ ctx->conda.tool_version = shell_output("conda --version", &status_tool_version);
if (ctx->conda.tool_version)
strip(ctx->conda.tool_version);
- ctx->conda.tool_build_version = shell_output("conda build --version", &status);
+ ctx->conda.tool_build_version = shell_output("conda build --version", &status_tool_build_version);
if (ctx->conda.tool_build_version)
strip(ctx->conda.tool_version);
+
+ if (status_tool_version || status_tool_build_version) {
+ return 1;
+ }
+ return 0;
}
diff --git a/src/lib/core/delivery_init.c b/src/lib/core/delivery_init.c
index e914f99..2333628 100644
--- a/src/lib/core/delivery_init.c
+++ b/src/lib/core/delivery_init.c
@@ -257,7 +257,7 @@ int delivery_init(struct Delivery *ctx, int render_mode) {
char cache_local[PATH_MAX];
sprintf(cache_local, "%s/%s", ctx->storage.tmpdir, "cache");
- setenv("XDG_CACHE_HOME", ctx->storage.tmpdir, 1);
+ setenv("XDG_CACHE_HOME", cache_local, 1);
// add tools to PATH
char pathvar_tmp[STASIS_BUFSIZ];
diff --git a/src/lib/core/multiprocessing.c b/src/lib/core/multiprocessing.c
index 484c566..252bab9 100644
--- a/src/lib/core/multiprocessing.c
+++ b/src/lib/core/multiprocessing.c
@@ -98,7 +98,7 @@ struct MultiProcessingTask *mp_pool_task(struct MultiProcessingPool *pool, const
}
// Set default status to "error"
- slot->status = -1;
+ slot->status = MP_POOL_TASK_STATUS_INITIAL;
// Set task identifier string
memset(slot->ident, 0, sizeof(slot->ident));
@@ -169,7 +169,13 @@ void mp_pool_show_summary(struct MultiProcessingPool *pool) {
for (size_t i = 0; i < pool->num_used; i++) {
struct MultiProcessingTask *task = &pool->task[i];
char status_str[10] = {0};
- if (!task->status && !task->signaled_by) {
+
+ if (task->status == MP_POOL_TASK_STATUS_INITIAL && task->pid == MP_POOL_PID_UNUSED) {
+ // You will only see this label if the task pool is killed by
+ // MP_POOL_FAIL_FAST and tasks are still queued for execution
+ strcpy(status_str, "HOLD");
+ } else if (!task->status && !task->signaled_by) {
+
strcpy(status_str, "DONE");
} else if (task->signaled_by) {
strcpy(status_str, "TERM");
@@ -254,7 +260,7 @@ int mp_pool_join(struct MultiProcessingPool *pool, size_t jobs, size_t flags) {
for (size_t i = lower_i; i < upper_i; i++) {
struct MultiProcessingTask *slot = &pool->task[i];
- if (slot->status == -1) {
+ if (slot->status == MP_POOL_TASK_STATUS_INITIAL) {
if (mp_task_fork(pool, slot)) {
fprintf(stderr, "%s: mp_task_fork failed\n", slot->ident);
kill(0, SIGTERM);