From: Michael Tremer Date: Thu, 2 Nov 2017 15:55:05 +0000 (+0100) Subject: Support to install packages without recommended packages X-Git-Tag: 0.9.28~1285^2~1324 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c79db0365fe6bc9a4467ca30addcf5b4216b97dd;p=pakfire.git Support to install packages without recommended packages Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/request.c b/src/_pakfire/request.c index 936cf798f..df48b653d 100644 --- a/src/_pakfire/request.c +++ b/src/_pakfire/request.c @@ -208,8 +208,18 @@ static PyObject* Request_get_problems(RequestObject* self) { return list; } -static PyObject* Request_solve(RequestObject* self) { - int ret = pakfire_request_solve(self->request, 0); +static PyObject* Request_solve(RequestObject* self, PyObject* args, PyObject *kwds) { + char* kwlist[] = {"without_recommends", NULL}; + + int without_recommends = 0; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|p", kwlist, &without_recommends)) + return NULL; + + int flags = 0; + if (without_recommends) + flags |= PAKFIRE_SOLVER_WITHOUT_RECOMMENDS; + + int ret = pakfire_request_solve(self->request, flags); // Raise a DependencyError with all problems // if the request could not be solved @@ -269,7 +279,7 @@ static struct PyMethodDef Request_methods[] = { { "solve", (PyCFunction)Request_solve, - METH_NOARGS, + METH_VARARGS|METH_KEYWORDS, NULL }, { NULL } diff --git a/src/libpakfire/include/pakfire/request.h b/src/libpakfire/include/pakfire/request.h index f29b0a975..3b1f11c96 100644 --- a/src/libpakfire/include/pakfire/request.h +++ b/src/libpakfire/include/pakfire/request.h @@ -33,8 +33,9 @@ enum _pakfire_request_op_flags { }; enum _pakfire_solver_flags { - PAKFIRE_SOLVER_ALLOW_UNINSTALL = 1 << 0, - PAKFIRE_SOLVER_FORCE_BEST = 1 << 1, + PAKFIRE_SOLVER_ALLOW_UNINSTALL = 1 << 0, + PAKFIRE_SOLVER_FORCE_BEST = 1 << 1, + PAKFIRE_SOLVER_WITHOUT_RECOMMENDS = 1 << 2, }; PakfireRequest pakfire_request_create(PakfirePool pool); diff --git a/src/libpakfire/request.c b/src/libpakfire/request.c index 24847d32a..d8aaab6cb 100644 --- a/src/libpakfire/request.c +++ b/src/libpakfire/request.c @@ -87,6 +87,10 @@ static void init_solver(PakfireRequest request, int flags) { if (flags & PAKFIRE_SOLVER_ALLOW_UNINSTALL) solver_set_flag(solver, SOLVER_FLAG_ALLOW_UNINSTALL, 1); + /* ignore recommends */ + if (flags & PAKFIRE_SOLVER_WITHOUT_RECOMMENDS) + solver_set_flag(solver, SOLVER_FLAG_IGNORE_RECOMMENDED, 1); + /* no vendor locking */ solver_set_flag(solver, SOLVER_FLAG_ALLOW_VENDORCHANGE, 1); diff --git a/src/pakfire/cli.py b/src/pakfire/cli.py index 9a63cace9..6ecb8b499 100644 --- a/src/pakfire/cli.py +++ b/src/pakfire/cli.py @@ -290,7 +290,7 @@ class Cli(object): def handle_install(self, ns): with self.pakfire(ns) as p: - p.install(ns.package, ignore_recommended=ns.without_recommends) + p.install(ns.package, without_recommends=ns.without_recommends) def handle_reinstall(self, ns): with self.pakfire(ns) as p: