From d8c8cdc4cc94d1767307888a19e1b08ad8a26c7a Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 31 Oct 2022 15:27:18 +0000 Subject: [PATCH] build: Make the local repository just a regular repository Fixes: #12970 Signed-off-by: Michael Tremer --- contrib/config/distros/ipfire3.conf | 5 ++ src/libpakfire/build.c | 112 +------------------------- src/libpakfire/include/pakfire/repo.h | 2 - 3 files changed, 9 insertions(+), 110 deletions(-) diff --git a/contrib/config/distros/ipfire3.conf b/contrib/config/distros/ipfire3.conf index 3dba68ff5..eeb69b8dc 100644 --- a/contrib/config/distros/ipfire3.conf +++ b/contrib/config/distros/ipfire3.conf @@ -65,3 +65,8 @@ description = IPFire 3 - Unstable Repository baseurl = https://pakfire.ipfire.org/repositories/ipfire3/unstable/%{arch} mirrors = https://pakfire.ipfire.org/distro/ipfire3/repo/unstable/mirrorlist?arch=%{arch} priority = 300 + +[repo:local] +description = IPFire 3 - Locally Built Packages +baseurl = file:///var/lib/pakfire/local/%{distro}/%{version} +priority = 1 diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index fabe5c266..c00940eb4 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -71,9 +71,6 @@ struct pakfire_build { // Jail struct pakfire_jail* jail; - // Local build repo - struct pakfire_repo* repo; - // The result repository struct pakfire_repo* result; @@ -103,51 +100,7 @@ static int pakfire_build_has_flag(struct pakfire_build* build, int flag) { a pakfire instance running inside the chroot. */ static int pakfire_build_enable_repos(struct pakfire_build* build) { - FILE* f = NULL; - char repopath[PATH_MAX]; - int r = 1; - - const char* path = pakfire_repo_get_path(build->repo); - - // Make sure the source directory exists - r = pakfire_mkdir(path, 0700); - if (r && errno != EEXIST) { - ERROR(build->pakfire, "Could not create repository directory %s: %m\n", path); - goto ERROR; - } - - // Bind-mount the repository data read-only - r = pakfire_jail_bind(build->jail, path, path, MS_RDONLY); - if (r) { - ERROR(build->pakfire, "Could not bind-mount the repository at %s: %m\n", path); - goto ERROR; - } - - // Make path for configuration file - r = pakfire_path(build->pakfire, repopath, - "%s", PAKFIRE_CONFIG_DIR "/repos/" PAKFIRE_REPO_LOCAL ".repo"); - if (r) - goto ERROR; - - // Open the repository configuration - f = fopen(repopath, "w"); - if (!f) { - ERROR(build->pakfire, "Could not open %s: %m\n", repopath); - goto ERROR; - } - - // Write repository configuration - r = pakfire_repo_write_config(build->repo, f); - if (r) { - ERROR(build->pakfire, "Could not write repository configuration: %m\n"); - goto ERROR; - } - -ERROR: - if (f) - fclose(f); - - return r; + return 0; } /* @@ -752,9 +705,6 @@ static void pakfire_build_free(struct pakfire_build* build) { pakfire_repo_unref(build->result); } - if (build->repo) - pakfire_repo_unref(build->repo); - if (build->jail) pakfire_jail_unref(build->jail); @@ -797,13 +747,6 @@ static int pakfire_build_parse_id(struct pakfire_build* build, const char* id) { Sets the default target */ static int pakfire_build_set_default_target(struct pakfire_build* build) { - // Look for the "local" repository - if (build->repo) { - const char* target = pakfire_repo_get_path(build->repo); - if (target) - pakfire_string_set(build->target, target); - } - // Default to the current working directory if (!*build->target) { char* cwd = getcwd(build->target, sizeof(build->target)); @@ -948,29 +891,7 @@ static int pakfire_build_setup_ccache(struct pakfire_build* build) { return 0; } -static int pakfire_build_setup_local_repo(struct pakfire_build* build) { - int r; - - // Create a new repository - r = pakfire_repo_create(&build->repo, build->pakfire, PAKFIRE_REPO_LOCAL); - if (r) { - ERROR(build->pakfire, "Could not create repository %s: %m\n", PAKFIRE_REPO_LOCAL); - return r; - } - - // Set description - pakfire_repo_set_description(build->repo, _("Locally Built Packages")); - - // Set path - pakfire_repo_set_baseurl(build->repo, PAKFIRE_REPO_LOCAL_PATH); - - // Set priority - pakfire_repo_set_priority(build->repo, PAKFIRE_REPO_LOCAL_PRIORITY); - - return 0; -} - -static int pakfire_build_setup_result_repo(struct pakfire_build* build) { +static int pakfire_build_setup_repo(struct pakfire_build* build) { char path[PATH_MAX] = "/var/tmp/.pakfire-build-repo.XXXXXX"; char url[PATH_MAX]; int r; @@ -1003,22 +924,6 @@ static int pakfire_build_setup_result_repo(struct pakfire_build* build) { return r; } -static int pakfire_build_setup_repos(struct pakfire_build* build) { - int r; - - // Set up the local repository - r = pakfire_build_setup_local_repo(build); - if (r) - return r; - - // Setup the result repository - r = pakfire_build_setup_result_repo(build); - if (r) - return r; - - return 0; -} - PAKFIRE_EXPORT int pakfire_build_create(struct pakfire_build** build, struct pakfire* pakfire, const char* id, int flags) { int r; @@ -1042,8 +947,8 @@ PAKFIRE_EXPORT int pakfire_build_create(struct pakfire_build** build, if (r) goto ERROR; - // Setup repos - r = pakfire_build_setup_repos(b); + // Setup repo + r = pakfire_build_setup_repo(b); if (r) goto ERROR; @@ -1173,15 +1078,6 @@ static int pakfire_build_init(struct pakfire_build* build) { return 0; } - // Refresh the local repository - if (build->repo) { - r = pakfire_repo_refresh(build->repo, 0); - if (r) { - ERROR(build->pakfire, "Could not refresh the local repository: %m\n"); - return 1; - } - } - // Compose path for snapshot r = pakfire_cache_path(build->pakfire, path, "%s", "snapshot.tar.zst"); if (r) { diff --git a/src/libpakfire/include/pakfire/repo.h b/src/libpakfire/include/pakfire/repo.h index fa47ce337..1648b0fad 100644 --- a/src/libpakfire/include/pakfire/repo.h +++ b/src/libpakfire/include/pakfire/repo.h @@ -104,8 +104,6 @@ int pakfire_repo_compose(struct pakfire* pakfire, const char* path, int flags, #define PAKFIRE_REPO_COMMANDLINE "@commandline" #define PAKFIRE_REPO_DUMMY "@dummy" #define PAKFIRE_REPO_LOCAL "local" -#define PAKFIRE_REPO_LOCAL_PATH "file://" PAKFIRE_PRIVATE_DIR "/local/%{distro}/%{version}" -#define PAKFIRE_REPO_LOCAL_PRIORITY 1000 #define PAKFIRE_REPO_RESULT "@build" #define PAKFIRE_REPO_SYSTEM "@system" -- 2.39.5