#include <systemd/sd-event.h>
+#include <pakfire/build.h>
#include <pakfire/constants.h>
#include <pakfire/ctx.h>
#include <pakfire/daemon.h>
static int pakfire_job_child(struct pakfire_job* job) {
struct pakfire* pakfire = NULL;
+ struct pakfire_build* build = NULL;
+ char job_id[UUID_STR_LEN];
FILE* conf = NULL;
int r;
CTX_DEBUG(job->ctx, "Launched job child as PID %d\n", pid);
+ // Format the job ID as string
+ uuid_unparse(job->job_id, job_id);
+
// Map the configuration
conf = fmemopen(job->conf, strlen(job->conf), "r");
if (!conf) {
goto ERROR;
}
- // XXX TODO
- for (unsigned int i = 0; i < 5; i++) {
- printf("WORK\n");
- sleep(1);
+ int build_flags =
+ PAKFIRE_BUILD_DISABLE_SNAPSHOT |
+ (job->flags & PAKFIRE_JOB_CCACHE) ? 0 : PAKFIRE_BUILD_DISABLE_CCACHE;
+
+ // Create a new build environment
+ r = pakfire_build_create(&build, pakfire, job_id, build_flags);
+ if (r) {
+ CTX_ERROR(job->ctx, "Could not setup the build environment: %m\n");
+ r = -errno;
+ goto ERROR;
+ }
+
+ // Set the ccache path (if set)
+ if (job->flags & PAKFIRE_JOB_CCACHE) {
+ if (*job->ccache_path) {
+ // XXX THIS NEEDS TO BE PREFIXED WITH THE BASE PATH
+ r = pakfire_build_set_ccache_path(build, job->ccache_path);
+ if (r) {
+ CTX_ERROR(job->ctx, "Could not set ccache path: %m\n");
+ r = -errno;
+ goto ERROR;
+ }
+ }
}
+ // XXX need to set target
+
+ // Run the build
+ r = pakfire_build_exec(build, job->pkg);
+
ERROR:
+ if (build)
+ pakfire_build_unref(build);
if (pakfire)
pakfire_unref(pakfire);
if (conf)