From: Michael Tremer Date: Sun, 29 Jun 2025 12:52:34 +0000 (+0000) Subject: repo: Add context to pakfire_repo_compose X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3ffe366df62cc2b51fb852c3cd6fd2a6dba5bf6d;p=pakfire.git repo: Add context to pakfire_repo_compose Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/repo_compose.c b/src/cli/lib/repo_compose.c index 1039a0bb..b16fd9a5 100644 --- a/src/cli/lib/repo_compose.c +++ b/src/cli/lib/repo_compose.c @@ -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) diff --git a/src/pakfire/repo.c b/src/pakfire/repo.c index aae78484..48281ea2 100644 --- a/src/pakfire/repo.c +++ b/src/pakfire/repo.c @@ -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; } diff --git a/src/pakfire/repo.h b/src/pakfire/repo.h index 2b8787c3..c7e66ceb 100644 --- a/src/pakfire/repo.h +++ b/src/pakfire/repo.h @@ -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" diff --git a/src/pakfire/transaction.c b/src/pakfire/transaction.c index 40881156..e4a8a715 100644 --- a/src/pakfire/transaction.c +++ b/src/pakfire/transaction.c @@ -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); } diff --git a/src/python/root.c b/src/python/root.c index afc3df67..ffeb745a 100644 --- a/src/python/root.c +++ b/src/python/root.c @@ -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); diff --git a/tests/libpakfire/repo.c b/tests/libpakfire/repo.c index 4d03e077..241f3421 100644 --- a/tests/libpakfire/repo.c +++ b/tests/libpakfire/repo.c @@ -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