]> git.ipfire.org Git - pakfire.git/commitdiff
snapshot: Do not archive any mountpoints
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 20 May 2021 11:31:47 +0000 (11:31 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 20 May 2021 11:31:47 +0000 (11:31 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/pakfire.h
src/libpakfire/pakfire.c
src/libpakfire/snapshot.c

index c2f49941e0f8bd40788c530a5630e760b2400df0..a6f6ca8c6230a6f8693eb9d3217e8c91c7e6dc3f 100644 (file)
@@ -92,6 +92,7 @@ int pakfire_read_makefile(PakfireParser* parser, Pakfire pakfire, const char* pa
 #include <pakfire/config.h>
 
 struct pakfire_config* pakfire_get_config(Pakfire pakfire);
+int pakfire_is_mountpoint(Pakfire pakfire, const char* path);
 
 const char* pakfire_get_distro_name(Pakfire pakfire);
 const char* pakfire_get_distro_id(Pakfire pakfire);
index 38fc1a600087d5252907a70d744d6a4ab79ed1f2..1045aeb54b68725a9d1cc74de1648687e9119982 100644 (file)
@@ -156,16 +156,12 @@ static int __mount(Pakfire pakfire, const char* source, const char* target,
        if (r)
                return r;
 
-       struct mountpoint* mp;
-
-       // Check if the mountpoint is already on the list
-       STAILQ_FOREACH(mp, &pakfire->mountpoints, nodes) {
-               if (strcmp(mp->path, target) == 0)
-                       return 0;
-       }
+       // Skip if the mountpoint is already on the list
+       if (pakfire_is_mountpoint(pakfire, target))
+               return 0;
 
        // If not, add the mountpoint to the list so that we can umount it later
-       mp = calloc(1, sizeof(*mp));
+       struct mountpoint* mp = calloc(1, sizeof(*mp));
        if (!mp)
                return 1;
 
@@ -251,6 +247,18 @@ RETRY:
        return 0;
 }
 
+int pakfire_is_mountpoint(Pakfire pakfire, const char* path) {
+       struct mountpoint* mp;
+
+       // Check if path is on this list
+       STAILQ_FOREACH(mp, &pakfire->mountpoints, nodes) {
+               if (strcmp(mp->path, path) == 0)
+                       return 1;
+       }
+
+       return 0;
+}
+
 static const struct pakfire_devnode {
        const char* path;
        int major;
index 5207df83206d24c5d4de88a544cb0b9c52912e40..e238890de89df1d83a1f03531e454e022f0aa801 100644 (file)
@@ -165,14 +165,22 @@ PAKFIRE_EXPORT int pakfire_snapshot_create(Pakfire pakfire, FILE* f) {
                        goto ERROR;
                }
 
+               const char* full_path = archive_entry_pathname(entry);
+
                // Compute the relative path
-               const char* path = pakfire_path_relpath(root, archive_entry_pathname(entry));
+               const char* path = pakfire_path_relpath(root, full_path);
                if (!path)
                        continue;
 
+               // Skip mountpoints
+               if (pakfire_is_mountpoint(pakfire, full_path)) {
+                       DEBUG(pakfire, "Skipping mountpoint %s...", path);
+                       continue;
+               }
+
                // Skip excludes
                if (pakfire_snapshot_path_is_excluded(path)) {
-                       DEBUG(pakfire, "Skipping %s...\n", path);
+                       DEBUG(pakfire, "Skipping excluded path %s...\n", path);
                        continue;
                }