"\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;
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
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);