]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
build: Install packages even when no snapshot is being used
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 17 Aug 2022 10:18:33 +0000 (10:18 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 17 Aug 2022 10:18:33 +0000 (10:18 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c

index c47ed24409f8cb96d7a11682d75692ca97679555..c5fdd9a53b2d41fc06b1d6fda7ad517ce5af32b2 100644 (file)
@@ -1146,6 +1146,7 @@ ERROR:
        Initializes the build environment
 */
 static int pakfire_build_init(struct pakfire_build* build) {
+       FILE* f = NULL;
        char path[PATH_MAX];
        int r;
 
@@ -1164,40 +1165,38 @@ static int pakfire_build_init(struct pakfire_build* build) {
                }
        }
 
-       // Check if the user wants a snapshot extracted
-       if (pakfire_build_has_flag(build, PAKFIRE_BUILD_DISABLE_SNAPSHOT)) {
-               DEBUG(build->pakfire, "Snapshot extraction has been disabled for this build\n");
-               return 0;
-       }
+       // Tells us whether we need to (re-)create the snapshot
+       int snapshot_needs_update = 0;
 
-       // Extract snapshot
-       r = pakfire_make_cache_path(build->pakfire, path, "%s", "snapshot.tar.zst");
-       if (r < 0) {
-               ERROR(build->pakfire, "Could not compose snapshot path: %m\n");
-               return 1;
-       }
+       // Check if the user wants a snapshot extracted
+       if (!pakfire_build_has_flag(build, PAKFIRE_BUILD_DISABLE_SNAPSHOT)) {
+               // Extract snapshot
+               r = pakfire_make_cache_path(build->pakfire, path, "%s", "snapshot.tar.zst");
+               if (r < 0) {
+                       ERROR(build->pakfire, "Could not compose snapshot path: %m\n");
+                       return 1;
+               }
 
-       // Open the snapshot
-       FILE* f = fopen(path, "r");
+               // Open the snapshot
+               f = fopen(path, "r");
 
-       // Try restoring the snapshot
-       if (f) {
-               r = pakfire_snapshot_restore(build->pakfire, f);
-               if (r) {
-                       fclose(f);
-                       return r;
+               // Try restoring the snapshot
+               if (f) {
+                       r = pakfire_snapshot_restore(build->pakfire, f);
+                       if (r) {
+                               fclose(f);
+                               return r;
+                       }
                }
        }
 
-       // Tells us whether we need to (re-)create the snapshot
-       int snapshot_needs_update = 0;
-
        // Install or update any build dependencies
        r = pakfire_build_install_packages(build, &snapshot_needs_update);
        if (r)
                return r;
 
-       if (snapshot_needs_update) {
+       // Update the snapshot if there were changes
+       if (!pakfire_build_has_flag(build, PAKFIRE_BUILD_DISABLE_SNAPSHOT) && snapshot_needs_update) {
                // Open snapshot file for writing
                f = fopen(path, "w");
                if (!f) {