From: Michael Tremer Date: Wed, 17 Aug 2022 10:18:33 +0000 (+0000) Subject: build: Install packages even when no snapshot is being used X-Git-Tag: 0.9.28~474 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffc2630d209f0b5f12ab16d6e6221a79025e3c3c;p=pakfire.git build: Install packages even when no snapshot is being used Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index c47ed2440..c5fdd9a53 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -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) {