]> git.ipfire.org Git - pakfire.git/commitdiff
install/remove/update/sync: Add solver flags for more granular configuration
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Jul 2021 11:36:12 +0000 (11:36 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Jul 2021 11:36:12 +0000 (11:36 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/libpakfire/build.c
src/libpakfire/include/pakfire/pakfire.h
src/libpakfire/pakfire.c

index da7b6879c93817efbd71d4f2f8c33baecad6cc60..8a815559625f131e84c976bf2d8c5dfdfa58f45d 100644 (file)
@@ -287,7 +287,7 @@ static PyObject* Pakfire_install(PakfireObject* self, PyObject* args, PyObject*
        // XXX include_recommended
 
        // Run pakfire_install
-       int r = pakfire_install(self->pakfire, (const char**)packages, NULL, flags, NULL);
+       int r = pakfire_install(self->pakfire, 0, (const char**)packages, NULL, flags, NULL);
        if (r)
                PyErr_SetFromErrno(PyExc_OSError);
 
@@ -321,7 +321,7 @@ static PyObject* Pakfire_erase(PakfireObject* self, PyObject* args, PyObject* kw
                flags |= PAKFIRE_REQUEST_KEEP_DEPS;
 
        // Run pakfire_erase
-       int r = pakfire_erase(self->pakfire, (const char**)packages, NULL, flags, NULL);
+       int r = pakfire_erase(self->pakfire, 0, (const char**)packages, NULL, flags, NULL);
        if (r)
                PyErr_SetFromErrno(PyExc_OSError);
 
@@ -352,7 +352,7 @@ static PyObject* Pakfire_update(PakfireObject* self, PyObject* args, PyObject* k
                return NULL;
 
        // Run pakfire_update
-       int r = pakfire_update(self->pakfire, (const char**)packages,
+       int r = pakfire_update(self->pakfire, 0, (const char**)packages,
                (const char**)excludes, flags, NULL);
        if (r)
                PyErr_SetFromErrno(PyExc_OSError);
@@ -898,7 +898,7 @@ static PyObject* Pakfire_sync(PakfireObject* self, PyObject* args, PyObject* kwa
        if (keep_orphaned)
                flags |= PAKFIRE_REQUEST_KEEP_ORPHANED;
 
-       int r = pakfire_sync(self->pakfire, flags, NULL);
+       int r = pakfire_sync(self->pakfire, 0, flags, NULL);
        if (r) {
                PyErr_SetFromErrno(PyExc_OSError);
                return NULL;
index d886dc8f4455b3d3775e106b8edc3a44941b1264..2868e8c282ced161ca88f72dbebb8cb0b80ce5a3 100644 (file)
@@ -80,7 +80,7 @@ static int pakfire_build_install_packages(Pakfire pakfire, int* snapshot_needs_u
        int changed = 0;
 
        // Install everything
-       r = pakfire_install(pakfire, (const char**)packages, NULL, 0, &changed);
+       r = pakfire_install(pakfire, 0, (const char**)packages, NULL, 0, &changed);
        if (r) {
                ERROR(pakfire, "Could not install build dependencies\n");
                goto ERROR;
@@ -91,7 +91,7 @@ static int pakfire_build_install_packages(Pakfire pakfire, int* snapshot_needs_u
                *snapshot_needs_update = 1;
 
        // Update everything
-       r = pakfire_sync(pakfire, 0, &changed);
+       r = pakfire_sync(pakfire, 0, 0, &changed);
        if (r) {
                ERROR(pakfire, "Could not update packages: %m\n");
                goto ERROR;
@@ -884,7 +884,7 @@ PAKFIRE_EXPORT int pakfire_build(Pakfire pakfire, const char* path,
        };
 
        // Install the package into the build environment
-       r = pakfire_install(pakfire, packages, NULL, 0, NULL);
+       r = pakfire_install(pakfire, 0, packages, NULL, 0, NULL);
        if (r) {
                ERROR(pakfire, "Could not install %s\n", path);
                goto ERROR;
index 0151fc79f2656eaa0451378aa624d1a0a7bc9e70..d30b018ec4700804792a87ec974866dd7e06816f 100644 (file)
@@ -88,12 +88,12 @@ void pakfire_log_set_priority(Pakfire pakfire, int priority);
 
 // Install/Erase/Update
 
-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);
+int pakfire_install(Pakfire pakfire, int solver_flags, const char** packages,
+       const char** locks, int job_flags, int* changed);
+int pakfire_erase(Pakfire pakfire, int solver_flags, const char** packages,
+       const char** locks, int job_flags, int* changed);
+int pakfire_update(Pakfire pakfire, int solver_flags, const char** packages,
+       const char** locks, int jobs_flags, int* changed);
 
 // Check
 
@@ -101,7 +101,7 @@ int pakfire_check(Pakfire pakfire);
 
 // Sync
 
-int pakfire_sync(Pakfire pakfire, int flags, int* changed);
+int pakfire_sync(Pakfire pakfire, int solver_flags, int flags, int* changed);
 
 #ifdef PAKFIRE_PRIVATE
 
index 19f6372e5a6cbbabe5f61ca57fa86eadc499f60a..56c865db1dc17be53c33bbefc4c2d59e5d51ebcf 100644 (file)
@@ -1570,9 +1570,9 @@ struct archive* pakfire_make_archive_disk_writer(Pakfire pakfire) {
 
 // Convenience functions to install/erase/update packages
 
-static int pakfire_perform_transaction(Pakfire pakfire,
+static int pakfire_perform_transaction(Pakfire pakfire, int solver_flags,
                int (*action)(struct pakfire_request* request, const char* what, int flags),
-               const char** packages, const char** locks, int flags, int* changed) {
+               const char** packages, const char** locks, int job_flags, int* changed) {
        struct pakfire_request* request = NULL;
        struct pakfire_transaction* transaction = NULL;
        struct pakfire_problem** problems = NULL;
@@ -1590,7 +1590,7 @@ static int pakfire_perform_transaction(Pakfire pakfire,
                goto ERROR;
 
        // Create a new request
-       r = pakfire_request_create(&request, pakfire, 0);
+       r = pakfire_request_create(&request, pakfire, solver_flags);
        if (r)
                goto ERROR;
 
@@ -1607,7 +1607,7 @@ static int pakfire_perform_transaction(Pakfire pakfire,
 
        // Perform action on all packages
        for (const char** package = packages; *package; package++) {
-               r = action(request, *package, flags);
+               r = action(request, *package, job_flags);
                if (r) {
                        ERROR(pakfire, "Could not find '%s': %m\n", *package);
                        goto ERROR;
@@ -1672,21 +1672,21 @@ ERROR:
        return r;
 }
 
-PAKFIRE_EXPORT int pakfire_install(Pakfire pakfire, const char** packages,
-               const char** locks, int flags, int* changed) {
-       return pakfire_perform_transaction(pakfire, pakfire_request_install, packages,
-               locks, flags, changed);
+PAKFIRE_EXPORT int pakfire_install(Pakfire pakfire, int solver_flags,
+               const char** packages, const char** locks, int flags, int* changed) {
+       return pakfire_perform_transaction(pakfire, solver_flags, pakfire_request_install,
+               packages, locks, flags, changed);
 }
 
-PAKFIRE_EXPORT int pakfire_erase(Pakfire pakfire, const char** packages,
-               const char** locks, int flags, int* changed) {
-       return pakfire_perform_transaction(pakfire, pakfire_request_erase, packages,
-               locks, flags, changed);
+PAKFIRE_EXPORT int pakfire_erase(Pakfire pakfire, int solver_flags,
+               const char** packages, const char** locks, int flags, int* changed) {
+       return pakfire_perform_transaction(pakfire, solver_flags, pakfire_request_erase,
+               packages, locks, flags, changed);
 }
 
-static int pakfire_perform_transaction_simple(Pakfire pakfire,
+static int pakfire_perform_transaction_simple(Pakfire pakfire, int solver_flags,
                int (*action)(struct pakfire_request* request, int flags),
-               int flags, int* changed) {
+               int job_flags, int* changed) {
        struct pakfire_request* request = NULL;
        struct pakfire_transaction* transaction = NULL;
        struct pakfire_problem** problems = NULL;
@@ -1698,12 +1698,12 @@ static int pakfire_perform_transaction_simple(Pakfire pakfire,
                goto ERROR;
 
        // Create a new request
-       r = pakfire_request_create(&request, pakfire, 0);
+       r = pakfire_request_create(&request, pakfire, solver_flags);
        if (r)
                goto ERROR;
 
        // Perform action
-       r = action(request, flags);
+       r = action(request, job_flags);
        if (r)
                goto ERROR;
 
@@ -1765,20 +1765,20 @@ ERROR:
        return r;
 }
 
-PAKFIRE_EXPORT int pakfire_update(Pakfire pakfire, const char** packages,
-               const char** locks, int flags, int* changed) {
+PAKFIRE_EXPORT int pakfire_update(Pakfire pakfire, int solver_flags,
+               const char** packages, const char** locks, int flags, int* changed) {
        // If no packages are being passed, we will try to update everything
        // XXX add locks
        if (!packages)
                return pakfire_perform_transaction_simple(
-                       pakfire, pakfire_request_update_all, flags, changed);
+                       pakfire, solver_flags, pakfire_request_update_all, flags, changed);
 
-       return pakfire_perform_transaction(pakfire, pakfire_request_update, packages,
-               locks, flags, changed);
+       return pakfire_perform_transaction(pakfire, solver_flags, pakfire_request_update,
+               packages, locks, flags, changed);
 }
 
 static int pakfire_verify(Pakfire pakfire, int *changed) {
-       return pakfire_perform_transaction_simple(pakfire, pakfire_request_verify, 0, changed);
+       return pakfire_perform_transaction_simple(pakfire, 0, pakfire_request_verify, 0, changed);
 }
 
 PAKFIRE_EXPORT int pakfire_check(Pakfire pakfire) {
@@ -1807,6 +1807,7 @@ ERROR:
        return r;
 }
 
-PAKFIRE_EXPORT int pakfire_sync(Pakfire pakfire, int flags, int* changed) {
-       return pakfire_perform_transaction_simple(pakfire, pakfire_request_sync, flags, changed);
+PAKFIRE_EXPORT int pakfire_sync(Pakfire pakfire, int solver_flags, int flags, int* changed) {
+       return pakfire_perform_transaction_simple(pakfire, solver_flags,
+               pakfire_request_sync, flags, changed);
 }