}
static int pakfire_job_child(struct pakfire_job* job) {
+ struct pakfire_ctx* ctx = NULL;
struct pakfire* pakfire = NULL;
struct pakfire_build* build = NULL;
char job_id[UUID_STR_LEN];
// Format the job ID as string
uuid_unparse(job->job_id, job_id);
+ // Create a new context
+ r = pakfire_ctx_create(&ctx, NULL);
+ if (r < 0) {
+ CTX_ERROR(job->ctx, "Could not create a new context: %s\n", strerror(-r));
+ goto ERROR;
+ }
+
// Map the configuration
conf = fmemopen(job->conf, strlen(job->conf), "r");
if (!conf) {
- CTX_ERROR(job->ctx, "Could not map the configuration into memory: %m\n");
+ CTX_ERROR(ctx, "Could not map the configuration into memory: %m\n");
r = -errno;
goto ERROR;
}
// Create a new Pakfire instance
- r = pakfire_create(&pakfire, job->ctx, NULL, job->arch, conf, PAKFIRE_FLAGS_BUILD);
+ r = pakfire_create(&pakfire, ctx, NULL, job->arch, conf, PAKFIRE_FLAGS_BUILD);
if (r) {
- CTX_ERROR(job->ctx, "Could not initialize Pakfire: %m\n");
+ CTX_ERROR(ctx, "Could not initialize Pakfire: %m\n");
r = -errno;
goto ERROR;
}
// 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");
+ CTX_ERROR(ctx, "Could not setup the build environment: %m\n");
r = -errno;
goto ERROR;
}
// 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");
+ CTX_ERROR(ctx, "Could not set ccache path: %m\n");
r = -errno;
goto ERROR;
}
pakfire_build_unref(build);
if (pakfire)
pakfire_unref(pakfire);
+ if (ctx)
+ pakfire_ctx_unref(ctx);
if (conf)
fclose(conf);