]> git.ipfire.org Git - pakfire.git/commitdiff
Move clean function into libpakfire
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Jun 2021 16:23:31 +0000 (16:23 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Jun 2021 16:23:31 +0000 (16:23 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/libpakfire/include/pakfire/pakfire.h
src/libpakfire/libpakfire.sym
src/libpakfire/pakfire.c
src/pakfire/base.py

index 32893cf500ff05352a721c50d5017b491e521a53..c8e17fab1d1c98af501f9d498a2053d8bb9288a4 100644 (file)
@@ -849,6 +849,16 @@ static PyObject* Pakfire_shell(PakfireObject* self) {
        return execute_return_value(r);
 }
 
+static PyObject* Pakfire_clean(PakfireObject* self) {
+       int r = pakfire_clean(self->pakfire);
+       if (r) {
+               PyErr_SetFromErrno(PyExc_OSError);
+               return NULL;
+       }
+
+       Py_RETURN_NONE;
+}
+
 static struct PyMethodDef Pakfire_methods[] = {
        {
                "bind",
@@ -862,6 +872,12 @@ static struct PyMethodDef Pakfire_methods[] = {
                METH_VARARGS|METH_KEYWORDS,
                NULL
        },
+       {
+               "clean",
+               (PyCFunction)Pakfire_clean,
+               METH_NOARGS,
+               NULL,
+       },
        {
                "copy_in",
                (PyCFunction)Pakfire_copy_in,
index 7fb2e72ac443c8b0566dd43486042935985a7a84..1f1daf26a99578827e3014589a7476d8d0a5bd09 100644 (file)
@@ -47,6 +47,8 @@ Pakfire pakfire_unref(Pakfire pakfire);
 
 const char* pakfire_get_path(Pakfire pakfire);
 
+int pakfire_clean(Pakfire pakfire);
+
 int pakfire_bind(Pakfire pakfire, const char* src, const char* dst, int flags);
 
 int pakfire_copy_in(Pakfire pakfire, const char* src, const char* dst);
index 02c0e05f581658b69501084b2cefb3c280c63b4d..7375b922c74dc67bfbdc16c96b2826c5a2b2d178 100644 (file)
@@ -22,6 +22,7 @@ LIBPAKFIRE_0 {
 global:
        # pakfire
        pakfire_bind;
+       pakfire_clean;
        pakfire_copy_in;
        pakfire_copy_out;
        pakfire_count_packages;
index 4347242d38dcc905f23810360de6ee18bf089561..c6e4db7a177612eec1a6df8cff4fa7433a3c0de5 100644 (file)
@@ -1053,6 +1053,32 @@ PAKFIRE_EXPORT int pakfire_bind(Pakfire pakfire, const char* src, const char* ds
        return __mount(pakfire, src, mountpoint, NULL, flags|MS_BIND, NULL);
 }
 
+PAKFIRE_EXPORT int pakfire_clean(Pakfire pakfire) {
+       PakfireRepo repo;
+       Repo* solv_repo;
+       int i;
+       int r;
+
+       Pool* pool = pakfire->pool;
+
+       // Cleanup all repositories
+       FOR_REPOS(i, solv_repo) {
+               repo = pakfire_repo_create_from_repo(pakfire, solv_repo);
+               if (!repo)
+                       return 1;
+
+               // Perform cleanup
+               r = pakfire_repo_clean(repo);
+               pakfire_repo_unref(repo);
+
+               // Raise any errors
+               if (r)
+                       return r;
+       }
+
+       return 0;
+}
+
 static int pakfire_copy(Pakfire pakfire, const char* src, const char* dst) {
        char buffer[512 * 1024];
        struct archive* reader = NULL;
index 9bf7fd0fae11516fd4290b141b1bc78ec3b92d60..07cd0f77c70b10fa320a6aebccfd48fcc6c8cd49 100644 (file)
@@ -45,11 +45,6 @@ class Pakfire(_pakfire.Pakfire):
        def __exit__(self, type, value, traceback):
                pass
 
-       def clean(self):
-               # Clean up repository caches
-               for repo in self.repos:
-                       repo.clean()
-
 
 class PakfireContext(object):
        """