]> git.ipfire.org Git - pakfire.git/commitdiff
pakfire: Always create a dummy repository
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 29 Apr 2021 11:08:49 +0000 (11:08 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 29 Apr 2021 11:08:49 +0000 (11:08 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/archive.c
src/libpakfire/archive.c
src/libpakfire/dist.c
src/libpakfire/pakfire.c
tests/libpakfire/db.c

index 3c6bdc0d1c084750a713d10f3f7d3dfcfe8d4f6b..c10d4117d8303783cf99425c3771c7d7b939ff06 100644 (file)
@@ -146,7 +146,7 @@ static PyObject* Archive_extract(ArchiveObject* self, PyObject* args) {
 static PyObject* Archive_get_package(ArchiveObject* self) {
        Pakfire pakfire = pakfire_archive_get_pakfire(self->archive);
 
-       PakfireRepo repo = pakfire_repo_create(pakfire, "@dummy");
+       PakfireRepo repo = pakfire_get_repo(pakfire, "@dummy");
        if (!repo)
                return NULL;
 
index b242b0a8262bccfe47d9e91b49a9d5d598b42038..0bdc45df2e6bbab374c5d9944017dc0a53174372 100644 (file)
@@ -757,7 +757,9 @@ ERROR:
 PAKFIRE_EXPORT char* pakfire_archive_extraction_path(PakfireArchive archive, const char* target) {
        char prefix[PATH_MAX];
 
-       PakfireRepo repo = pakfire_repo_create(archive->pakfire, "@dummy");
+       PakfireRepo repo = pakfire_get_repo(archive->pakfire, "@dummy");
+       if (!repo)
+               return NULL;
 
        // Read package metadata
        PakfirePackage pkg = pakfire_archive_make_package(archive, repo);
index 94058d22b87c3f0a8e685fe3f0440560b7e863b6..595ffe12b367939ee87a990514097c48820ff3d4 100644 (file)
@@ -307,7 +307,7 @@ PAKFIRE_EXPORT int pakfire_dist(Pakfire pakfire, const char* path, const char* t
                return r;
        }
 
-       PakfireRepo repo = pakfire_repo_create(pakfire, "@dummy");
+       PakfireRepo repo = pakfire_get_repo(pakfire, "@dummy");
        if (!repo)
                goto ERROR;
 
index f8e5931dd7de467caf128826a5a1926d5a1b1ee9..5427f787aee709644b8e2a3a3923b4738df5d267 100644 (file)
@@ -331,6 +331,7 @@ static void pool_log(Pool* pool, void* data, int type, const char* s) {
 static int pakfire_populate_pool(Pakfire pakfire) {
        struct pakfire_db* db;
        PakfireRepo repo = NULL;
+       PakfireRepo dummy = NULL;
        int r;
 
        // Initialize the pool
@@ -356,6 +357,14 @@ static int pakfire_populate_pool(Pakfire pakfire) {
        if (r)
                goto ERROR;
 
+       // Create a dummy repository
+       dummy = pakfire_repo_create(pakfire, "@dummy");
+       if (!dummy)
+               goto ERROR;
+
+       // Disable the repository
+       pakfire_repo_set_enabled(dummy, 0);
+
        // Create the system repository
        repo = pakfire_repo_create(pakfire, "@system");
        if (!repo)
@@ -370,12 +379,12 @@ static int pakfire_populate_pool(Pakfire pakfire) {
                goto ERROR;
 
 ERROR:
-       // Cleanup
        if (db)
                pakfire_db_unref(db);
-
        if (repo)
                pakfire_repo_unref(repo);
+       if (dummy)
+               pakfire_repo_unref(dummy);
 
        return r;
 }
@@ -1013,6 +1022,10 @@ PAKFIRE_EXPORT struct pakfire_repolist* pakfire_get_repos(Pakfire pakfire) {
        int i;
 
        FOR_REPOS(i, solv_repo) {
+               // Skip the dummy repository
+               if (strcmp(solv_repo->name, "@dummy") == 0)
+                       continue;
+
                PakfireRepo repo = pakfire_repo_create_from_repo(pakfire, solv_repo);
                if (!repo) {
                        r = 1;
index d196d7c5949ed88e057300d6daaeb02c6ea9dbae..929f58017f8bd6540118154d648f23d0fbc3c848 100644 (file)
@@ -65,7 +65,7 @@ static int test_check(const struct test* t) {
 static int test_add_package(const struct test* t) {
        struct pakfire_db* db;
 
-       PakfireRepo repo = pakfire_repo_create(t->pakfire, "@dummy");
+       PakfireRepo repo = pakfire_get_repo(t->pakfire, "@dummy");
        ASSERT(repo);
 
        int r = pakfire_db_open(&db, t->pakfire, PAKFIRE_DB_READWRITE);