]> git.ipfire.org Git - pakfire.git/commitdiff
_pakfire: archive: Allow opening packages in any repository
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 May 2023 13:54:24 +0000 (13:54 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 May 2023 13:54:24 +0000 (13:54 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/archive.c

index 348334ba7ff76300083c22aaf95c74a97265c6bd..5c70ec749ebfc5d3561b049b6a5729e8c9c5b855 100644 (file)
@@ -32,6 +32,7 @@
 #include "errors.h"
 #include "key.h"
 #include "package.h"
+#include "repo.h"
 #include "util.h"
 
 PyObject* new_archive(PyTypeObject* type, struct pakfire_archive* archive) {
@@ -146,13 +147,17 @@ static PyObject* Archive_extract(ArchiveObject* self) {
        Py_RETURN_NONE;
 }
 
-static PyObject* Archive_get_package(ArchiveObject* self) {
+static PyObject* Archive_get_package(ArchiveObject* self, PyObject* args) {
        struct pakfire_package* package = NULL;
+       RepoObject* repo = NULL;
+
+       if (!PyArg_ParseTuple(args, "|O!", &RepoType, &repo))
+               return NULL;
 
        Py_BEGIN_ALLOW_THREADS
 
        // Make the package
-       int r = pakfire_archive_make_package(self->archive, NULL, &package);
+       int r = pakfire_archive_make_package(self->archive, (repo) ? repo->repo : NULL, &package);
        if (r) {
                Py_BLOCK_THREADS
                PyErr_SetFromErrno(PyExc_OSError);
@@ -212,7 +217,7 @@ static struct PyMethodDef Archive_methods[] = {
        {
                "get_package",
                (PyCFunction)Archive_get_package,
-               METH_NOARGS,
+               METH_VARARGS,
                NULL
        },
        {