From: Michael Tremer Date: Tue, 28 Sep 2021 13:39:26 +0000 (+0000) Subject: repo: Use preprocessor macros for special repo names X-Git-Tag: 0.9.28~919 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ebd55e2058b9e57fb5df190a81966256c92015d;p=pakfire.git repo: Use preprocessor macros for special repo names Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/archive.c b/src/_pakfire/archive.c index 0418fc5af..a21722ab3 100644 --- a/src/_pakfire/archive.c +++ b/src/_pakfire/archive.c @@ -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; diff --git a/src/libpakfire/archive.c b/src/libpakfire/archive.c index 93f839ff5..27ed9f1cc 100644 --- a/src/libpakfire/archive.c +++ b/src/libpakfire/archive.c @@ -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; diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index ed1731f00..1eda2e07b 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -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) diff --git a/src/libpakfire/dist.c b/src/libpakfire/dist.c index dc9fd9f52..85edf1418 100644 --- a/src/libpakfire/dist.c +++ b/src/libpakfire/dist.c @@ -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; diff --git a/src/libpakfire/include/pakfire/repo.h b/src/libpakfire/include/pakfire/repo.h index 20d3960ae..adf9d26c9 100644 --- a/src/libpakfire/include/pakfire/repo.h +++ b/src/libpakfire/include/pakfire/repo.h @@ -101,9 +101,12 @@ int pakfire_repo_compose(struct pakfire* pakfire, const char* path, int flags, #include #include +#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); diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index b539357ce..56e053d60 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -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); diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index eaa2d1474..642bde7da 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -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( diff --git a/src/libpakfire/request.c b/src/libpakfire/request.c index 7abe90d8c..489df8523 100644 --- a/src/libpakfire/request.c +++ b/src/libpakfire/request.c @@ -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; diff --git a/tests/libpakfire/db.c b/tests/libpakfire/db.c index 6bcc60769..b1327b1c9 100644 --- a/tests/libpakfire/db.c +++ b/tests/libpakfire/db.c @@ -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));