From 8d77d9f00cd4fd60ebd229f46b8a24fc325239a6 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 25 May 2023 12:06:01 +0000 Subject: [PATCH] build: Fix creating the build environment without a snapshot For some reason, I really messed this one up. Signed-off-by: Michael Tremer --- src/libpakfire/build.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index 3b9117ab1..e7eca7fcd 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -1686,7 +1686,7 @@ static int pakfire_build_install_packages(struct pakfire_build* build, /* Initializes the build environment */ -static int pakfire_build_setup_snapshot(struct pakfire_build* build) { +static int pakfire_build_init(struct pakfire_build* build) { int r; // Don't do it again @@ -1695,17 +1695,17 @@ static int pakfire_build_setup_snapshot(struct pakfire_build* build) { return 0; } - // Nothing to do if we don't use the snapshot - if (pakfire_build_has_flag(build, PAKFIRE_BUILD_DISABLE_SNAPSHOT)) - return 0; + const int use_snapshot = !pakfire_build_has_flag(build, PAKFIRE_BUILD_DISABLE_SNAPSHOT); // Tells us whether we need to (re-)create the snapshot int snapshot_needs_update = 0; // Extract snapshot - r = pakfire_snapshot_restore(build->pakfire); - if (r) - return r; + if (use_snapshot) { + r = pakfire_snapshot_restore(build->pakfire); + if (r) + return r; + } // Install or update any build dependencies r = pakfire_build_install_packages(build, &snapshot_needs_update); @@ -1713,7 +1713,7 @@ static int pakfire_build_setup_snapshot(struct pakfire_build* build) { return r; // Update the snapshot if there were changes - if (snapshot_needs_update) { + if (use_snapshot && snapshot_needs_update) { // Store the snapshot r = pakfire_snapshot_store(build->pakfire); if (r) @@ -2124,7 +2124,7 @@ PAKFIRE_EXPORT int pakfire_build_exec(struct pakfire_build* build, const char* p INFO(build->pakfire, "Building %s...\n", nevra); // Initialize the build environment - r = pakfire_build_setup_snapshot(build); + r = pakfire_build_init(build); if (r) goto ERROR; @@ -2238,7 +2238,7 @@ PAKFIRE_EXPORT int pakfire_shell(struct pakfire* pakfire, const char** packages, } // Initialize the build environment - r = pakfire_build_setup_snapshot(build); + r = pakfire_build_init(build); if (r) goto ERROR; -- 2.39.5