aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cli/stasis_indexer/helpers.c34
-rw-r--r--src/cli/stasis_indexer/include/helpers.h1
-rw-r--r--src/cli/stasis_indexer/stasis_indexer_main.c40
-rw-r--r--src/lib/core/conda.c13
4 files changed, 87 insertions, 1 deletions
diff --git a/src/cli/stasis_indexer/helpers.c b/src/cli/stasis_indexer/helpers.c
index 8ae49a3..018a8f6 100644
--- a/src/cli/stasis_indexer/helpers.c
+++ b/src/cli/stasis_indexer/helpers.c
@@ -356,3 +356,37 @@ int load_metadata(struct Delivery *ctx, const char *filename) {
return 0;
}
+
+int write_manifest(const char *path, char **exclude_path, FILE *fp) {
+ struct dirent *rec = NULL;
+ DIR *dp = opendir(path);
+ if (!dp) {
+ perror(path);
+ return -1;
+ }
+ while ((rec = readdir(dp)) != NULL) {
+ if (!strcmp(rec->d_name, ".") || !strcmp(rec->d_name, "..")) {
+ continue;
+ }
+ if (strstr_array(exclude_path, rec->d_name)) {
+ continue;
+ }
+ char filepath[PATH_MAX] = {0};
+ strncpy(filepath, path, PATH_MAX - 1);
+ strcat(filepath, "/");
+ strcat(filepath, rec->d_name);
+ if (rec->d_type == DT_DIR) {
+ write_manifest(filepath, exclude_path, fp);
+ continue;
+ }
+
+ char *output = filepath;
+ if (!strncmp(output, "./", 2)) {
+ output += 2;
+ }
+ printf("%s\n", output);
+ fprintf(fp, "%s\n", output);
+ }
+ closedir(dp);
+ return 0;
+} \ No newline at end of file
diff --git a/src/cli/stasis_indexer/include/helpers.h b/src/cli/stasis_indexer/include/helpers.h
index 46705d2..9cefc05 100644
--- a/src/cli/stasis_indexer/include/helpers.h
+++ b/src/cli/stasis_indexer/include/helpers.h
@@ -23,5 +23,6 @@ int get_files(struct StrList **out, const char *path, const char *pattern, ...);
struct StrList *get_docker_images(struct Delivery *ctx, char *pattern);
int load_metadata(struct Delivery *ctx, const char *filename);
int micromamba_configure(const struct Delivery *ctx, struct MicromambaInfo *m);
+int write_manifest(const char *path, char **exclude_path, FILE *fp);
#endif //HELPERS_H
diff --git a/src/cli/stasis_indexer/stasis_indexer_main.c b/src/cli/stasis_indexer/stasis_indexer_main.c
index 5510dac..279af5a 100644
--- a/src/cli/stasis_indexer/stasis_indexer_main.c
+++ b/src/cli/stasis_indexer/stasis_indexer_main.c
@@ -368,6 +368,46 @@ int main(const int argc, char *argv[]) {
}
}
+ const char *revisionfile = "REVISION";
+ msg(STASIS_MSG_L1, "Writing revision file: %s\n", revisionfile);
+ if (!pushd(workdir)) {
+ FILE *revisionfp = fopen(revisionfile, "w+");
+ if (!revisionfp) {
+ SYSERROR("Unable to open revision file for writing: %s", revisionfile);
+ rmtree(workdir);
+ exit(1);
+ }
+ fprintf(revisionfp, "%d\n", get_latest_rc(local, strlist_count(metafiles)));
+ fclose(revisionfp);
+ popd();
+ } else {
+ SYSERROR("%s", workdir);
+ rmtree(workdir);
+ exit(1);
+ }
+
+ const char *manifestfile = "TREE";
+ msg(STASIS_MSG_L1, "Writing manifest: %s\n", manifestfile);
+ if (!pushd(workdir)) {
+ FILE *manifestfp = fopen(manifestfile, "w+");
+ if (!manifestfp) {
+ SYSERROR("Unable to open manifest for writing: %s", manifestfile);
+ rmtree(workdir);
+ exit(1);
+ }
+ if (write_manifest(".", (char *[]) {"tools", "build", "tmp", NULL}, manifestfp)) {
+ SYSERROR("Unable to write records to manifest: %s", manifestfile);
+ rmtree(workdir);
+ exit(1);
+ }
+ fclose(manifestfp);
+ popd();
+ } else {
+ SYSERROR("%s", workdir);
+ rmtree(workdir);
+ exit(1);
+ }
+
msg(STASIS_MSG_L1, "Copying indexed delivery to '%s'\n", destdir);
char cmd[PATH_MAX] = {0};
sprintf(cmd, "rsync -ah%s --delete --exclude 'tmp/' --exclude 'tools/' '%s/' '%s/'", globals.verbose ? "v" : "q", workdir, destdir);
diff --git a/src/lib/core/conda.c b/src/lib/core/conda.c
index 80d280a..9b5c77c 100644
--- a/src/lib/core/conda.c
+++ b/src/lib/core/conda.c
@@ -500,7 +500,18 @@ int conda_setup_headless() {
int conda_env_create_from_uri(char *name, char *uri) {
char env_command[PATH_MAX];
- sprintf(env_command, "env create -n %s -f %s", name, uri);
+ char *uri_fs = NULL;
+
+ // Convert a bare system path to a file:// path
+ if (!strstr(uri, "://")) {
+ uri_fs = calloc(strlen(uri) + strlen("file://") + 1, sizeof(*uri_fs));
+ if (!uri_fs) {
+ return -1;
+ }
+ snprintf(uri_fs, strlen(uri) + strlen("file://") + 1, "%s%s", "file://", uri);
+ }
+ sprintf(env_command, "env create -n '%s' --file='%s'", name, uri_fs ? uri_fs : uri);
+ guard_free(uri_fs);
return conda_exec(env_command);
}