]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Add context to pakfire_repo_compose
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Jun 2025 12:52:34 +0000 (12:52 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Jun 2025 12:52:34 +0000 (12:52 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/repo_compose.c
src/pakfire/repo.c
src/pakfire/repo.h
src/pakfire/transaction.c
src/python/root.c
tests/libpakfire/repo.c

index 1039a0bbd1cd35a5ae35ab4e133edef505bcdfc4..b16fd9a572d9a4151717b24b7cb74edaf501a3a8 100644 (file)
@@ -126,7 +126,8 @@ int cli_repo_compose(void* data, int argc, char* argv[]) {
        }
 
        // Write the repository
-       r = pakfire_repo_compose(root, local_args.path, key, (const char**)local_args.packages);
+       r = pakfire_repo_compose(global_args->ctx, root,
+               local_args.path, key, (const char**)local_args.packages);
 
 ERROR:
        if (key)
index aae78484b1f4a0df0c6ad84a5af19d90644420a8..48281ea2978ae2f6fb8d287e01bc6b8f3b90ff55 100644 (file)
@@ -2551,8 +2551,8 @@ ERROR:
        return r;
 }
 
-int pakfire_repo_compose(pakfire_root* root, const char* path,
-               pakfire_key* key, const char** files) {
+int pakfire_repo_compose(pakfire_ctx* ctx, pakfire_root* root,
+               const char* path, pakfire_key* key, const char** files) {
        pakfire_archive* archive = NULL;
        pakfire_repo* repo = NULL;
        char realpath[PATH_MAX];
@@ -2565,9 +2565,6 @@ int pakfire_repo_compose(pakfire_root* root, const char* path,
                return 1;
        }
 
-       // Fetch context
-       pakfire_ctx* ctx = pakfire_root_get_ctx(root);
-
        // XXX Check if the key is a secret key
 
        size_t num_files = 0;
@@ -2657,8 +2654,6 @@ ERROR:
                pakfire_repo_clear(repo);
                pakfire_repo_unref(repo);
        }
-       if (ctx)
-               pakfire_ctx_unref(ctx);
 
        return r;
 }
index 2b8787c33b8c08cf666e11ff337b1e8de8f17bcd..c7e66ceb4f9533a32bb0dfdea0ba21a79a44f927 100644 (file)
@@ -106,8 +106,8 @@ int pakfire_repo_refresh(pakfire_repo* repo, int force);
 
 int pakfire_repo_write_metadata(pakfire_repo* repo, pakfire_key* key);
 
-int pakfire_repo_compose(pakfire_root* root, const char* path,
-       pakfire_key* key, const char** files);
+int pakfire_repo_compose(pakfire_ctx* ctx, pakfire_root* root,
+       const char* path, pakfire_key* key, const char** files);
 
 #define PAKFIRE_REPO_COMMANDLINE               "@commandline"
 #define PAKFIRE_REPO_DUMMY                             "@dummy"
index 4088115682e72e9b36f07f4e40867b6dc554ae81..e4a8a715d3649c7eb83beeb481be8218ce2b037b 100644 (file)
@@ -2113,5 +2113,5 @@ int pakfire_transaction_compose_repo(pakfire_transaction* transaction,
        files[num] = NULL;
 
        // Create the repository
-       return pakfire_repo_compose(transaction->root, path, key, files);
+       return pakfire_repo_compose(transaction->ctx, transaction->root, path, key, files);
 }
index afc3df67c601fe3ae25d2ad71f255c7d07ed52e9..ffeb745afc9d039dcae6b4dc0c25bc59a4e317bb 100644 (file)
@@ -510,7 +510,8 @@ static PyObject* Root_repo_compose(RootObject* self, PyObject* args, PyObject* k
 
        Py_BEGIN_ALLOW_THREADS
 
-       int r = pakfire_repo_compose(self->root, path, (key) ? key->key : NULL, files);
+       int r = pakfire_repo_compose(self->ctx->ctx, self->root,
+                       path, (key) ? key->key : NULL, files);
        if (r) {
                Py_BLOCK_THREADS
                PyErr_SetFromErrno(PyExc_OSError);
index 4d03e0774a9563efad7b23dcf1774d457f5c9980..241f34216c1a336dc9a7632ee76e5a5ccdd1d094 100644 (file)
@@ -90,7 +90,7 @@ static int test_compose(const struct test* t) {
 
        // Compose the repository
        ASSERT_SUCCESS(
-               pakfire_repo_compose(t->root, path, NULL, files)
+               pakfire_repo_compose(t->ctx, t->root, path, NULL, files)
        );
 
        // Everything passed