From: Michael Tremer Date: Thu, 2 Nov 2017 18:42:15 +0000 (+0100) Subject: Allow to check for any dependency issues X-Git-Tag: 0.9.28~1285^2~1315 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f466d0dbcd2d2f6f4bb74e0e3e1558d031c507fd;p=pakfire.git Allow to check for any dependency issues Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/request.c b/src/_pakfire/request.c index 9a59acc88..05c957aa0 100644 --- a/src/_pakfire/request.c +++ b/src/_pakfire/request.c @@ -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, diff --git a/src/pakfire/base.py b/src/pakfire/base.py index 277485d66..5416def28 100644 --- a/src/pakfire/base.py +++ b/src/pakfire/base.py @@ -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 = [] diff --git a/src/pakfire/cli.py b/src/pakfire/cli.py index ebc395844..c4e470a66 100644 --- a/src/pakfire/cli.py +++ b/src/pakfire/cli.py @@ -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: