Initializes the build environment
*/
static int pakfire_build_init(struct pakfire_build* build) {
+ FILE* f = NULL;
char path[PATH_MAX];
int r;
}
}
- // 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) {