]> git.ipfire.org Git - pakfire.git/commitdiff
build: Make the local repository just a regular repository
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 31 Oct 2022 15:27:18 +0000 (15:27 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 31 Oct 2022 15:31:11 +0000 (15:31 +0000)
Fixes: #12970
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
contrib/config/distros/ipfire3.conf
src/libpakfire/build.c
src/libpakfire/include/pakfire/repo.h

index 3dba68ff55d1a3da500dd36495f5c7c53ba2a1d2..eeb69b8dc13311aa4b0b4818e3f75bd68f52e677 100644 (file)
@@ -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
index fabe5c26666343c7dd970c925c733f3ac801fbda..c00940eb45e495f9d62879c7f9428fe07e666fb3 100644 (file)
@@ -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) {
index fa47ce3374e66513b8f2a3ddb1fb61bc3c1644df..1648b0fad31e39747ae00c0ef2a8ed0f8a9a117d 100644 (file)
@@ -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"