aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-01-31 13:06:16 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-01-31 13:06:16 -0500
commit1f7ebb234761d8aa5edf0ea784c2dd9e2e247218 (patch)
treedffa1c7b5a344ceea11fecffb8ac1d5d3139ba70 /src
parent633c3c257807449d196cb9c9380a1f819a37cf67 (diff)
downloadstasis-1f7ebb234761d8aa5edf0ea784c2dd9e2e247218.tar.gz
Fix up mission directory handler
Diffstat (limited to 'src')
-rw-r--r--src/deliverable.c26
-rw-r--r--src/main.c34
2 files changed, 49 insertions, 11 deletions
diff --git a/src/deliverable.c b/src/deliverable.c
index b77502c..e7d47f5 100644
--- a/src/deliverable.c
+++ b/src/deliverable.c
@@ -137,6 +137,7 @@ void delivery_free(struct Delivery *ctx) {
guard_free(ctx->storage.build_recipes_dir)
guard_free(ctx->storage.build_sources_dir)
guard_free(ctx->storage.build_testing_dir)
+ guard_free(ctx->storage.mission_dir);
guard_free(ctx->conda.installer_baseurl)
guard_free(ctx->conda.installer_name)
guard_free(ctx->conda.installer_version)
@@ -189,6 +190,21 @@ void delivery_init_dirs(struct Delivery *ctx) {
ctx->storage.conda_artifact_dir = realpath("omc/output/packages/conda", NULL);
ctx->storage.wheel_artifact_dir = realpath("omc/output/packages/wheels", NULL);
+ // Configure mission directory
+ if (!ctx->storage.mission_dir) {
+ ctx->storage.mission_dir = join(
+ (char *[]) {
+ globals.sysconfdir,
+ "mission",
+ NULL
+ },
+ DIR_SEP);
+ }
+ if (access(ctx->storage.mission_dir, F_OK)) {
+ msg(OMC_MSG_L1, "%s: %s\n", ctx->storage.mission_dir, strerror(errno));
+ exit(1);
+ }
+
// Override installation prefix using global configuration key
if (globals.conda_install_prefix && strlen(globals.conda_install_prefix)) {
// user wants a specific path
@@ -501,7 +517,17 @@ int delivery_format_str(struct Delivery *ctx, char **dest, const char *fmt) {
return 0;
}
+void delivery_debug_show(struct Delivery *ctx) {
+ printf("\n====DEBUG====\n");
+ printf("%-20s %-10s\n", "[DEBUG] system configuration directory:", globals.sysconfdir);
+ printf("%-20s %-10s\n", "[DEBUG] mission directory:", ctx->storage.mission_dir);
+}
+
void delivery_meta_show(struct Delivery *ctx) {
+ if (globals.verbose) {
+ delivery_debug_show(ctx);
+ }
+
printf("\n====DELIVERY====\n");
printf("%-20s %-10s\n", "Target Python:", ctx->meta.python);
printf("%-20s %-10s\n", "Name:", ctx->meta.name);
diff --git a/src/main.c b/src/main.c
index 1dccea2..d1df20e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -186,6 +186,24 @@ int main(int argc, char *argv[], char *arge[]) {
msg(OMC_MSG_L1, "Initializing\n");
+ // Set up PREFIX/etc directory information
+ // The user may manipulate the base directory path with OMC_SYSCONFDIR
+ // environment variable
+ char omc_sysconfdir_tmp[PATH_MAX];
+ if (getenv("OMC_SYSCONFDIR")) {
+ strncpy(omc_sysconfdir_tmp, getenv("OMC_SYSCONFDIR"), sizeof(omc_sysconfdir_tmp));
+ } else {
+ strncpy(omc_sysconfdir_tmp, OMC_SYSCONFDIR, sizeof(omc_sysconfdir_tmp) - 1);
+ }
+
+ globals.sysconfdir = realpath(omc_sysconfdir_tmp, NULL);
+ if (!globals.sysconfdir) {
+ msg(OMC_MSG_ERROR | OMC_MSG_L1, "Unable to resolve path to configuration directory: %s\n", omc_sysconfdir_tmp);
+ exit(1);
+ } else {
+ memset(omc_sysconfdir_tmp, 0, sizeof(omc_sysconfdir_tmp));
+ }
+
if (config_input) {
msg(OMC_MSG_L2, "Reading OMC global configuration: %s\n", config_input);
cfg = ini_open(config_input);
@@ -241,19 +259,13 @@ int main(int argc, char *argv[], char *arge[]) {
tpl_register("system.platform", ctx.system.platform[DELIVERY_PLATFORM_RELEASE]);
char missionfile[PATH_MAX] = {0};
+
if (getenv("OMC_SYSCONFDIR")) {
- globals.sysconfdir = calloc(PATH_MAX, sizeof(*globals.sysconfdir));
- } else {
- globals.sysconfdir = strdup(OMC_SYSCONFDIR);
- }
- if (!globals.sysconfdir) {
- msg(OMC_MSG_ERROR | OMC_MSG_L1, "Unable to allocate memory for system configuration directory path\n");
- exit(1);
- }
- if (getenv("OMC_SYSCONFDIR")) {
- sprintf(missionfile, "%s/%s/%s/%s.ini", getenv("OMC_SYSCONFDIR"), "mission", ctx.meta.mission, ctx.meta.mission);
+ sprintf(missionfile, "%s/%s/%s/%s.ini",
+ getenv("OMC_SYSCONFDIR"), "mission", ctx.meta.mission, ctx.meta.mission);
} else {
- sprintf(missionfile, "%s/%s/%s/%s.ini", OMC_SYSCONFDIR, "mission", ctx.meta.mission, ctx.meta.mission);
+ sprintf(missionfile, "%s/%s/%s/%s.ini",
+ globals.sysconfdir, "mission", ctx.meta.mission, ctx.meta.mission);
}
struct INIFILE *cfg_mission;