char* kwlist[] = {
"packages",
"without_recommended",
+ "allow_uninstall",
+ "allow_downgrade",
NULL
};
char** packages = NULL;
int without_recommended = 0;
+ int allow_uninstall = 0;
+ int allow_downgrade = 0;
int solver_flags = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$p", kwlist,
- convert_packages, &packages, &without_recommended))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$ppp", kwlist,
+ convert_packages, &packages, &without_recommended, &allow_uninstall,
+ &allow_downgrade))
return NULL;
// Do not install recommended packages
if (without_recommended)
solver_flags |= PAKFIRE_REQUEST_WITHOUT_RECOMMENDED;
+ // Can the solver uninstall packages?
+ if (allow_uninstall)
+ solver_flags |= PAKFIRE_REQUEST_ALLOW_UNINSTALL;
+
+ // Can the solver downgrade packages?
+ if (allow_downgrade)
+ solver_flags |= PAKFIRE_REQUEST_ALLOW_DOWNGRADE;
+
// Run pakfire_install
int r = pakfire_install(self->pakfire, solver_flags, (const char**)packages, NULL, 0, NULL);
if (r)
char* kwlist[] = {
"packages",
"excludes",
+ "allow_uninstall",
+ "allow_downgrade",
NULL
};
char** packages = NULL;
char** excludes = NULL;
- int flags = 0;
+ int allow_uninstall = 0;
+ int allow_downgrade = 0;
+ int solver_flags = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&", kwlist,
- convert_packages, &packages, convert_packages, &excludes))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&pp", kwlist,
+ convert_packages, &packages, convert_packages, &excludes,
+ &allow_uninstall, &allow_downgrade))
return NULL;
+ // Can the solver uninstall packages?
+ if (allow_uninstall)
+ solver_flags |= PAKFIRE_REQUEST_ALLOW_UNINSTALL;
+
+ // Can the solver downgrade packages?
+ if (allow_downgrade)
+ solver_flags |= PAKFIRE_REQUEST_ALLOW_DOWNGRADE;
+
// Run pakfire_update
- int r = pakfire_update(self->pakfire, 0, (const char**)packages,
- (const char**)excludes, flags, NULL);
+ int r = pakfire_update(self->pakfire, solver_flags, (const char**)packages,
+ (const char**)excludes, 0, NULL);
if (r)
PyErr_SetFromErrno(PyExc_OSError);
enum pakfire_request_flags {
PAKFIRE_REQUEST_WITHOUT_RECOMMENDED = 1 << 0,
+ PAKFIRE_REQUEST_ALLOW_UNINSTALL = 1 << 1,
+ PAKFIRE_REQUEST_ALLOW_DOWNGRADE = 1 << 2,
};
enum pakfire_request_job_flags {
- PAKFIRE_REQUEST_KEEP_DEPS = 1 << 0,
- PAKFIRE_REQUEST_KEEP_ORPHANED = 1 << 1,
+ PAKFIRE_REQUEST_KEEP_DEPS = 1 << 0,
+ PAKFIRE_REQUEST_KEEP_ORPHANED = 1 << 1,
};
enum _pakfire_solver_flags {
- PAKFIRE_SOLVER_ALLOW_UNINSTALL = 1 << 0,
- PAKFIRE_SOLVER_ALLOW_DOWNGRADE = 1 << 3,
PAKFIRE_SOLVER_ALLOW_VENDORCHANGE = 1 << 4,
};
}
static int setup_solver(struct pakfire_request* request, int flags) {
- if (flags & PAKFIRE_SOLVER_ALLOW_DOWNGRADE)
+ // Can the solver downgrade packages?
+ if (flags & PAKFIRE_REQUEST_ALLOW_DOWNGRADE)
solver_set_flag(request->solver, SOLVER_FLAG_ALLOW_DOWNGRADE, 1);
- if (flags & PAKFIRE_SOLVER_ALLOW_UNINSTALL)
+ // Can the solver uninstall packages?
+ if (flags & PAKFIRE_REQUEST_ALLOW_UNINSTALL)
solver_set_flag(request->solver, SOLVER_FLAG_ALLOW_UNINSTALL, 1);
if (flags & PAKFIRE_SOLVER_ALLOW_VENDORCHANGE)
help=_("Give name of at least one package to install"))
install.add_argument("--without-recommended", action="store_true",
help=_("Don't install recommended packages"))
+ install.add_argument("--allow-uninstall", action="store_true",
+ help=_("Allow uninstalling packages"))
+ install.add_argument("--allow-downgrade", action="store_true",
+ help=_("Allow downgrading packages"))
install.set_defaults(func=self.handle_install)
# provides
help=_("Give a name of a package to update or leave emtpy for all"))
update.add_argument("--exclude", "-x", nargs="+", default=[],
help=_("Exclude package from update"))
+ update.add_argument("--allow-uninstall", action="store_true",
+ help=_("Allow uninstalling packages"))
+ update.add_argument("--allow-downgrade", action="store_true",
+ help=_("Allow downgrading packages"))
update.set_defaults(func=self.handle_update)
return parser.parse_args()
p.update(
ns.package,
excludes=ns.exclude,
+ allow_uninstall=ns.allow_uninstall,
+ allow_downgrade=ns.allow_downgrade,
)
def handle_sync(self, ns):
def handle_install(self, ns):
p = self.pakfire(ns)
- p.install(ns.package, without_recommended=not ns.without_recommended)
+ p.install(
+ ns.package,
+ without_recommended=ns.without_recommended,
+ allow_uninstall=ns.allow_uninstall,
+ allow_downgrade=ns.allow_downgrade,
+ )
def handle_reinstall(self, ns):
with self.pakfire(ns) as p: