From: Michael Tremer Date: Mon, 8 Aug 2022 16:23:18 +0000 (+0000) Subject: build: Set default target X-Git-Tag: 0.9.28~570 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a84624bec55efd3bead282351a96258ff4559260;p=pakfire.git build: Set default target Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index addfc6963..ea0c36f15 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -52,6 +52,8 @@ struct pakfire_build { uuid_t id; char _id[UUID_STR_LEN]; + char target[PATH_MAX]; + // cgroup struct pakfire_cgroup* cgroup; @@ -822,6 +824,32 @@ static int pakfire_build_parse_id(struct pakfire_build* build, const char* id) { return 0; } +/* + Sets the default target +*/ +static int pakfire_build_set_default_target(struct pakfire_build* build) { + // Look for the "local" repository + struct pakfire_repo* repo = pakfire_get_repo(build->pakfire, PAKFIRE_REPO_LOCAL); + if (repo) { + const char* target = pakfire_repo_get_path(repo); + if (target) + pakfire_string_set(build->target, target); + + pakfire_repo_unref(repo); + } + + // Default to the current working directory + if (!*build->target) { + char* cwd = getcwd(build->target, sizeof(build->target)); + if (!cwd) { + ERROR(build->pakfire, "getcwd() failed: %m\n"); + return 1; + } + } + + return 0; +} + /* Sets up a new cgroup for this build */ @@ -895,6 +923,11 @@ PAKFIRE_EXPORT int pakfire_build_create(struct pakfire_build** build, if (r) goto ERROR; + // Set target + r = pakfire_build_set_default_target(b); + if (r) + goto ERROR; + // Create cgroup r = pakfire_build_setup_cgroup(b); if (r)