#include <pakfire/execute.h>
#include <pakfire/dist.h>
#include <pakfire/file.h>
+#include <pakfire/jail.h>
#include <pakfire/logging.h>
#include <pakfire/mount.h>
#include <pakfire/package.h>
"\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* pakfire, const char* filename, const char* args[],
pakfire_execute_logging_callback logging_callback, void* data) {
+ struct pakfire_jail* jail = NULL;
char* script = NULL;
size_t size = 0;
char path[PATH_MAX];
goto ERROR;
}
- // Execute it
- r = pakfire_execute_script(pakfire, script, size, args, NULL, 0, logging_callback, data);
+ // Create a new jail
+ jail = pakfire_build_make_jail(pakfire);
+ if (!jail)
+ goto ERROR;
+
+ // Configure logging
+ if (logging_callback) {
+ r = pakfire_jail_set_log_callback(jail, logging_callback, data);
+ if (r)
+ goto ERROR;
+ }
+
+ // Execute the script
+ r = pakfire_jail_exec_script(jail, script, size, args);
if (r) {
ERROR(pakfire, "Script '%s' failed with status %d\n", filename, r);
}
ERROR:
+ if (jail)
+ pakfire_jail_unref(jail);
if (script)
free(script);