aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-06-28 15:41:36 +0530
committersinanmohd <sinan@sinanmohd.com>2024-06-28 15:44:44 +0530
commit63c4f3d603650b90b182e6d6b1b92a272538ce5d (patch)
tree217d023febcbf3284cdf2502bece1aa43088aa3f
parent6f246fb247b87bcc7f5ad0ca070392cc92071dfc (diff)
evanix: add --system flag
-rw-r--r--include/evanix.h1
-rw-r--r--include/jobs.h1
-rw-r--r--src/evanix.c6
-rw-r--r--src/jobs.c11
-rw-r--r--src/queue.c1
5 files changed, 20 insertions, 0 deletions
diff --git a/include/evanix.h b/include/evanix.h
index aa53b9f..c4285fc 100644
--- a/include/evanix.h
+++ b/include/evanix.h
@@ -7,6 +7,7 @@ struct evanix_opts_t {
bool isdryrun;
bool ispipelined;
bool close_stderr_exec;
+ char *system;
};
extern struct evanix_opts_t evanix_opts;
diff --git a/include/jobs.h b/include/jobs.h
index 11f6b01..66ddcec 100644
--- a/include/jobs.h
+++ b/include/jobs.h
@@ -32,6 +32,7 @@ typedef enum {
JOB_READ_EVAL_ERR = 2,
JOB_READ_JSON_INVAL = 3,
JOB_READ_CACHED = 4,
+ JOB_READ_SYS_MISMATCH = 5,
} job_read_state_t;
int job_read(FILE *stream, struct job **jobs);
diff --git a/src/evanix.c b/src/evanix.c
index 64bd763..01279d1 100644
--- a/src/evanix.c
+++ b/src/evanix.c
@@ -14,6 +14,7 @@ static const char usage[] =
" -f, --flake Build a flake.\n"
" -d, --dry-run Show what derivations would be "
"built.\n"
+ " -s, --system System to build for."
" -p, --pipelined <bool> Use evanix build pipeline.\n"
" -c, --close-stderr-exec <bool> Close stderr on exec.\n"
"\n";
@@ -23,6 +24,7 @@ struct evanix_opts_t evanix_opts = {
.isflake = false,
.ispipelined = true,
.isdryrun = false,
+ .system = NULL,
};
static int evanix(char *expr);
@@ -99,6 +101,7 @@ int main(int argc, char *argv[])
{"help", no_argument, NULL, 'h'},
{"flake", no_argument, NULL, 'f'},
{"dry-run", no_argument, NULL, 'd'},
+ {"system", required_argument, NULL, 's'},
{"pipelined", required_argument, NULL, 'p'},
{"close-stderr-exec", required_argument, NULL, 'c'},
{NULL, 0, NULL, 0},
@@ -117,6 +120,9 @@ int main(int argc, char *argv[])
case 'd':
evanix_opts.isdryrun = true;
break;
+ case 's':
+ evanix_opts.system = optarg;
+ break;
case 'p':
ret = atob(optarg);
if (ret < 0) {
diff --git a/src/jobs.c b/src/jobs.c
index ec7d26d..bda9ee2 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -253,6 +253,17 @@ int job_read(FILE *stream, struct job **job)
goto out_free;
}
+ temp = cJSON_GetObjectItemCaseSensitive(root, "system");
+ if (!cJSON_IsString(temp)) {
+ ret = JOB_READ_JSON_INVAL;
+ goto out_free;
+ }
+ if (evanix_opts.system != NULL &&
+ strcmp(evanix_opts.system, temp->valuestring)) {
+ ret = JOB_READ_SYS_MISMATCH;
+ goto out_free;
+ }
+
temp = cJSON_GetObjectItemCaseSensitive(root, "name");
if (!cJSON_IsString(temp)) {
ret = JOB_READ_JSON_INVAL;
diff --git a/src/queue.c b/src/queue.c
index a5b4d6a..09eebb6 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -67,6 +67,7 @@ void *queue_thread_entry(void *queue_thread)
break;
} else if (ret == JOB_READ_EVAL_ERR ||
ret == JOB_READ_JSON_INVAL ||
+ ret == JOB_READ_SYS_MISMATCH ||
ret == JOB_READ_CACHED) {
continue;
} else if (ret == JOB_READ_SUCCESS) {