]> git.ipfire.org Git - pakfire.git/commitdiff
python: Rename Pakfire() to Root()
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Jun 2025 12:35:24 +0000 (12:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 29 Jun 2025 12:35:24 +0000 (12:35 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
21 files changed:
Makefile.am
src/python/archive.c
src/python/file.c
src/python/key.c
src/python/package.c
src/python/package.h
src/python/pakfiremodule.c
src/python/repo.c
src/python/repo.h
src/python/root.c [moved from src/python/pakfire.c with 86% similarity]
src/python/root.h [moved from src/python/pakfire.h with 91% similarity]
src/python/transaction.c
tests/python/archive.py
tests/python/ctx.py
tests/python/dist.py
tests/python/execute.py
tests/python/keys.py
tests/python/main.py
tests/python/package.py
tests/python/tests.py
tests/python/transaction.py

index e9da5ef443c84034a66a0314c1541cf7baa8caab..b55aeb60bc1e51e8d63b3b56f9d470eb7f71abd3 100644 (file)
@@ -117,12 +117,12 @@ pakfire_la_SOURCES = \
        src/python/key.h \
        src/python/package.c \
        src/python/package.h \
-       src/python/pakfire.c \
-       src/python/pakfire.h \
        src/python/problem.c \
        src/python/problem.h \
        src/python/repo.c \
        src/python/repo.h \
+       src/python/root.c \
+       src/python/root.h \
        src/python/solution.c \
        src/python/solution.h \
        src/python/transaction.c \
index 93556309e302dd1929f7799050d52882712e20a0..03069334ce07aead800371f1bbbe5344c2ce7b79 100644 (file)
@@ -33,6 +33,7 @@
 #include "key.h"
 #include "package.h"
 #include "repo.h"
+#include "root.h"
 #include "util.h"
 
 PyObject* new_archive(PyTypeObject* type, pakfire_archive* archive) {
@@ -60,13 +61,13 @@ static void Archive_dealloc(ArchiveObject* self) {
 }
 
 static int Archive_init(ArchiveObject* self, PyObject* args, PyObject* kwds) {
-       PakfireObject* pakfire = NULL;
+       RootObject* root = NULL;
        const char* filename = NULL;
 
-       if (!PyArg_ParseTuple(args, "O!s", &PakfireType, &pakfire, &filename))
+       if (!PyArg_ParseTuple(args, "O!s", &RootType, &root, &filename))
                return -1;
 
-       errno = -pakfire_archive_open(&self->archive, pakfire->root, filename);
+       errno = -pakfire_archive_open(&self->archive, root->root, filename);
        if (errno) {
                PyErr_SetFromErrno(PyExc_OSError);
                return -1;
index 131df7667f3cd62805386422b784f9d8e2ff8fb9..ac74cf08549ee47a8e71d29bd058e03e7536018d 100644 (file)
@@ -25,7 +25,7 @@
 #include <pakfire/file.h>
 
 #include "file.h"
-#include "pakfire.h"
+#include "root.h"
 #include "util.h"
 
 PyObject* new_file(PyTypeObject* type, pakfire_file* file) {
index 08ab8f6a2d74fb4d266ded593c00048c831e61a1..a604a3a976a5f923f79a6ce2793d3aebdd21e4b3 100644 (file)
@@ -25,7 +25,7 @@
 #include <pakfire/util.h>
 
 #include "key.h"
-#include "pakfire.h"
+#include "root.h"
 #include "util.h"
 
 PyObject* new_key(PyTypeObject* type, pakfire_key* key) {
index 044cc0b4648bac9269d7246abc677555ea21e659..9490cdfbe01bea5e247d950715592c76df159ac8 100644 (file)
@@ -31,8 +31,8 @@
 
 #include "errors.h"
 #include "package.h"
-#include "pakfire.h"
 #include "repo.h"
+#include "root.h"
 #include "util.h"
 
 PyObject* new_package(PyTypeObject* type, pakfire_package* pkg) {
@@ -61,7 +61,7 @@ static void Package_dealloc(PackageObject* self) {
 }
 
 static int Package_init(PackageObject* self, PyObject* args, PyObject* kwds) {
-       PakfireObject* pakfire = NULL;
+       RootObject* root = NULL;
        RepoObject* repo = NULL;
        const char* name = NULL;
        const char* evr = NULL;
@@ -69,11 +69,11 @@ static int Package_init(PackageObject* self, PyObject* args, PyObject* kwds) {
        int r;
 
        if (!PyArg_ParseTuple(args, "O!O!sss",
-                       &PakfireType, &pakfire, &RepoType, &repo, &name, &evr, &arch))
+                       &RootType, &root, &RepoType, &repo, &name, &evr, &arch))
                return -1;
 
        // Create the package object
-       r = pakfire_package_create(&self->package, pakfire->root, repo->repo, name, evr, arch);
+       r = pakfire_package_create(&self->package, root->root, repo->repo, name, evr, arch);
        if (r < 0) {
                errno = -r;
                PyErr_SetFromErrno(PyExc_OSError);
index 2926e23e7e94704ba9d6cbbd58491b2315d076f7..e1c9f55ab3cdb0cabc0346519520026e27c36e02 100644 (file)
 
 #include <Python.h>
 
-#include <pakfire/ctx.h>
 #include <pakfire/package.h>
 
-#include "pakfire.h"
-
 typedef struct {
        PyObject_HEAD
        pakfire_package* package;
index ebd0eb05527ef69da7bc614ffc882a72a42b5a5a..0fa057011859c51740cc2258f77debddc634d7d6 100644 (file)
@@ -31,9 +31,9 @@
 #include "file.h"
 #include "key.h"
 #include "package.h"
-#include "pakfire.h"
 #include "problem.h"
 #include "repo.h"
+#include "root.h"
 #include "solution.h"
 #include "transaction.h"
 #include "util.h"
@@ -121,13 +121,6 @@ PyMODINIT_FUNC PyInit_pakfire(void) {
        Py_INCREF(PyExc_DependencyError);
        PyModule_AddObject(module, "DependencyError", PyExc_DependencyError);
 
-       // Pakfire
-       if (PyType_Ready(&PakfireType) < 0)
-               return NULL;
-
-       Py_INCREF(&PakfireType);
-       PyModule_AddObject(module, "Pakfire", (PyObject *)&PakfireType);
-
        // Archive
        if (PyType_Ready(&ArchiveType) < 0)
                return NULL;
@@ -183,6 +176,13 @@ PyMODINIT_FUNC PyInit_pakfire(void) {
        Py_INCREF(&RepoType);
        PyModule_AddObject(module, "Repo", (PyObject *)&RepoType);
 
+       // Root
+       if (PyType_Ready(&RootType) < 0)
+               return NULL;
+
+       Py_INCREF(&RootType);
+       PyModule_AddObject(module, "Root", (PyObject *)&RootType);
+
        // Solution
        if (PyType_Ready(&SolutionType) < 0)
                return NULL;
index 985399ab6b1282413793c5152419f2957af29cde..bdae582db47a77982d15ac34356a9d00b2f50a9b 100644 (file)
@@ -29,6 +29,7 @@
 #include "key.h"
 #include "package.h"
 #include "repo.h"
+#include "root.h"
 
 PyObject* new_repo(PyTypeObject* type, pakfire_repo* repo) {
        RepoObject* self = (RepoObject *)type->tp_alloc(type, 0);
@@ -56,15 +57,15 @@ static void Repo_dealloc(RepoObject* self) {
 }
 
 static int Repo_init(RepoObject* self, PyObject* args, PyObject* kwds) {
-       PakfireObject* pakfire;
+       RootObject* root = NULL;
        const char* name;
        int clean = 0;
 
-       if (!PyArg_ParseTuple(args, "O!s|i", &PakfireType, &pakfire, &name, &clean))
+       if (!PyArg_ParseTuple(args, "O!s|i", &RootType, &root, &name, &clean))
                return -1;
 
        // Create a new repository
-       int r = pakfire_repo_create(&self->repo, pakfire->root, name);
+       int r = pakfire_repo_create(&self->repo, root->root, name);
        if (r) {
                PyErr_SetFromErrno(PyExc_OSError);
                return -1;
index 161cbb8e74ea5aff25a5a403eb46e600a181a5dd..b36488ade99621d9129e6e26584707de9d99c042 100644 (file)
@@ -25,8 +25,6 @@
 
 #include <pakfire/repo.h>
 
-#include "pakfire.h"
-
 typedef struct {
     PyObject_HEAD
     pakfire_repo* repo;
similarity index 86%
rename from src/python/pakfire.c
rename to src/python/root.c
index 7ffa451da23e29a7e693b8dfe01225d23d7be3d2..afc3df67c601fe3ae25d2ad71f255c7d07ed52e9 100644 (file)
 #include "ctx.h"
 #include "errors.h"
 #include "key.h"
-#include "pakfire.h"
 #include "repo.h"
+#include "root.h"
 #include "util.h"
 
-static PyObject* Pakfire_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
-       PakfireObject* self = (PakfireObject *)type->tp_alloc(type, 0);
+static PyObject* Root_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
+       RootObject* self = (RootObject *)type->tp_alloc(type, 0);
        if (self) {
                self->ctx = NULL;
                self->root = NULL;
@@ -58,7 +58,7 @@ static PyObject* Pakfire_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
        return (PyObject *)self;
 }
 
-static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) {
+static int Root_init(RootObject* self, PyObject* args, PyObject* kwds) {
        const char* kwlist[] = { "ctx", "path", "arch", "config", "stub", NULL };
        pakfire_config* c = NULL;
        const char* config = NULL;
@@ -120,7 +120,7 @@ ERROR:
        return r;
 }
 
-static void Pakfire_dealloc(PakfireObject* self) {
+static void Root_dealloc(RootObject* self) {
        Py_BEGIN_ALLOW_THREADS
 
        if (self->root)
@@ -133,26 +133,26 @@ static void Pakfire_dealloc(PakfireObject* self) {
        Py_TYPE(self)->tp_free((PyObject *)self);
 }
 
-static PyObject* Pakfire_repr(PakfireObject* self) {
+static PyObject* Root_repr(RootObject* self) {
        const char* path = pakfire_root_get_path(self->root);
        const char* arch = pakfire_root_get_arch(self->root);
 
-       return PyUnicode_FromFormat("<_pakfire.Pakfire %s (%s)>", path, arch);
+       return PyUnicode_FromFormat("<_pakfire.Root %s (%s)>", path, arch);
 }
 
-static PyObject* Pakfire_get_path(PakfireObject* self) {
+static PyObject* Root_get_path(RootObject* self) {
        const char* path = pakfire_root_get_path(self->root);
 
        return PyUnicode_FromString(path);
 }
 
-static PyObject* Pakfire_get_arch(PakfireObject* self) {
+static PyObject* Root_get_arch(RootObject* self) {
        const char* arch = pakfire_root_get_arch(self->root);
 
        return PyUnicode_FromString(arch);
 }
 
-static PyObject* Pakfire_get_repo(PakfireObject* self, PyObject* args) {
+static PyObject* Root_get_repo(RootObject* self, PyObject* args) {
        const char* name = NULL;
 
        if (!PyArg_ParseTuple(args, "s", &name))
@@ -171,7 +171,7 @@ static PyObject* Pakfire_get_repo(PakfireObject* self, PyObject* args) {
 /*
        XXX This could be moved out of here as this no longer depends on Pakfire
 */
-static PyObject* Pakfire_generate_key(PakfireObject* self, PyObject* args, PyObject* kwds) {
+static PyObject* Root_generate_key(RootObject* self, PyObject* args, PyObject* kwds) {
        const char* kwlist[] = { "algorithm", "comment", NULL };
        pakfire_key* key = NULL;
        pakfire_key_algo_t algo = PAKFIRE_KEY_ALGO_NULL;
@@ -195,7 +195,7 @@ static PyObject* Pakfire_generate_key(PakfireObject* self, PyObject* args, PyObj
 /*
        XXX This could be moved out of here as this no longer depends on Pakfire
 */
-static PyObject* Pakfire_import_key(PakfireObject* self, PyObject* args) {
+static PyObject* Root_import_key(RootObject* self, PyObject* args) {
        pakfire_key* key = NULL;
        PyObject* object = NULL;
        char* data = NULL;
@@ -232,7 +232,7 @@ ERROR:
        return object;
 }
 
-static PyObject* Pakfire_whatprovides(PakfireObject* self, PyObject* args) {
+static PyObject* Root_whatprovides(RootObject* self, PyObject* args) {
        const char* provides = NULL;
        pakfire_packagelist* list = NULL;
        PyObject* ret = NULL;
@@ -266,7 +266,7 @@ ERROR:
        return ret;
 }
 
-static PyObject* Pakfire_whatrequires(PakfireObject* self, PyObject* args) {
+static PyObject* Root_whatrequires(RootObject* self, PyObject* args) {
        pakfire_packagelist* list = NULL;
        const char* requires = NULL;
        PyObject* ret = NULL;
@@ -306,7 +306,7 @@ ERROR:
        return ret;
 }
 
-static PyObject* Pakfire_search(PakfireObject* self, PyObject* args, PyObject* kwds) {
+static PyObject* Root_search(RootObject* self, PyObject* args, PyObject* kwds) {
        const char* kwlist[] = { "pattern", "name_only", NULL };
        pakfire_packagelist* list = NULL;
        const char* pattern = NULL;
@@ -345,7 +345,7 @@ ERROR:
        return ret;
 }
 
-static PyObject* Pakfire_version_compare(PakfireObject* self, PyObject* args) {
+static PyObject* Root_version_compare(RootObject* self, PyObject* args) {
        const char* evr1 = NULL;
        const char* evr2 = NULL;
 
@@ -357,7 +357,7 @@ static PyObject* Pakfire_version_compare(PakfireObject* self, PyObject* args) {
        return PyLong_FromLong(cmp);
 }
 
-static PyObject* Pakfire_dist(PakfireObject* self, PyObject* args) {
+static PyObject* Root_dist(RootObject* self, PyObject* args) {
        pakfire_archive* archive = NULL;
        const char* path = NULL;
        PyObject* ret = NULL;
@@ -387,7 +387,7 @@ static PyObject* Pakfire_dist(PakfireObject* self, PyObject* args) {
        return ret;
 }
 
-static PyObject* Pakfire_get_repos(PakfireObject* self) {
+static PyObject* Root_get_repos(RootObject* self) {
        pakfire_repolist* repos = pakfire_root_get_repos(self->root);
        if (!repos) {
                PyErr_SetFromErrno(PyExc_OSError);
@@ -417,7 +417,7 @@ ERROR:
        return list;
 }
 
-static PyObject* Pakfire_clean(PakfireObject* self) {
+static PyObject* Root_clean(RootObject* self) {
        int r;
 
        Py_BEGIN_ALLOW_THREADS
@@ -434,7 +434,7 @@ static PyObject* Pakfire_clean(PakfireObject* self) {
        Py_RETURN_NONE;
 }
 
-static PyObject* Pakfire_open(PakfireObject* self, PyObject* args) {
+static PyObject* Root_open(RootObject* self, PyObject* args) {
        pakfire_archive* archive = NULL;
        const char* path = NULL;
 
@@ -459,7 +459,7 @@ static PyObject* Pakfire_open(PakfireObject* self, PyObject* args) {
        return object;
 }
 
-static PyObject* Pakfire_repo_compose(PakfireObject* self, PyObject* args, PyObject* kwargs) {
+static PyObject* Root_repo_compose(RootObject* self, PyObject* args, PyObject* kwargs) {
        const char* kwlist[] = { "path", "files", "key", NULL };
        const char* path = NULL;
        PyObject* list = NULL;
@@ -539,7 +539,7 @@ struct Pakfire_execute_output {
        PyObject* stderr;
 };
 
-static int Pakfire_execute_stdout_callback(pakfire_ctx* ctx, void* data,
+static int Root_execute_stdout_callback(pakfire_ctx* ctx, void* data,
                const enum pakfire_jail_output_stream stream, const char* line, const size_t length) {
        struct Pakfire_execute_output* output = data;
        PyObject* chunk = NULL;
@@ -563,7 +563,7 @@ static int Pakfire_execute_stdout_callback(pakfire_ctx* ctx, void* data,
        return 0;
 }
 
-static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject* kwargs) {
+static PyObject* Root_execute(RootObject* self, PyObject* args, PyObject* kwargs) {
        struct pakfire_input_buffer input = {};
        pakfire_jail* jail = NULL;
        pakfire_env* env = NULL;
@@ -738,7 +738,7 @@ static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject*
 
        // Execute command
        r = pakfire_jail_communicate(jail, argv, env, 0,
-                       input_callback, &input, Pakfire_execute_stdout_callback, &output);
+                       input_callback, &input, Root_execute_stdout_callback, &output);
 
        Py_END_ALLOW_THREADS
 
@@ -785,100 +785,100 @@ ERROR:
        return ret;
 }
 
-static struct PyMethodDef Pakfire_methods[] = {
+static struct PyMethodDef Root_methods[] = {
        {
                "clean",
-               (PyCFunction)Pakfire_clean,
+               (PyCFunction)Root_clean,
                METH_NOARGS,
                NULL,
        },
        {
                "dist",
-               (PyCFunction)Pakfire_dist,
+               (PyCFunction)Root_dist,
                METH_VARARGS,
                NULL
        },
        {
                "execute",
-               (PyCFunction)Pakfire_execute,
+               (PyCFunction)Root_execute,
                METH_VARARGS|METH_KEYWORDS,
                NULL,
        },
        {
                "generate_key",
-               (PyCFunction)Pakfire_generate_key,
+               (PyCFunction)Root_generate_key,
                METH_VARARGS|METH_KEYWORDS,
                NULL
        },
        {
                "get_repo",
-               (PyCFunction)Pakfire_get_repo,
+               (PyCFunction)Root_get_repo,
                METH_VARARGS,
                NULL
        },
        {
                "import_key",
-               (PyCFunction)Pakfire_import_key,
+               (PyCFunction)Root_import_key,
                METH_VARARGS,
                NULL,
        },
        {
                "open",
-               (PyCFunction)Pakfire_open,
+               (PyCFunction)Root_open,
                METH_VARARGS,
                NULL
        },
        {
                "repo_compose",
-               (PyCFunction)Pakfire_repo_compose,
+               (PyCFunction)Root_repo_compose,
                METH_VARARGS|METH_KEYWORDS,
                NULL
        },
        {
                "search",
-               (PyCFunction)Pakfire_search,
+               (PyCFunction)Root_search,
                METH_VARARGS|METH_KEYWORDS,
                NULL
        },
        {
                "version_compare",
-               (PyCFunction)Pakfire_version_compare,
+               (PyCFunction)Root_version_compare,
                METH_VARARGS,
                NULL
        },
        {
                "whatprovides",
-               (PyCFunction)Pakfire_whatprovides,
+               (PyCFunction)Root_whatprovides,
                METH_VARARGS,
                NULL
        },
        {
                "whatrequires",
-               (PyCFunction)Pakfire_whatrequires,
+               (PyCFunction)Root_whatrequires,
                METH_VARARGS,
                NULL
        },
        { NULL },
 };
 
-static struct PyGetSetDef Pakfire_getsetters[] = {
+static struct PyGetSetDef Root_getsetters[] = {
        {
                "arch",
-               (getter)Pakfire_get_arch,
+               (getter)Root_get_arch,
                NULL,
                NULL,
                NULL
        },
     {
                "path",
-               (getter)Pakfire_get_path,
+               (getter)Root_get_path,
                NULL,
                NULL,
                NULL
        },
        {
                "repos",
-               (getter)Pakfire_get_repos,
+               (getter)Root_get_repos,
                NULL,
                NULL,
                NULL
@@ -886,16 +886,16 @@ static struct PyGetSetDef Pakfire_getsetters[] = {
     { NULL },
 };
 
-PyTypeObject PakfireType = {
+PyTypeObject RootType = {
        PyVarObject_HEAD_INIT(NULL, 0)
-       .tp_name            = "pakfire.Pakfire",
-       .tp_basicsize       = sizeof(PakfireObject),
+       .tp_name            = "pakfire.Root",
+       .tp_basicsize       = sizeof(RootObject),
        .tp_flags           = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
-       .tp_new             = Pakfire_new,
-       .tp_dealloc         = (destructor)Pakfire_dealloc,
-       .tp_init            = (initproc)Pakfire_init,
-       .tp_doc             = "Pakfire Object",
-       .tp_methods         = Pakfire_methods,
-       .tp_getset          = Pakfire_getsetters,
-       .tp_repr            = (reprfunc)Pakfire_repr,
+       .tp_new             = Root_new,
+       .tp_dealloc         = (destructor)Root_dealloc,
+       .tp_init            = (initproc)Root_init,
+       .tp_doc             = "Root Object",
+       .tp_methods         = Root_methods,
+       .tp_getset          = Root_getsetters,
+       .tp_repr            = (reprfunc)Root_repr,
 };
similarity index 91%
rename from src/python/pakfire.h
rename to src/python/root.h
index d805986bb8631800513e90ebc16d1441fdf64050..2cad39e0505a558dc71e7d51baa26ee726265c68 100644 (file)
@@ -18,8 +18,8 @@
 #                                                                             #
 #############################################################################*/
 
-#ifndef PYTHON_PAKFIRE_PAKFIRE_H
-#define PYTHON_PAKFIRE_PAKFIRE_H
+#ifndef PYTHON_PAKFIRE_ROOT_H
+#define PYTHON_PAKFIRE_ROOT_H
 
 #include <Python.h>
 
@@ -35,8 +35,8 @@ typedef struct {
 
        // Root
        pakfire_root* root;
-} PakfireObject;
+} RootObject;
 
-extern PyTypeObject PakfireType;
+extern PyTypeObject RootType;
 
-#endif /* PYTHON_PAKFIRE_PAKFIRE_H */
+#endif /* PYTHON_PAKFIRE_ROOT_H */
index 54c94ddbf69851e3a0e28ef9403331c1d7ac3810..cb4470202f17315a37af572e63e7761aa68611f0 100644 (file)
@@ -24,7 +24,7 @@
 #include <pakfire/transaction.h>
 
 #include "errors.h"
-#include "pakfire.h"
+#include "root.h"
 #include "transaction.h"
 
 static PyObject* Transaction_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
@@ -44,7 +44,7 @@ static void Transaction_dealloc(TransactionObject* self) {
 }
 
 static int Transaction_init(TransactionObject* self, PyObject* args, PyObject* kwargs) {
-       PakfireObject* pakfire = NULL;
+       RootObject* root = NULL;
        int allow_downgrade = 0;
        int allow_uninstall = 0;
        int without_recommended = 0;
@@ -60,7 +60,7 @@ static int Transaction_init(TransactionObject* self, PyObject* args, PyObject* k
        };
 
        if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|bbb", (char**)kwlist,
-                       &PakfireType, &pakfire, &allow_downgrade, &allow_uninstall, &without_recommended))
+                       &RootType, &root, &allow_downgrade, &allow_uninstall, &without_recommended))
                return -1;
 
        if (allow_downgrade)
@@ -73,7 +73,7 @@ static int Transaction_init(TransactionObject* self, PyObject* args, PyObject* k
                flags |= PAKFIRE_TRANSACTION_WITHOUT_RECOMMENDED;
 
        // Create a new transaction
-       r = pakfire_transaction_create(&self->transaction, pakfire->root, flags);
+       r = pakfire_transaction_create(&self->transaction, root->root, flags);
        if (r < 0) {
                errno = -r;
                PyErr_SetFromErrno(PyExc_OSError);
index 7bdaa6c3743add839a9d58fcc46685aed7c4f2c7..faf3b4c7bd68aa4630a0fcb385bb7cf811ececf4 100755 (executable)
@@ -12,7 +12,7 @@ class ArchiveTest(tests.TestCase):
                This tests the Package class
        """
        def setUp(self):
-               self.pakfire = self.setup_pakfire()
+               self.root = self.setup_root()
 
        def test_open(self):
                """
@@ -21,7 +21,7 @@ class ArchiveTest(tests.TestCase):
                path = self.path("beep-1.3-2.ip3.x86_64.pfm")
 
                # Open the archive
-               archive = self.pakfire.open(path)
+               archive = self.root.open(path)
 
                # Read back the path
                self.assertEqual(archive.path, path)
@@ -36,7 +36,7 @@ class ArchiveTest(tests.TestCase):
                path = self.path("beep-1.3-2.ip3.x86_64.pfm")
 
                # Open the archive
-               archive = self.pakfire.open(path)
+               archive = self.root.open(path)
 
                # Check that we read the entire list of 7 files
                self.assertEqual(len(archive.filelist), 7)
@@ -80,7 +80,7 @@ class ArchiveTest(tests.TestCase):
                path = self.path("beep-1.3-2.ip3.x86_64.pfm")
 
                # Open the archive
-               archive = self.pakfire.open(path)
+               archive = self.root.open(path)
 
                # Try opening /usr/bin/beep
                f = archive.read("/usr/bin/beep")
@@ -118,7 +118,7 @@ class ArchiveTest(tests.TestCase):
                path = self.path("beep-1.3-2.ip3.x86_64.pfm")
 
                # Open the archive
-               archive = self.pakfire.open(path)
+               archive = self.root.open(path)
 
                with self.tempdir() as t:
                        # Perform extraction
@@ -141,7 +141,7 @@ class ArchiveTest(tests.TestCase):
                path = self.path("beep-1.3-2.ip3.x86_64.pfm")
 
                # Open the archive
-               archive = self.pakfire.open(path)
+               archive = self.root.open(path)
 
                # Fetch the package metadata
                package = archive.get_package()
@@ -152,13 +152,13 @@ class ArchiveTest(tests.TestCase):
 
        def test_open_stub(self):
                # Launch Pakfire in stub mode
-               p = self.setup_pakfire(stub=True)
+               p = self.setup_root(stub=True)
 
                # Make path
                path = self.path("beep-1.3-2.ip3.x86_64.pfm")
 
                # Open the archive
-               archive = self.pakfire.open(path)
+               archive = self.root.open(path)
 
                # Fetch the filelist
                self.assertIsInstance(archive.filelist, list)
index 3c9fc9230e5bfdaa9869e9241621afd6a36913a6..7ea6a0efc3086a732e6bf8b91741578b28e3719c 100755 (executable)
@@ -59,7 +59,7 @@ class CtxTests(tests.TestCase):
                logger = logging.getLogger("pakfire")
 
                with self.assertLogs(logger, logging.DEBUG):
-                       self.setup_pakfire()
+                       self.setup_root()
 
        def test_log_custom(self):
                """
@@ -82,7 +82,7 @@ class CtxTests(tests.TestCase):
                ctx.set_logger(logger)
 
                # Create a new Pakfire instance to create some log messages
-               self.setup_pakfire(ctx=ctx)
+               self.setup_root(ctx=ctx)
 
                # Check if we have received anything
                self.assertTrue(logger.buffer)
index 6a4f3ffd4019c9e965fe9d71f03eb59677f12e09..7f3a2bbbaefcd1cc6e08bee93edda2444918f488 100755 (executable)
@@ -29,7 +29,7 @@ class DistTests(tests.TestCase):
                This tests the dist command
        """
        def setUp(self):
-               self.pakfire = self.setup_pakfire()
+               self.root = self.setup_root()
 
        def test_dist(self):
                """
@@ -42,7 +42,7 @@ class DistTests(tests.TestCase):
                makefile = os.path.join(TEST_DATA_DIR, "packages/dummy/dummy.nm")
 
                # Run dist()
-               archive = self.pakfire.dist(makefile)
+               archive = self.root.dist(makefile)
 
                self.assertIsInstance(archive, pakfire.Archive)
 
index 30ddcebdf43c6b41657f66e9db45683c77cdc9b8..14e12685a0cb75b56a63d315b0e2a179aeb17cdc 100755 (executable)
@@ -29,17 +29,17 @@ class ExecuteTests(tests.TestCase):
                This tests the execute command
        """
        def setUp(self):
-               self.pakfire = self.setup_pakfire()
+               self.root = self.setup_root()
 
        # XXX Temporarily disabled, because the jail messes up the console
        def test_execute(self):
-               r = self.pakfire.execute(["/command", "exit-with-code", "0"])
+               r = self.root.execute(["/command", "exit-with-code", "0"])
 
                self.assertIsNone(r)
 
        def test_return_value(self):
                with self.assertRaises(pakfire.CommandExecutionError) as e:
-                       self.pakfire.execute(["/command", "exit-with-code", "123"])
+                       self.root.execute(["/command", "exit-with-code", "123"])
 
                # Extract return code
                code, output = e.exception.args
@@ -48,7 +48,7 @@ class ExecuteTests(tests.TestCase):
                self.assertIsInstance(output, bytes)
 
        def test_environ(self):
-               r = self.pakfire.execute(["/command", "echo-environ", "VAR1"],
+               r = self.root.execute(["/command", "echo-environ", "VAR1"],
                        environ={"VAR1" : "VAL1"})
 
                self.assertIsNone(r)
@@ -56,48 +56,48 @@ class ExecuteTests(tests.TestCase):
        def test_invalid_inputs(self):
                # Arguments
                with self.assertRaises(TypeError):
-                       self.pakfire.execute("/command")
+                       self.root.execute("/command")
 
                with self.assertRaises(TypeError):
-                       self.pakfire.execute(["/command", 1])
+                       self.root.execute(["/command", 1])
 
                with self.assertRaises(TypeError):
-                       self.pakfire.execute(("/command", "--help"))
+                       self.root.execute(("/command", "--help"))
 
                # Environment
                with self.assertRaises(TypeError):
-                       self.pakfire.execute(["/command", "--help"], environ={"VAR1" : 1})
+                       self.root.execute(["/command", "--help"], environ={"VAR1" : 1})
 
                with self.assertRaises(TypeError):
-                       self.pakfire.execute(["/command", "--help"], environ={1 : "VAL1"})
+                       self.root.execute(["/command", "--help"], environ={1 : "VAL1"})
 
                with self.assertRaises(TypeError):
-                       self.pakfire.execute(["/command", "--help"], environ="VAR1=VAL1")
+                       self.root.execute(["/command", "--help"], environ="VAR1=VAL1")
 
        def test_execute_non_existant_command(self):
                """
                        Executing non-existant commands should raise an error
                """
                with self.assertRaises(pakfire.CommandExecutionError):
-                       self.pakfire.execute(["/command-does-not-exist"])
+                       self.root.execute(["/command-does-not-exist"])
 
        def test_execute_output(self):
                self.assertEqual(
-                       self.pakfire.execute(["/command", "echo", "123"], return_output=True),
+                       self.root.execute(["/command", "echo", "123"], return_output=True),
                        b"123\n",
                )
 
                # Multiple newlines in one read
                self.assertEqual(
-                       self.pakfire.execute(["/command", "echo", "1\n2\n3"], return_output=True),
+                       self.root.execute(["/command", "echo", "1\n2\n3"], return_output=True),
                        b"1\n2\n3\n",
                )
 
                # Run a command with a lot of output which exceeds the buffer size
-               self.pakfire.execute(["/command", "lines", "1", "65536"])
+               self.root.execute(["/command", "lines", "1", "65536"])
 
                # Run a command that generates lots of lines
-               output = self.pakfire.execute(["/command", "lines", "100", "40"], return_output=True)
+               output = self.root.execute(["/command", "lines", "100", "40"], return_output=True)
                self.assertEqual(output.count(b"\n"), 100)
 
        def test_execute_input(self):
@@ -106,7 +106,7 @@ class ExecuteTests(tests.TestCase):
                                output = input
 
                        # Pipe the data through the command
-                       output = self.pakfire.execute(["/command", "pipe"],
+                       output = self.root.execute(["/command", "pipe"],
                                input=input, return_output=True)
 
                        # Input and output must match
@@ -120,7 +120,7 @@ class ExecuteTests(tests.TestCase):
 
                # Ensure that we won't run forever in case the command cannot be found
                with self.assertRaises(pakfire.CommandExecutionError):
-                       self.pakfire.execute(["/does-not-exist"], input=b"1234")
+                       self.root.execute(["/does-not-exist"], input=b"1234")
 
        def test_execute_bind(self):
                """
@@ -130,20 +130,20 @@ class ExecuteTests(tests.TestCase):
                mountpoint = self.path()
 
                # Check if this is actually a mountpoint
-               self.pakfire.execute(["/command", "check-mountpoint", mountpoint], bind=[mountpoint])
+               self.root.execute(["/command", "check-mountpoint", mountpoint], bind=[mountpoint])
 
                # Try some invalid inputs
                with self.assertRaises(TypeError):
-                       self.pakfire.execute(["/command", "exit-with-code", "0"], bind="/something")
+                       self.root.execute(["/command", "exit-with-code", "0"], bind="/something")
 
                with self.assertRaises(TypeError):
-                       self.pakfire.execute(["/command", "exit-with-code", "0"], bind=[123])
+                       self.root.execute(["/command", "exit-with-code", "0"], bind=[123])
 
        def test_nice(self):
                """
                        Check if the jail is able to set the nice level
                """
-               output = self.pakfire.execute(["/command", "print-nice"],
+               output = self.root.execute(["/command", "print-nice"],
                        nice=5, return_output=True)
 
                # Check that we have received 5
@@ -154,14 +154,14 @@ class ExecuteTests(tests.TestCase):
                        Tries using an invalid nice value
                """
                with self.assertRaises(OSError):
-                       self.pakfire.execute(["/command", "print-nice"], nice=100)
+                       self.root.execute(["/command", "print-nice"], nice=100)
 
        def test_check_open_file_descriptors(self):
                """
                        Since we are spawning child processes, it might happen that we leak file
                        descriptors to the child process.
                """
-               self.pakfire.execute(["/command", "check-open-file-descriptors"])
+               self.root.execute(["/command", "check-open-file-descriptors"])
 
        # Signals
 
@@ -169,19 +169,19 @@ class ExecuteTests(tests.TestCase):
                """
                        Sends a stupid signal which doesn't do anything
                """
-               self.pakfire.execute(["/command", "send-signal", "0"])
+               self.root.execute(["/command", "send-signal", "0"])
 
        def test_send_signal_KILL(self):
                """
                        Test the process killing itself
                """
-               self.pakfire.execute(["/command", "send-signal", "9"])
+               self.root.execute(["/command", "send-signal", "9"])
 
        def test_send_signal_TERM(self):
                """
                        Test the process terminating itself
                """
-               self.pakfire.execute(["/command", "send-signal", "15"])
+               self.root.execute(["/command", "send-signal", "15"])
 
 
 if __name__ == "__main__":
index 9663776e91c42c470ff225a93bd4c47103f006f4..1be9a6b665a27a82e030d7ca9661074b8a4bdca2 100755 (executable)
@@ -28,13 +28,13 @@ class KeysTests(tests.TestCase):
                This tests the keys
        """
        def setUp(self):
-               self.pakfire = self.setup_pakfire()
+               self.root = self.setup_root()
 
        def test_generate(self):
                """
                        Generate a new key
                """
-               key = self.pakfire.generate_key(
+               key = self.root.generate_key(
                        algorithm=pakfire.PAKFIRE_KEY_ALGO_ED25519, comment="Key 1")
 
                # Check if we got the correct type
@@ -50,7 +50,7 @@ class KeysTests(tests.TestCase):
                with self.open(path) as f:
                        payload = f.read()
 
-               return self.pakfire.import_key(payload)
+               return self.root.import_key(payload)
 
        def test_import_public_key(self):
                # Import a public key
@@ -70,7 +70,7 @@ class KeysTests(tests.TestCase):
                """
                        Generate a new key
                """
-               key = self.pakfire.generate_key(
+               key = self.root.generate_key(
                        algorithm=pakfire.PAKFIRE_KEY_ALGO_ED25519, comment="Key 1")
 
                data = b"Pakfire"
index b9409f112ea6697e01be97f94e4f6445ded39857..4521044a9c3e9be0497687342e49047c665deb48 100755 (executable)
@@ -28,12 +28,12 @@ class PakfireTest(tests.TestCase):
                This tests the main Pakfire class
        """
        def test_repr(self):
-               p = self.setup_pakfire()
+               p = self.setup_root()
 
                self.assertIn("Pakfire", repr(p))
 
        def test_properties(self):
-               p = self.setup_pakfire()
+               p = self.setup_root()
 
                # Fetch the path and check if it is absolute
                self.assertTrue(p.path.startswith("/"))
@@ -41,7 +41,7 @@ class PakfireTest(tests.TestCase):
                self.assertIn(p.arch, pakfire.supported_arches())
 
        def test_repo(self):
-               p = self.setup_pakfire()
+               p = self.setup_root()
 
                # Fetch a repository
                repo = p.get_repo("@system")
@@ -59,7 +59,7 @@ class PakfireTest(tests.TestCase):
                        self.assertIsInstance(repo, pakfire.Repo)
 
        def test_whatprovides_whatrequires(self):
-               p = self.setup_pakfire()
+               p = self.setup_root()
 
                self.assertIsInstance(p.whatprovides("bash"), list)
                self.assertIsInstance(p.whatrequires("bash"), list)
index 5be2f9dfdc0e394924ce074c0897e196316702b4..cf57b9eb9db25db5490bb89adfed8e5a2ee5f9b3 100755 (executable)
@@ -7,13 +7,13 @@ class PackageTest(tests.TestCase):
                This tests the Package class
        """
        def setUp(self):
-               self.pakfire = self.setup_pakfire()
+               self.root = self.setup_root()
 
        def test_open(self):
                path = self.path("beep-1.3-2.ip3.x86_64.pfm")
 
                # Open the archive
-               a = self.pakfire.open(path)
+               a = self.root.open(path)
 
                # Fetch the package
                p = a.get_package()
index 5482cce95771cbed201f731c134b43e23005acd2..e1500cc173db581b26bc781534303d5a30bf0e24 100644 (file)
@@ -48,9 +48,9 @@ class TestCase(unittest.TestCase):
                # Return a new context
                return pakfire.Ctx(path=path, **kwargs)
 
-       def setup_pakfire(self, ctx=None, path=None, config=None, stub=False, **kwargs):
+       def setup_root(self, ctx=None, path=None, config=None, stub=False, **kwargs):
                """
-                       Sets up a new Pakfire environment
+                       Sets up a new root
                """
                # Create a context if none given
                if ctx is None:
@@ -69,7 +69,7 @@ class TestCase(unittest.TestCase):
                with open(config, "r") as f:
                        config = f.read()
 
-               return pakfire.Pakfire(ctx=ctx, path=path, config=config, stub=stub, **kwargs)
+               return pakfire.Root(ctx=ctx, path=path, config=config, stub=stub, **kwargs)
 
        def path(self, *args, **kwargs):
                """
index 2a1ce27d8bf41b129089885ec12703a70f48db98..5d4596daaee55c2caa56e9369782498809cb4216 100755 (executable)
@@ -8,11 +8,11 @@ class TransactionTest(tests.TestCase):
                This tests the Transaction class
        """
        def setUp(self):
-               self.pakfire = self.setup_pakfire()
+               self.root = self.setup_root()
 
        def test_create(self):
                # Create a new transaction
-               t = pakfire.Transaction(self.pakfire)
+               t = pakfire.Transaction(self.root)
 
                # Ensure we get a transaction
                self.assertIsInstance(t, pakfire.Transaction)
@@ -21,7 +21,7 @@ class TransactionTest(tests.TestCase):
                """
                        Performs some very simple operations which should all fail
                """
-               t = pakfire.Transaction(self.pakfire)
+               t = pakfire.Transaction(self.root)
 
                # Install a few packages
                t.install("a", essential=True)