From: Michael Tremer Date: Sun, 13 Oct 2024 13:42:25 +0000 (+0000) Subject: cli: Fix enabling the snapshot X-Git-Tag: 0.9.30~1040 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=842bd2ba69fb8d5c12a62a1e9fa0be664694d866;p=pakfire.git cli: Fix enabling the snapshot Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/build.c b/src/cli/lib/build.c index b787f040b..d21c124f4 100644 --- a/src/cli/lib/build.c +++ b/src/cli/lib/build.c @@ -36,7 +36,12 @@ struct config { const char* id; const char* target; - int flags; + enum { + BUILD_INTERACTIVE = (1 << 0), + BUILD_ENABLE_CCACHE = (1 << 1), + BUILD_ENABLE_SNAPSHOT = (1 << 2), + BUILD_ENABLE_TESTS = (1 << 3), + } flags; // Makefiles char* makefiles[MAX_MAKEFILES]; @@ -67,15 +72,15 @@ static error_t parse(int key, char* arg, struct argp_state* state, void* data) { switch (key) { case OPT_DISABLE_CCACHE: - config->flags |= PAKFIRE_BUILD_DISABLE_CCACHE; + config->flags &= ~BUILD_ENABLE_CCACHE; break; case OPT_DISABLE_SNAPSHOT: - config->flags |= PAKFIRE_BUILD_DISABLE_SNAPSHOT; + config->flags &= ~BUILD_ENABLE_SNAPSHOT; break; case OPT_DISABLE_TESTS: - config->flags |= PAKFIRE_BUILD_DISABLE_TESTS; + config->flags &= ~BUILD_ENABLE_TESTS; break; case OPT_ID: @@ -83,7 +88,7 @@ static error_t parse(int key, char* arg, struct argp_state* state, void* data) { break; case OPT_NON_INTERACTIVE: - config->flags &= ~PAKFIRE_BUILD_INTERACTIVE; + config->flags &= ~BUILD_INTERACTIVE; break; case OPT_TARGET: @@ -139,8 +144,13 @@ int cli_build(void* data, int argc, char* argv[]) { struct config config = { .id = NULL, .target = NULL, - .flags = PAKFIRE_USE_SNAPSHOT, + .flags = + BUILD_INTERACTIVE | + BUILD_ENABLE_CCACHE | + BUILD_ENABLE_SNAPSHOT | + BUILD_ENABLE_TESTS, }; + int build_flags = 0; int r; struct cli_config* cli_config = data; @@ -153,13 +163,29 @@ int cli_build(void* data, int argc, char* argv[]) { // Replace the logger pakfire_ctx_set_log_callback(cli_config->ctx, log_callback, NULL); + // Set Pakfire flags + if (config.flags & BUILD_ENABLE_SNAPSHOT) + cli_config->flags |= PAKFIRE_USE_SNAPSHOT; + // Setup pakfire r = cli_setup_pakfire(&pakfire, cli_config); if (r) goto ERROR; + // Is the build interactive? + if (config.flags & BUILD_INTERACTIVE) + build_flags |= PAKFIRE_BUILD_INTERACTIVE; + + // Enable ccache? + if (!(config.flags & BUILD_ENABLE_CCACHE)) + build_flags |= PAKFIRE_BUILD_DISABLE_CCACHE; + + // Enable tests? + if (!(config.flags & BUILD_ENABLE_TESTS)) + build_flags |= PAKFIRE_BUILD_DISABLE_TESTS; + // Setup the build environment - r = pakfire_build_create(&build, pakfire, config.id, config.flags); + r = pakfire_build_create(&build, pakfire, config.id, build_flags); if (r) { fprintf(stderr, "Could not setup the build environment: %m\n"); goto ERROR; diff --git a/src/cli/lib/shell.c b/src/cli/lib/shell.c index 31a43e8e9..d13972ec6 100644 --- a/src/cli/lib/shell.c +++ b/src/cli/lib/shell.c @@ -31,7 +31,9 @@ #define MAX_PACKAGES 128 struct config { - int flags; + enum { + SHELL_ENABLE_SNAPSHOT = (1 << 0), + } flags; // Arguments const char* argv[MAX_ARGS + 1]; @@ -61,7 +63,7 @@ static error_t parse(int key, char* arg, struct argp_state* state, void* data) { switch (key) { case OPT_DISABLE_SNAPSHOT: - config->flags |= PAKFIRE_BUILD_DISABLE_SNAPSHOT; + config->flags &= ~SHELL_ENABLE_SNAPSHOT; break; case OPT_INSTALL: @@ -92,11 +94,8 @@ int cli_shell(void* data, int argc, char* argv[]) { struct cli_config* cli_config = data; - // XXX DEBUG - cli_config->flags |= PAKFIRE_USE_SNAPSHOT; - struct config config = { - .flags = PAKFIRE_BUILD_INTERACTIVE, + .flags = SHELL_ENABLE_SNAPSHOT, .argv = {}, .argc = 0, .packages = {}, @@ -108,13 +107,17 @@ int cli_shell(void* data, int argc, char* argv[]) { if (r) goto ERROR; + // Enable snapshots? + if (config.flags & SHELL_ENABLE_SNAPSHOT) + cli_config->flags |= PAKFIRE_USE_SNAPSHOT; + // Setup pakfire r = cli_setup_pakfire(&pakfire, cli_config); if (r) goto ERROR; // Setup the build environment - r = pakfire_build_create(&build, pakfire, NULL, config.flags); + r = pakfire_build_create(&build, pakfire, NULL, PAKFIRE_BUILD_INTERACTIVE); if (r) { fprintf(stderr, "Could not setup the build environment: %m\n"); goto ERROR;