]> git.ipfire.org Git - pakfire.git/commitdiff
snapshot: Clone pakfire with custom flags
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 31 Jan 2025 14:40:18 +0000 (14:40 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 31 Jan 2025 14:40:18 +0000 (14:40 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/snapshot.c

index 162defbef876bc7be9cb275e77ff83d4c57ff44a..981e151e68e7c85c68d3917a825230c22df9cfde 100644 (file)
@@ -29,6 +29,7 @@
 #include <sys/mount.h>
 
 #include <pakfire/logging.h>
+#include <pakfire/pakfire.h>
 #include <pakfire/path.h>
 #include <pakfire/snapshot.h>
 #include <pakfire/string.h>
@@ -507,11 +508,14 @@ ERROR:
        Creates a new snapshot
 */
 int pakfire_snapshot_make(struct pakfire_snapshot** snapshot, struct pakfire* pakfire) {
+       struct pakfire_config* config = NULL;
        struct pakfire* p = NULL;
        char snapshot_path[PATH_MAX];
        char tmp[PATH_MAX];
+       const char* arch = NULL;
        const char* path = NULL;
        char time[1024];
+       int flags = PAKFIRE_FLAGS_BUILD|PAKFIRE_FLAGS_BUILD_LOCAL;
        int r;
 
        const char* packages[] = {
@@ -521,6 +525,12 @@ int pakfire_snapshot_make(struct pakfire_snapshot** snapshot, struct pakfire* pa
 
        struct pakfire_ctx* ctx = pakfire_ctx(pakfire);
 
+       // Fetch the configuration
+       config = pakfire_get_config(pakfire);
+
+       // Fetch the architecture
+       arch = pakfire_get_arch(pakfire);
+
        // Store the current time
        r = pakfire_strftime_now(time, PAKFIRE_SNAPSHOT_TIMESTAMP_FORMAT);
        if (r < 0)
@@ -543,8 +553,8 @@ int pakfire_snapshot_make(struct pakfire_snapshot** snapshot, struct pakfire* pa
                goto ERROR;
        }
 
-       // Clone the Pakfire instance
-       r = pakfire_clone(&p, pakfire, tmp);
+       // Create a new pakfire instance
+       r = pakfire_create(&p, ctx, config, tmp, arch, flags);
        if (r < 0) {
                ERROR(ctx, "Could not clone pakfire: %s\n", strerror(-r));
                goto ERROR;
@@ -578,6 +588,8 @@ int pakfire_snapshot_make(struct pakfire_snapshot** snapshot, struct pakfire* pa
 ERROR:
        if (p)
                pakfire_unref(p);
+       if (config)
+               pakfire_config_unref(config);
        if (ctx)
                pakfire_ctx_unref(ctx);