]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Use preprocessor macros for special repo names
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Sep 2021 13:39:26 +0000 (13:39 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Sep 2021 13:39:26 +0000 (13:39 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/archive.c
src/libpakfire/archive.c
src/libpakfire/build.c
src/libpakfire/dist.c
src/libpakfire/include/pakfire/repo.h
src/libpakfire/pakfire.c
src/libpakfire/repo.c
src/libpakfire/request.c
tests/libpakfire/db.c

index 0418fc5af979b43e520a0b1e2dc9c864abeba964..a21722ab34fb2890c46dd32e643cac41711f6825 100644 (file)
@@ -162,14 +162,10 @@ static PyObject* Archive_extract(ArchiveObject* self, PyObject* args) {
 static PyObject* Archive_get_package(ArchiveObject* self) {
        struct pakfire* pakfire = pakfire_archive_get_pakfire(self->archive);
 
-       struct pakfire_repo* repo = pakfire_get_repo(pakfire, "@dummy");
-       if (!repo)
-               return NULL;
-
        struct pakfire_package* package = NULL;
 
        // Make the package
-       int r = pakfire_archive_make_package(self->archive, repo, &package);
+       int r = pakfire_archive_make_package(self->archive, NULL, &package);
        if (r) {
                PyErr_SetFromErrno(PyExc_OSError);
                return NULL;
@@ -180,7 +176,6 @@ static PyObject* Archive_get_package(ArchiveObject* self) {
 
        // Cleanup
        pakfire_package_unref(package);
-       pakfire_repo_unref(repo);
        pakfire_unref(pakfire);
 
        return ret;
index 93f839ff5347b4a552606bcedf6ea93c515e7518..27ed9f1cca66d272effc3c3c743c0c39712d8eed 100644 (file)
@@ -1970,7 +1970,7 @@ PAKFIRE_EXPORT int pakfire_archive_make_package(struct pakfire_archive* archive,
 
        // Use dummy repo if no repository was passed
        if (!repo) {
-               dummy = pakfire_get_repo(archive->pakfire, "@dummy");
+               dummy = pakfire_get_repo(archive->pakfire, PAKFIRE_REPO_DUMMY);
                if (!dummy)
                        return 1;
 
index ed1731f00bc9e1459b6934495ba29e550ec440a6..1eda2e07b5255a65bda12e105a89516d25e9c264 100644 (file)
@@ -450,7 +450,6 @@ static int pakfire_build_package_add_scriptlets(struct pakfire* pakfire, struct
 
 static int pakfire_build_package(struct pakfire* pakfire, struct pakfire_parser* makefile,
                uuid_t* build_id, const char* buildroot, const char* namespace, const char* target) {
-       struct pakfire_repo* repo = NULL;
        struct pakfire_package* pkg = NULL;
        struct pakfire_packager* packager = NULL;
 
@@ -470,13 +469,8 @@ static int pakfire_build_package(struct pakfire* pakfire, struct pakfire_parser*
        if (!arch)
                goto ERROR;
 
-       // Fetch the dummy repository
-       repo = pakfire_get_repo(pakfire, "@dummy");
-       if (!repo)
-               goto ERROR;
-
        // Fetch package from makefile
-       r = pakfire_parser_create_package(makefile, &pkg, repo, namespace, arch);
+       r = pakfire_parser_create_package(makefile, &pkg, NULL, namespace, arch);
        if (r) {
                ERROR(pakfire, "Could not create package from makefile: %m\n");
                goto ERROR;
@@ -522,8 +516,6 @@ static int pakfire_build_package(struct pakfire* pakfire, struct pakfire_parser*
 ERROR:
        if (packager)
                pakfire_packager_unref(packager);
-       if (repo)
-               pakfire_repo_unref(repo);
        if (pkg)
                pakfire_package_unref(pkg);
        if (name)
index dc9fd9f52d4d108d7367927e3ed664dbbc420d30..85edf1418f800b5682c39cb0e984eff4cee4e7a4 100644 (file)
@@ -388,7 +388,7 @@ PAKFIRE_EXPORT int pakfire_dist(struct pakfire* pakfire, const char* path,
        if (r)
                goto ERROR;
 
-       repo = pakfire_get_repo(pakfire, "@dummy");
+       repo = pakfire_get_repo(pakfire, PAKFIRE_REPO_DUMMY);
        if (!repo)
                goto ERROR;
 
index 20d3960aed36ac29636fa9f4826ac8a10341ab74..adf9d26c979291a0c0b718a318590896a2fc72f0 100644 (file)
@@ -101,9 +101,12 @@ int pakfire_repo_compose(struct pakfire* pakfire, const char* path, int flags,
 #include <pakfire/downloader.h>
 #include <pakfire/package.h>
 
+#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_SYSTEM                            "@system"
 
 int pakfire_repo_is_dummy(struct pakfire_repo* repo);
 
index b539357cef0fa990367f6ff554449a2134fa59a1..56e053d60d7ee0f05ef89b3294447c87f7167f69 100644 (file)
@@ -439,7 +439,7 @@ static int pakfire_populate_pool(struct pakfire* pakfire) {
                goto ERROR;
 
        // Create a dummy repository
-       r = pakfire_repo_create(&dummy, pakfire, "@dummy");
+       r = pakfire_repo_create(&dummy, pakfire, PAKFIRE_REPO_DUMMY);
        if (r)
                goto ERROR;
 
@@ -447,7 +447,7 @@ static int pakfire_populate_pool(struct pakfire* pakfire) {
        pakfire_repo_set_enabled(dummy, 0);
 
        // Create the system repository
-       r = pakfire_repo_create(&system, pakfire, "@system");
+       r = pakfire_repo_create(&system, pakfire, PAKFIRE_REPO_SYSTEM);
        if (r)
                goto ERROR;
 
@@ -455,7 +455,7 @@ static int pakfire_populate_pool(struct pakfire* pakfire) {
        pool_set_installed(pool, pakfire_repo_get_repo(system));
 
        // Create the command line repo
-       r = pakfire_repo_create(&commandline, pakfire, "@commandline");
+       r = pakfire_repo_create(&commandline, pakfire, PAKFIRE_REPO_COMMANDLINE);
        if (r)
                goto ERROR;
 
@@ -1352,7 +1352,7 @@ PAKFIRE_EXPORT struct pakfire_repolist* pakfire_get_repos(struct pakfire* pakfir
 
        FOR_REPOS(i, solv_repo) {
                // Skip the dummy repository
-               if (strcmp(solv_repo->name, "@dummy") == 0)
+               if (strcmp(solv_repo->name, PAKFIRE_REPO_DUMMY) == 0)
                        continue;
 
                struct pakfire_repo* repo = pakfire_repo_create_from_repo(pakfire, solv_repo);
index eaa2d1474d1d200b21d73a68ee02a3b2be9d2bb4..642bde7dacbe7a1ca8c7e0f8f906a63d7ce019fc 100644 (file)
@@ -90,7 +90,7 @@ int pakfire_repo_is_dummy(struct pakfire_repo* repo) {
        if (!name)
                return 0;
 
-       return strcmp(name, "@dummy") == 0;
+       return strcmp(name, PAKFIRE_REPO_DUMMY) == 0;
 }
 
 static int pakfire_repo_retrieve(
index 7abe90d8cf7908f0dc76913f30f62f322a71ee7b..489df8523d1c7251d1bac8a75f67b9dfd7ed4d69 100644 (file)
@@ -392,7 +392,7 @@ static int pakfire_request_add_archive(struct pakfire_request* request, int acti
        struct pakfire_package* package = NULL;
        int r;
 
-       struct pakfire_repo* repo = pakfire_get_repo(request->pakfire, "@commandline");
+       struct pakfire_repo* repo = pakfire_get_repo(request->pakfire, PAKFIRE_REPO_COMMANDLINE);
        if (!repo)
                return 1;
 
index 6bcc607693cee1864b272d422006b451ad6ec220..b1327b1c9b16b6fdacb997ecfad727ed943a8a4a 100644 (file)
@@ -83,7 +83,7 @@ static int test_add_package(const struct test* t) {
        struct pakfire_archive* archive = NULL;
        int r = EXIT_FAILURE;
 
-       ASSERT(repo = pakfire_get_repo(t->pakfire, "@dummy"));
+       ASSERT(repo = pakfire_get_repo(t->pakfire, PAKFIRE_REPO_DUMMY));
 
        ASSERT_SUCCESS(pakfire_db_open(&db, t->pakfire, PAKFIRE_DB_READWRITE));