]> git.ipfire.org Git - pakfire.git/commitdiff
build: Replace pakfire_execute_script with new jail functions
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Aug 2022 09:32:17 +0000 (09:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Aug 2022 09:32:17 +0000 (09:32 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c

index c4094f49c4237fb70970764ed2f214784afa36aa..91f11cd11272838ebaceafcea7c4c5b82540035e 100644 (file)
@@ -621,6 +621,7 @@ ERROR:
 }
 
 static int pakfire_build_stage(struct pakfire* pakfire, struct pakfire_parser* makefile, const char* stage) {
+       struct pakfire_jail* jail = NULL;
        char template[1024];
 
        // Prepare template for this stage
@@ -640,12 +641,27 @@ static int pakfire_build_stage(struct pakfire* pakfire, struct pakfire_parser* m
 
        INFO(pakfire, "Running build stage '%s'\n", stage);
 
-       r = pakfire_execute_script(pakfire, script, strlen(script), NULL, envp, 0, NULL, NULL);
+       // Create a new jail
+       jail = pakfire_build_make_jail(pakfire);
+       if (!jail)
+               goto ERROR;
+
+       // Import environment
+       r = pakfire_jail_import_env(jail, (const char**)envp);
+       if (r) {
+               ERROR(pakfire, "Could not import environment: %m\n");
+               goto ERROR;
+       }
+
+       // Run the script
+       r = pakfire_jail_exec_script(jail, script, strlen(script), NULL);
        if (r) {
                ERROR(pakfire, "Build stage '%s' failed with status %d\n", stage, r);
        }
 
 ERROR:
+       if (jail)
+               pakfire_jail_unref(jail);
        if (envp) {
                for (char** e = envp; *e; e++)
                        free(*e);