]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
mount: Mount the interpreter every time
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jul 2022 18:25:48 +0000 (18:25 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jul 2022 18:25:48 +0000 (18:25 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/mount.c
src/libpakfire/pakfire.c

index f7b1b966ad4ee16c584541a831c7b4dae02b80f0..52eb381cb1b5cfcc33c0614e26bfa1c051470ba4 100644 (file)
@@ -29,6 +29,7 @@
 // libmount
 #include <libmount/libmount.h>
 
+#include <pakfire/arch.h>
 #include <pakfire/logging.h>
 #include <pakfire/pakfire.h>
 #include <pakfire/mount.h>
@@ -327,6 +328,44 @@ static int pakfire_populate_dev(struct pakfire* pakfire) {
        return 0;
 }
 
+static int pakfire_mount_interpreter(struct pakfire* pakfire) {
+       char target[PATH_MAX];
+
+       // Fetch the target architecture
+       const char* arch = pakfire_get_arch(pakfire);
+
+       // Can we emulate this architecture?
+       char* interpreter = pakfire_arch_find_interpreter(arch);
+
+       // No interpreter required
+       if (!interpreter)
+               return 0;
+
+       DEBUG(pakfire, "Mounting interpreter %s for %s\n", interpreter, arch);
+
+       // Where to mount this?
+       int r = pakfire_make_path(pakfire, target, interpreter);
+       if (r < 0)
+               return r;
+
+       // Create directory
+       r = pakfire_mkparentdir(target, 0);
+       if (r)
+               return r;
+
+       // Create an empty file
+       FILE* f = fopen(target, "w");
+       if (!f)
+               return 1;
+       fclose(f);
+
+       r = pakfire_mount(pakfire, interpreter, target, NULL, MS_BIND|MS_RDONLY, NULL);
+       if (r)
+               ERROR(pakfire, "Could not mount interpreter %s to %s: %m\n", interpreter, target);
+
+       return r;
+}
+
 int pakfire_mount_all(struct pakfire* pakfire) {
        char target[PATH_MAX];
        char options[PATH_MAX];
@@ -369,6 +408,11 @@ RETRY:
        if (r)
                return r;
 
+       // Mount the interpreter (if needed)
+       r = pakfire_mount_interpreter(pakfire);
+       if (r)
+               return r;
+
        return 0;
 }
 
index 6547bd811240e0702942f7f6e43b41277aa50de4..0c5bc8833540e95557221b1ecfbc18223b9fbcc1 100644 (file)
@@ -265,41 +265,6 @@ ERROR:
        return r;
 }
 
-static int pakfire_mount_interpreter(struct pakfire* pakfire) {
-       char target[PATH_MAX];
-
-       // Can we emulate this architecture?
-       char* interpreter = pakfire_arch_find_interpreter(pakfire->arch);
-
-       // No interpreter required
-       if (!interpreter)
-               return 0;
-
-       DEBUG(pakfire, "Mounting interpreter %s for %s\n", interpreter, pakfire->arch);
-
-       // Where to mount this?
-       int r = pakfire_make_path(pakfire, target, interpreter);
-       if (r < 0)
-               return r;
-
-       // Create directory
-       r = pakfire_mkparentdir(target, 0);
-       if (r)
-               return r;
-
-       // Create an empty file
-       FILE* f = fopen(target, "w");
-       if (!f)
-               return 1;
-       fclose(f);
-
-       r = pakfire_mount(pakfire, interpreter, target, NULL, MS_BIND|MS_RDONLY, NULL);
-       if (r)
-               ERROR(pakfire, "Could not mount interpreter %s to %s: %m\n", interpreter, target);
-
-       return r;
-}
-
 static void pakfire_free(struct pakfire* pakfire) {
        struct pakfire_repo* repo = NULL;
        int r;
@@ -765,11 +730,6 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, const char* path,
                goto ERROR;
        }
 
-       // Mount the interpreter (if needed)
-       r = pakfire_mount_interpreter(p);
-       if (r)
-               goto ERROR;
-
        // Make path for private files
        char private_dir[PATH_MAX];
        r = pakfire_make_path(p, private_dir, PAKFIRE_PRIVATE_DIR);