}
const unsigned int length = PySequence_Length(object);
- if (!length) {
- PyErr_SetString(PyExc_ValueError, "Packages list is empty");
- goto ERROR;
- }
// Allocate array
*packages = calloc(length + 1, sizeof(*packages));
// XXX include_recommended
// Run pakfire_install
- int r = pakfire_install(self->pakfire, (const char**)packages, flags, NULL);
+ int r = pakfire_install(self->pakfire, (const char**)packages, NULL, flags, NULL);
if (r)
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
// Run pakfire_erase
- int r = pakfire_erase(self->pakfire, (const char**)packages, flags, NULL);
+ int r = pakfire_erase(self->pakfire, (const char**)packages, NULL, flags, NULL);
if (r)
PyErr_SetFromErrno(PyExc_OSError);
static PyObject* Pakfire_update(PakfireObject* self, PyObject* args, PyObject* kwargs) {
char* kwlist[] = {
"packages",
+ "excludes",
"allow_archchange",
"allow_vendorchange",
NULL
};
char** packages = NULL;
+ char** excludes = NULL;
int allow_archchange = 0;
int allow_vendorchange = 0;
int flags = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$pp", kwlist,
- convert_packages, &packages, &allow_archchange, &allow_vendorchange))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&|$O&pp", kwlist,
+ convert_packages, &packages, convert_packages, &excludes,
+ &allow_archchange, &allow_vendorchange))
return NULL;
if (allow_archchange)
flags |= PAKFIRE_SOLVER_ALLOW_VENDORCHANGE;
// Run pakfire_update
- int r = pakfire_update(self->pakfire, (const char**)packages, flags, NULL);
+ int r = pakfire_update(self->pakfire, (const char**)packages,
+ (const char**)excludes, flags, NULL);
if (r)
PyErr_SetFromErrno(PyExc_OSError);
free(packages);
}
+ if (excludes) {
+ for (char** exclude = excludes; *exclude; exclude++)
+ free(*exclude);
+ free(excludes);
+ }
+
if (r)
return NULL;
int changed = 0;
// Install everything
- r = pakfire_install(pakfire, (const char**)packages, 0, &changed);
+ r = pakfire_install(pakfire, (const char**)packages, NULL, 0, &changed);
if (r) {
ERROR(pakfire, "Could not install build dependencies\n");
goto ERROR;
};
// Install the package into the build environment
- r = pakfire_install(pakfire, packages, 0, NULL);
+ r = pakfire_install(pakfire, packages, NULL, 0, NULL);
if (r) {
ERROR(pakfire, "Could not install %s\n", path);
goto ERROR;
// Install/Erase/Update
-int pakfire_install(Pakfire pakfire, const char** packages, int flags, int* changed);
-int pakfire_erase(Pakfire pakfire, const char** packages, int flags, int* changed);
-int pakfire_update(Pakfire pakfire, const char** packages, int flags, int* changed);
+int pakfire_install(Pakfire pakfire, const char** packages, const char** locks,
+ int flags, int* changed);
+int pakfire_erase(Pakfire pakfire, const char** packages, const char** locks,
+ int flags, int* changed);
+int pakfire_update(Pakfire pakfire, const char** packages, const char** locks,
+ int flags, int* changed);
// Check
static int pakfire_perform_transaction(Pakfire pakfire,
int (*action)(struct pakfire_request* request, const char* what, int flags),
- const char** packages, int flags, int* changed) {
+ const char** packages, const char** locks, int flags, int* changed) {
struct pakfire_request* request = NULL;
struct pakfire_transaction* transaction = NULL;
int r = 1;
if (r)
goto ERROR;
+ // Lock anything that should be locked
+ for (const char** lock = locks; *lock; lock++) {
+ r = pakfire_request_lock(request, *lock);
+ if (r) {
+ ERROR(pakfire, "Could not lock '%s': %m\n", *lock);
+ goto ERROR;
+ }
+ }
+
// Perform action on all packages
for (const char** package = packages; *package; package++) {
r = action(request, *package, flags);
}
PAKFIRE_EXPORT int pakfire_install(Pakfire pakfire, const char** packages,
- int flags, int* changed) {
+ const char** locks, int flags, int* changed) {
return pakfire_perform_transaction(pakfire, pakfire_request_install, packages,
- flags, changed);
+ locks, flags, changed);
}
PAKFIRE_EXPORT int pakfire_erase(Pakfire pakfire, const char** packages,
- int flags, int* changed) {
+ const char** locks, int flags, int* changed) {
return pakfire_perform_transaction(pakfire, pakfire_request_erase, packages,
- flags, changed);
+ locks, flags, changed);
}
PAKFIRE_EXPORT int pakfire_update(Pakfire pakfire, const char** packages,
- int flags, int* changed) {
+ const char** locks, int flags, int* changed) {
return pakfire_perform_transaction(pakfire, pakfire_request_upgrade, packages,
- flags, changed);
+ locks, flags, changed);
}
static int pakfire_perform_transaction_simple(Pakfire pakfire,
help=_("Allow changing the architecture of packages"))
update.add_argument("--allow-vendorchange", action="store_true",
help=_("Allow changing the vendor of packages"))
+ update.add_argument("--exclude", "-x", nargs="+", default=[],
+ help=_("Exclude package from update"))
update.set_defaults(func=self.handle_update)
return parser.parse_args()
p = self.pakfire(ns)
p.update(
ns.package,
+ excludes=ns.exclude,
allow_archchange=ns.allow_archchange,
allow_vendorchange=ns.allow_vendorchange,
)