]> git.ipfire.org Git - pakfire.git/commitdiff
build: Use main jail to build stages
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Aug 2022 17:22:54 +0000 (17:22 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Aug 2022 17:22:54 +0000 (17:22 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c

index fc1264149d5c3372229f0612a267675dee65fa15..f09962e0c16ceefd0f1acb9f66ea3b73e494e526 100644 (file)
@@ -78,29 +78,6 @@ static const char* stages[] = {
        "\n" \
        "exit 0\n"
 
-/*
-       This function creates a new jail which is pre-configured for a build job.
-
-       TODO Add resource limits
-*/
-static struct pakfire_jail* pakfire_build_make_jail(struct pakfire* pakfire) {
-       struct pakfire_jail* jail = NULL;
-       int r;
-
-       // Create a new jail
-       r = pakfire_jail_create(&jail, pakfire, 0);
-       if (r)
-               goto ERROR;
-
-       return jail;
-
-ERROR:
-       if (jail)
-               pakfire_jail_unref(jail);
-
-       return NULL;
-}
-
 static int pakfire_build_run_script(struct pakfire_build* build, const char* filename,
                const char* args[], char*** output) {
        char* script = NULL;
@@ -626,7 +603,6 @@ ERROR:
 
 static int pakfire_build_stage(struct pakfire_build* build,
                struct pakfire_parser* makefile, const char* stage) {
-       struct pakfire_jail* jail = NULL;
        char template[1024];
 
        // Prepare template for this stage
@@ -647,27 +623,21 @@ static int pakfire_build_stage(struct pakfire_build* build,
 
        INFO(build->pakfire, "Running build stage '%s'\n", stage);
 
-       // Create a new jail
-       jail = pakfire_build_make_jail(build->pakfire);
-       if (!jail)
-               goto ERROR;
-
        // Import environment
-       r = pakfire_jail_import_env(jail, (const char**)envp);
+       // XXX is this a good idea?
+       r = pakfire_jail_import_env(build->jail, (const char**)envp);
        if (r) {
                ERROR(build->pakfire, "Could not import environment: %m\n");
                goto ERROR;
        }
 
        // Run the script
-       r = pakfire_jail_exec_script(jail, script, strlen(script), NULL, NULL);
+       r = pakfire_jail_exec_script(build->jail, script, strlen(script), NULL, NULL);
        if (r) {
                ERROR(build->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);