]> git.ipfire.org Git - pakfire.git/commitdiff
Make pakfire non-interactive by default
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Dec 2021 12:23:33 +0000 (12:23 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Dec 2021 12:23:33 +0000 (12:23 +0000)
This feels a lot more logical in the code. Most of the time Pakfire will
be used in a non-interactive mode and therefore making it optional is
the better choice.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/libpakfire/archive.c
src/libpakfire/include/pakfire/pakfire.h
src/libpakfire/pakfire.c
src/libpakfire/transaction.c
src/libpakfire/ui.c
src/scripts/pakfire.in

index 8320bdd7347f22702347fd281e5b154fe68a680c..93690a64197965664b120c75007d9731fcc38384 100644 (file)
@@ -155,18 +155,19 @@ ERROR:
 }
 
 static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) {
-       char* kwlist[] = { "path", "arch", "logger", "offline", "conf", "build",
+       char* kwlist[] = { "path", "arch", "logger", "interactive", "offline", "conf", "build",
                "enable_ccache", "enable_snapshot", "status_callback", "progress_callback", NULL };
        const char* path = NULL;
        const char* arch = NULL;
        const char* conf = NULL;
+       int interactive = 0;
        int offline = 0;
        int build = 0;
        int enable_ccache = 1;
        int enable_snapshot = 1;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzOpzpppOO", kwlist,
-                       &path, &arch, &self->callbacks.log, &offline, &conf, &build,
+       if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzOppzpppOO", kwlist,
+                       &path, &arch, &self->callbacks.log, &interactive, &offline, &conf, &build,
                        &enable_ccache, &enable_snapshot, &self->callbacks.status,
                        &self->callbacks.progress))
                return -1;
@@ -191,6 +192,10 @@ static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) {
 
        int flags = 0;
 
+       // Enable interactive mode
+       if (interactive)
+               flags |= PAKFIRE_FLAGS_INTERACTIVE;
+
        // Enable offline mode
        if (offline)
                flags |= PAKFIRE_FLAGS_OFFLINE;
index 73f84fc492a332958f31714c9c320aebbb5bc863..c72f73206283eb2c95cb479bd4fc40b32e34a3bf 100644 (file)
@@ -866,7 +866,7 @@ PAKFIRE_EXPORT int pakfire_archive_extract(struct pakfire_archive* archive, cons
        DEBUG(archive->pakfire, "Extracting %s to %s\n", archive->path, path);
 
        // Create a progressbar
-       if (!pakfire_has_flag(archive->pakfire, PAKFIRE_FLAGS_NON_INTERACTIVE)) {
+       if (pakfire_has_flag(archive->pakfire, PAKFIRE_FLAGS_INTERACTIVE)) {
                r = pakfire_archive_extract_progressbar(archive, &progressbar);
                if (r)
                        goto ERROR;
index 47bd89eadde682befb1ff7390b8adebdfc215f99..52ee69b117fbe50e1958522738086b1fdc06f28c 100644 (file)
@@ -43,8 +43,8 @@ enum pakfire_digests {
 #include <pakfire/repolist.h>
 
 enum pakfire_flags {
-       PAKFIRE_FLAGS_OFFLINE                   = (1 << 0),
-       PAKFIRE_FLAGS_NON_INTERACTIVE   = (1 << 1),
+       PAKFIRE_FLAGS_INTERACTIVE               = (1 << 0),
+       PAKFIRE_FLAGS_OFFLINE                   = (1 << 1),
        PAKFIRE_FLAGS_BUILD                             = (1 << 2),
        PAKFIRE_FLAGS_DISABLE_CCACHE    = (1 << 3),
        PAKFIRE_FLAGS_DISABLE_SNAPSHOT  = (1 << 4),
index e6a1821844be849fba6e5a2ba0d1223cb9f621bb..522c08903359dfd16fc90c8d47fac74608020c8b 100644 (file)
@@ -933,11 +933,11 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, const char* path,
        DEBUG(p, "  path   = %s\n", pakfire_get_path(p));
 
        // Automatically disable interactive mode
-       if (!pakfire_has_flag(p, PAKFIRE_FLAGS_NON_INTERACTIVE)) {
+       if (pakfire_has_flag(p, PAKFIRE_FLAGS_INTERACTIVE)) {
                if (pakfire_tty_is_noninteractive()) {
                        DEBUG(p, "Interactive mode disabled\n");
 
-                       flags |= PAKFIRE_FLAGS_NON_INTERACTIVE;
+                       flags &= ~PAKFIRE_FLAGS_INTERACTIVE;
                }
        }
 
@@ -1021,7 +1021,7 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, const char* path,
        // Setup build stuff
        if (pakfire_has_flag(p, PAKFIRE_FLAGS_BUILD)) {
                // Builds are never interactive
-               p->flags |= PAKFIRE_FLAGS_NON_INTERACTIVE;
+               p->flags &= ~PAKFIRE_FLAGS_INTERACTIVE;
        }
 
        *pakfire = p;
index 4844905877c503ce5f7e13c0499f145f8f83ba56..7ceb5de1e0f08e9f9a6b25d6c8c7d9dc6795b76e 100644 (file)
@@ -1223,7 +1223,7 @@ PAKFIRE_EXPORT int pakfire_transaction_run(struct pakfire_transaction* transacti
        char* dump = pakfire_transaction_dump(transaction, 80);
 
        // Check if we should continue
-       if (!pakfire_has_flag(transaction->pakfire, PAKFIRE_FLAGS_NON_INTERACTIVE)) {
+       if (pakfire_has_flag(transaction->pakfire, PAKFIRE_FLAGS_INTERACTIVE)) {
                r = pakfire_ui_confirm(transaction->pakfire, dump, _("Is this okay? [y/N]"));
                if (r) {
                        ERROR(transaction->pakfire, "Transaction aborted upon user request\n");
index 22f25cc1b5d87994e8e8d7de9a9f58001b372c6c..96f43054b2ac346c76d293fffe642bd33615c819 100644 (file)
@@ -32,7 +32,7 @@ int pakfire_ui_confirm(struct pakfire* pakfire, const char* message, const char*
        printf("%s\n", message);
 
        // Skip this, if running in non-interactive mode
-       if (pakfire_has_flag(pakfire, PAKFIRE_FLAGS_NON_INTERACTIVE))
+       if (!pakfire_has_flag(pakfire, PAKFIRE_FLAGS_INTERACTIVE))
                return 0;
 
        char* line = NULL;
@@ -81,7 +81,7 @@ END:
 static int pakfire_ui_enter_number(struct pakfire* pakfire, const char* question,
                unsigned int* choice, unsigned int min, unsigned int max) {
        // Skip this, if running in non-interactive mode
-       if (pakfire_has_flag(pakfire, PAKFIRE_FLAGS_NON_INTERACTIVE))
+       if (!pakfire_has_flag(pakfire, PAKFIRE_FLAGS_INTERACTIVE))
                return 0;
 
        char* line = NULL;
@@ -216,7 +216,7 @@ int pakfire_ui_pick_solution(struct pakfire* pakfire, struct pakfire_request* re
        }
 
        // Skip this, if running in non-interactive mode
-       if (pakfire_has_flag(pakfire, PAKFIRE_FLAGS_NON_INTERACTIVE)) {
+       if (!pakfire_has_flag(pakfire, PAKFIRE_FLAGS_INTERACTIVE)) {
                r = 1;
                goto ERROR;
        }
index fdd21f26a85f40399dd5859c378c86651c54ba07..52a16248a99f78e9dccbbd97bbdfa0f4cb84368b 100644 (file)
@@ -248,6 +248,7 @@ class Cli(object):
                        conf=args.config,
                        arch=args.arch,
                        path=args.root,
+                       interactive=True,
                        offline=args.offline,
                )