]> git.ipfire.org Git - pakfire.git/commitdiff
build: Fix creating the build environment without a snapshot
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 25 May 2023 12:06:01 +0000 (12:06 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 25 May 2023 12:09:25 +0000 (12:09 +0000)
For some reason, I really messed this one up.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c

index 3b9117ab1f41b92249b759ab89f9296f28824d43..e7eca7fcd65c1c3511ef561a3e79b93227aa69d3 100644 (file)
@@ -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;