From: Michael Tremer Date: Sat, 5 Oct 2024 10:49:56 +0000 (+0000) Subject: job: Create scaffolding to run a build X-Git-Tag: 0.9.30~1165 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d6ddde5a1f80bdae52982653003aa72614f6327;p=pakfire.git job: Create scaffolding to run a build Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/job.c b/src/libpakfire/job.c index 7151ba7df..9e5e0a929 100644 --- a/src/libpakfire/job.c +++ b/src/libpakfire/job.c @@ -28,6 +28,7 @@ #include +#include #include #include #include @@ -276,6 +277,8 @@ static int pakfire_job_parent(struct pakfire_job* job) { 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; @@ -284,6 +287,9 @@ static int pakfire_job_child(struct pakfire_job* job) { 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) { @@ -300,13 +306,39 @@ static int pakfire_job_child(struct pakfire_job* job) { 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)