aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/core/conda.c11
-rw-r--r--src/lib/core/include/conda.h3
-rw-r--r--src/lib/delivery/delivery.c4
3 files changed, 13 insertions, 5 deletions
diff --git a/src/lib/core/conda.c b/src/lib/core/conda.c
index 2a76c30..d15b6a6 100644
--- a/src/lib/core/conda.c
+++ b/src/lib/core/conda.c
@@ -137,7 +137,7 @@ const char *pkg_index_provides_strerror(int code) {
return PKG_ERROR_STR[code];
}
-int pkg_index_provides(int mode, const char *index, const char *spec) {
+int pkg_index_provides(int mode, const char *index, const char *spec, const char *logdir) {
char cmd[PATH_MAX] = {0};
char spec_local[255] = {0};
@@ -153,7 +153,14 @@ int pkg_index_provides(int mode, const char *index, const char *spec) {
lstrip(spec_local);
strip(spec_local);
- char logfile[] = "/tmp/stasis/STASIS-package_exists.XXXXXX";
+ if (mkdirs(logdir, 0700) < 0) {
+ SYSERROR("Unable to create log directory: %s", logdir ? logdir : "NULL");
+ return -1;
+ }
+ const char logfile_template[] = "STASIS-package_exists.XXXXXX";
+ char logfile[PATH_MAX] = {0};
+ snprintf(logfile, sizeof(logfile), "%s/%s", logdir, logfile_template);
+
int logfd = mkstemp(logfile);
if (logfd < 0) {
perror(logfile);
diff --git a/src/lib/core/include/conda.h b/src/lib/core/include/conda.h
index f3d481c..ccab060 100644
--- a/src/lib/core/include/conda.h
+++ b/src/lib/core/include/conda.h
@@ -219,12 +219,13 @@ int conda_index(const char *path);
* @param mode USE_CONDA
* @param index a file system path or url pointing to a simple index or conda channel
* @param spec a pip package specification (e.g. `name==1.2.3`)
+ * @param logdir the directory to store the output log
* @param spec a conda package specification (e.g. `name=1.2.3`)
* @return PKG_NOT_FOUND, if not found
* @return PKG_FOUND, if found
* @return PKG_E_INDEX_PROVIDES_{ERROR}, on error (see conda.h)
*/
-int pkg_index_provides(int mode, const char *index, const char *spec);
+int pkg_index_provides(int mode, const char *index, const char *spec, const char *logdir);
const char *pkg_index_provides_strerror(int code);
char *conda_get_active_environment();
diff --git a/src/lib/delivery/delivery.c b/src/lib/delivery/delivery.c
index d4fe08c..45b3b35 100644
--- a/src/lib/delivery/delivery.c
+++ b/src/lib/delivery/delivery.c
@@ -453,9 +453,9 @@ void delivery_defer_packages(struct Delivery *ctx, int type) {
int upstream_exists = 0;
if (DEFER_PIP == type) {
- upstream_exists = pkg_index_provides(PKG_USE_PIP, PYPI_INDEX_DEFAULT, name);
+ upstream_exists = pkg_index_provides(PKG_USE_PIP, PYPI_INDEX_DEFAULT, name, ctx->storage.tmpdir);
} else if (DEFER_CONDA == type) {
- upstream_exists = pkg_index_provides(PKG_USE_CONDA, NULL, name);
+ upstream_exists = pkg_index_provides(PKG_USE_CONDA, NULL, name, ctx->storage.tmpdir);
}
if (PKG_INDEX_PROVIDES_FAILED(upstream_exists)) {