diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/conda.c | 17 | ||||
| -rw-r--r-- | src/delivery.c | 21 | ||||
| -rw-r--r-- | src/download.c | 10 | 
3 files changed, 41 insertions, 7 deletions
| diff --git a/src/conda.c b/src/conda.c index 976bbbc..7aaec77 100644 --- a/src/conda.c +++ b/src/conda.c @@ -35,7 +35,10 @@ int micromamba(struct MicromambaInfo *info, char *command, ...) {          char untarcmd[PATH_MAX * 2];          mkdirs(info->micromamba_prefix, 0755);          sprintf(untarcmd, "tar -xvf %s -C %s --strip-components=1 bin/micromamba 1>/dev/null", installer_path, info->micromamba_prefix); -        system(untarcmd); +        int untarcmd_status = system(untarcmd); +        if (untarcmd_status) { +            return -1; +        }      }      char cmd[STASIS_BUFSIZ]; @@ -249,7 +252,7 @@ int conda_check_required() {      return 0;  } -void conda_setup_headless() { +int conda_setup_headless() {      if (globals.verbose) {          conda_exec("config --system --set quiet false");      } else { @@ -285,7 +288,7 @@ void conda_setup_headless() {          if (conda_exec(cmd)) {              msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Unable to install user-defined base packages (conda)\n"); -            exit(1); +            return 1;          }      } @@ -307,7 +310,7 @@ void conda_setup_headless() {          if (pip_exec(cmd)) {              msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "Unable to install user-defined base packages (pip)\n"); -            exit(1); +            return 1;          }      } @@ -315,15 +318,17 @@ void conda_setup_headless() {          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); +        return 1;      }      if (globals.always_update_base_environment) {          if (conda_exec("update --all")) {              fprintf(stderr, "conda update was unsuccessful\n"); -            exit(1); +            return 1;          }      } + +    return 0;  }  int conda_env_create_from_uri(char *name, char *uri) { diff --git a/src/delivery.c b/src/delivery.c index 0c20550..b27ab08 100644 --- a/src/delivery.c +++ b/src/delivery.c @@ -420,6 +420,10 @@ static int populate_mission_ini(struct Delivery **ctx) {  }  void validate_delivery_ini(struct INIFILE *ini) { +    if (!ini) { +        SYSERROR("%s", "INIFILE is NULL!"); +        exit(1); +    }      if (ini_section_search(&ini, INI_SEARCH_EXACT, "meta")) {          ini_has_key_required(ini, "meta", "name");          ini_has_key_required(ini, "meta", "version"); @@ -1428,6 +1432,18 @@ void delivery_install_conda(char *install_script, char *conda_install_dir) {                  fprintf(stderr, "conda installation failed\n");                  exit(1);              } +        } else { +            // Proceed with the installation +            // -b = batch mode (non-interactive) +            char cmd[PATH_MAX] = {0}; +            snprintf(cmd, sizeof(cmd) - 1, "%s %s -b -p %s", +                     find_program("bash"), +                     install_script, +                     conda_install_dir); +            if (shell_safe(&proc, cmd)) { +                fprintf(stderr, "conda installation failed\n"); +                exit(1); +            }          }      } else {          msg(STASIS_MSG_L3, "Conda removal disabled by configuration\n"); @@ -1451,7 +1467,10 @@ void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir) {          exit(1);      } -    conda_setup_headless(); +    if (conda_setup_headless()) { +        // no COE check. this call must succeed. +        exit(1); +    }  }  void delivery_defer_packages(struct Delivery *ctx, int type) { diff --git a/src/download.c b/src/download.c index 1623560..f83adda 100644 --- a/src/download.c +++ b/src/download.c @@ -3,6 +3,7 @@  //  #include <string.h> +#include <stdlib.h>  #include "download.h"  size_t download_writer(void *fp, size_t size, size_t nmemb, void *stream) { @@ -18,6 +19,8 @@ long download(char *url, const char *filename, char **errmsg) {      FILE *fp;      char user_agent[20];      sprintf(user_agent, "stasis/%s", VERSION); +    long timeout = 30L; +    char *timeout_str = getenv("STASIS_DOWNLOAD_TIMEOUT");      curl_global_init(CURL_GLOBAL_ALL);      c = curl_easy_init(); @@ -27,11 +30,18 @@ long download(char *url, const char *filename, char **errmsg) {      if (!fp) {          return -1;      } +      curl_easy_setopt(c, CURLOPT_VERBOSE, 0L);      curl_easy_setopt(c, CURLOPT_FOLLOWLOCATION, 1L);      curl_easy_setopt(c, CURLOPT_USERAGENT, user_agent);      curl_easy_setopt(c, CURLOPT_NOPROGRESS, 0L);      curl_easy_setopt(c, CURLOPT_WRITEDATA, fp); + +    if (timeout_str) { +        timeout = strtol(timeout_str, NULL, 10); +    } +    curl_easy_setopt(c, CURLOPT_CONNECTTIMEOUT, timeout); +      curl_code = curl_easy_perform(c);      if (curl_code != CURLE_OK) {          if (errmsg) { | 
