#include <systemd/sd-event.h>
#include <pakfire/build.h>
+#include <pakfire/config.h>
#include <pakfire/constants.h>
#include <pakfire/ctx.h>
#include <pakfire/daemon.h>
char ccache_path[PATH_MAX];
// Configuration
- char conf[4096];
+ struct pakfire_config* config;
// PID File Descriptor
int pidfd;
return -EINVAL;
}
- // Store the configuration
- r = pakfire_string_set(job->conf, json_object_get_string(o));
- if (r) {
- ERROR(job->ctx, "Could not store the configuration: %m\n");
+ // Parse the configuration
+ r = pakfire_config_parse(job->config, json_object_get_string(o), -1);
+ if (r < 0) {
+ ERROR(job->ctx, "Could not parse the configuration: %s\n", strerror(-r));
return r;
}
if (job->log.stderr)
pakfire_log_stream_unref(job->log.stderr);
+ if (job->config)
+ pakfire_config_unref(job->config);
if (job->loop)
sd_event_unref(job->loop);
if (job->daemon)
static int pakfire_job_child(struct pakfire_job* job) {
struct pakfire_ctx* ctx = NULL;
- struct pakfire_config* config = NULL;
struct pakfire_build* build = NULL;
char job_id[UUID_STR_LEN];
int build_flags = 0;
// Setup logging
pakfire_ctx_set_log_callback(ctx, pakfire_job_log, job);
- // Create a new configuration object
- r = pakfire_config_create(&config);
- if (r < 0)
- goto ERROR;
-
- // Parse the configuration
- r = pakfire_config_parse(config, job->conf, -1);
- if (r < 0) {
- ERROR(ctx, "Could not parse configuration: %s\n", strerror(-r));
- goto ERROR;
- }
-
// Disable the ccache
if (!(job->flags & PAKFIRE_JOB_CCACHE))
build_flags |= PAKFIRE_BUILD_DISABLE_CCACHE;
// Create a new build environment
- r = pakfire_build_create(&build, ctx, config, job->arch, job_id, build_flags);
+ r = pakfire_build_create(&build, ctx, job->config, job->arch, job_id, build_flags);
if (r) {
ERROR(ctx, "Could not setup the build environment: %m\n");
r = -errno;
ERROR:
if (build)
pakfire_build_unref(build);
- if (config)
- pakfire_config_unref(config);
if (ctx)
pakfire_ctx_unref(ctx);
// Initialize the PID file descriptor
j->pidfd = -1;
+ // Initialize the configuration
+ r = pakfire_config_create(&j->config);
+ if (r < 0)
+ goto ERROR;
+
// Allocate the log buffer
r = pakfire_log_buffer_create(&j->log.buffer, j->ctx, 1024);
if (r < 0)