]> git.ipfire.org Git - pakfire.git/commitdiff
Allow to check for any dependency issues
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 2 Nov 2017 18:42:15 +0000 (19:42 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 2 Nov 2017 18:42:15 +0000 (19:42 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/request.c
src/pakfire/base.py
src/pakfire/cli.py

index 9a59acc8881d6672c36cdf6e6375d271d01ee752..05c957aa0e8777a2762f5dfe22cf55799a20cba3 100644 (file)
@@ -191,6 +191,12 @@ static PyObject* Request_distupgrade(RequestObject* self) {
        return Request_operation_return(ret);
 }
 
+static PyObject* Request_verify(RequestObject* self) {
+       int ret = pakfire_request_verify(self->request);
+
+       return Request_operation_return(ret);
+}
+
 static PyObject* Request_get_problems(RequestObject* self) {
        PyObject* list = PyList_New(0);
 
@@ -296,6 +302,12 @@ static struct PyMethodDef Request_methods[] = {
                METH_NOARGS,
                NULL
        },
+       {
+               "verify",
+               (PyCFunction)Request_verify,
+               METH_NOARGS,
+               NULL
+       },
        {
                "solve",
                (PyCFunction)Request_solve,
index 277485d66741c08593a848b5b019f38d4f79f522..5416def284cb42956f27302feaca8bea54ff47eb 100644 (file)
@@ -171,36 +171,17 @@ class PakfireContext(object):
                """
                return self.pakfire.repos
 
-       def check(self, allow_downgrade=True, allow_uninstall=True):
+       def check(self, **kwargs):
                """
                        Try to fix any errors in the system.
                """
                # Detect any errors in the dependency tree.
                # For that we create an empty request and solver and try to solve
                # something.
-               request = self.pakfire.pool.create_request()
+               request = _pakfire.Request(self.pakfire.pool)
                request.verify()
 
-               solver = self.pakfire.pool.solve(
-                       request,
-                       allow_downgrade=allow_downgrade,
-                       allow_uninstall=allow_uninstall,
-               )
-
-               if solver.status is False:
-                       log.info(_("Everything is fine."))
-                       return
-
-               # Create the transaction.
-               t = transaction.Transaction.from_solver(self.pakfire, solver)
-               t.dump()
-
-               # Ask the user if okay.
-               if not t.cli_yesno():
-                       return
-
-               # Process the transaction.
-               t.run()
+               return request.solve(**kwargs)
 
        def info(self, patterns):
                pkgs = []
index ebc39584468ffbb45d535d5c4a6989d053625c03..c4e470a66ad2631c6165c98f5dccb343ec17d46b 100644 (file)
@@ -374,7 +374,10 @@ class Cli(object):
 
        def handle_check(self, ns):
                with self.pakfire(ns) as p:
-                       p.check()
+                       # This will throw an exception when there are errors
+                       transaction = p.check()
+
+                       self.ui.message(_("Everything okay"))
 
        def handle_resolvdep(self, ns):
                with self.pakfire(ns) as p: