From 2d68cec7808194ece51218d4915e7435104c7a95 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 7 Dec 2009 06:52:27 +0100 Subject: [PATCH] xbps-bin: make the 'autoremove' target respect -f flag to bypass question. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091207055227-8kiks1f3k2tuoe2z --- bin/xbps-bin/defs.h | 2 +- bin/xbps-bin/main.c | 4 ++-- bin/xbps-bin/remove.c | 27 +++++++++++---------------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/bin/xbps-bin/defs.h b/bin/xbps-bin/defs.h index 754c07a7..780e4fae 100644 --- a/bin/xbps-bin/defs.h +++ b/bin/xbps-bin/defs.h @@ -27,7 +27,7 @@ #define _XBPS_BIN_DEFS_H_ int xbps_exec_transaction(const char *, bool, bool); -int xbps_autoremove_pkgs(void); +int xbps_autoremove_pkgs(bool); int xbps_remove_installed_pkg(const char *, bool); int xbps_check_pkg_integrity(const char *); int xbps_check_pkg_integrity_all(void); diff --git a/bin/xbps-bin/main.c b/bin/xbps-bin/main.c index 9433535c..7d39bfd3 100644 --- a/bin/xbps-bin/main.c +++ b/bin/xbps-bin/main.c @@ -62,7 +62,7 @@ usage(void) " -r\t\t\n" " -v\t\tShows verbose messages\n" " -V\t\tPrints the xbps release version\n" - " Options used by the (auto)remove and install target:\n" + " Options used by the install/(auto)remove/update targets:\n" " -f\t\tBypasses the questions.\n" "\n"); exit(EXIT_FAILURE); @@ -256,7 +256,7 @@ main(int argc, char **argv) if (argc != 1) usage(); - rv = xbps_autoremove_pkgs(); + rv = xbps_autoremove_pkgs(force); } else if (strcasecmp(argv[0], "purge") == 0) { /* diff --git a/bin/xbps-bin/remove.c b/bin/xbps-bin/remove.c index e66aef26..03070031 100644 --- a/bin/xbps-bin/remove.c +++ b/bin/xbps-bin/remove.c @@ -34,7 +34,7 @@ #include "../xbps-repo/defs.h" int -xbps_autoremove_pkgs(void) +xbps_autoremove_pkgs(bool force) { prop_array_t orphans; prop_object_t obj; @@ -88,7 +88,7 @@ xbps_autoremove_pkgs(void) prop_object_iterator_reset(iter); printf("\n\n"); - if (xbps_noyes("Do you want to remove them?") == false) { + if (!force && !xbps_noyes("Do you want to remove them?")) { printf("Cancelled!\n"); goto out2; } @@ -123,6 +123,7 @@ xbps_remove_installed_pkg(const char *pkgname, bool force) prop_dictionary_t dict; const char *version; int rv = 0; + bool reqby_force = false; /* * First check if package is required by other packages. @@ -142,22 +143,16 @@ xbps_remove_installed_pkg(const char *pkgname, bool force) (void)xbps_callback_array_iter_in_dict(dict, "requiredby", list_strings_in_array, NULL); printf("\n\n"); - if (!force) { - if (!xbps_noyes("Do you want to remove %s?", pkgname)) { - printf("Cancelling!\n"); - return 0; - } - } - printf("Forcing %s-%s for deletion!\n", pkgname, version); - } else { - if (!force) { - if (!xbps_noyes("Do you want to remove %s?", pkgname)) { - printf("Cancelling!\n"); - return 0; - } - } + reqby_force = true; } + if (!force && !xbps_noyes("Do you want to remove %s?", pkgname)) { + printf("Cancelling!\n"); + return 0; + } + if (reqby_force) + printf("Forcing %s-%s for deletion!\n", pkgname, version); + printf("Removing package %s-%s ...\n", pkgname, version); if ((rv = xbps_remove_pkg(pkgname, version, false)) != 0) { printf("Unable to remove %s-%s (%s).\n",