From f0f53cb07eb6905b8d8c6c853bbce39f7b8df5d5 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 9 Apr 2009 18:42:07 +0200 Subject: [PATCH] xbps-bin: use -f to bypass questions while installing/removing. --HG-- extra : convert_revision : edefc4dbf4dbbcdac53579100732e77004a45463 --- bin/xbps-bin/defs.h | 4 ++-- bin/xbps-bin/install.c | 12 +++++++----- bin/xbps-bin/main.c | 11 ++++++----- bin/xbps-bin/remove.c | 18 +++++++++++------- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/bin/xbps-bin/defs.h b/bin/xbps-bin/defs.h index ef6fa8eb99e..37f9acb44d6 100644 --- a/bin/xbps-bin/defs.h +++ b/bin/xbps-bin/defs.h @@ -26,8 +26,8 @@ #ifndef _XBPS_BIN_DEFS_H_ #define _XBPS_BIN_DEFS_H_ -void xbps_install_pkg(const char *, bool); +void xbps_install_pkg(const char *, bool, bool); void xbps_autoremove_pkgs(void); -void xbps_remove_pkg(const char *); +void xbps_remove_pkg(const char *, bool); #endif /* !_XBPS_BIN_DEFS_H_ */ diff --git a/bin/xbps-bin/install.c b/bin/xbps-bin/install.c index 5f4701285cd..a271422da94 100644 --- a/bin/xbps-bin/install.c +++ b/bin/xbps-bin/install.c @@ -66,7 +66,7 @@ show_missing_dep_cb(prop_object_t obj, void *arg, bool *loop_done) } void -xbps_install_pkg(const char *pkg, bool update) +xbps_install_pkg(const char *pkg, bool force, bool update) { prop_dictionary_t props, instpkg; prop_array_t array; @@ -183,10 +183,12 @@ xbps_install_pkg(const char *pkg, bool update) } printf("Total installed size: %s\n\n", size); - if (xbps_noyes("Do you want to continue?") == false) { - printf("Aborting!\n"); - prop_object_release(props); - exit(EXIT_SUCCESS); + if (force == false) { + if (xbps_noyes("Do you want to continue?") == false) { + printf("Aborting!\n"); + prop_object_release(props); + exit(EXIT_SUCCESS); + } } printf("Checking binary package file(s) integrity...\n"); diff --git a/bin/xbps-bin/main.c b/bin/xbps-bin/main.c index 2c98455d94f..589156c7ed0 100644 --- a/bin/xbps-bin/main.c +++ b/bin/xbps-bin/main.c @@ -58,8 +58,8 @@ usage(void) " Options used by the files target:\n" " -C\t\tTo check the SHA256 hash for any listed file.\n" " Options used by the (auto)remove target:\n" - " -f\t\tForce removal, even if package is required by other\n" - " \t\tpackages that are currently installed.\n" + " -f\t\tForce installation or removal of packages.\n" + " \t\tBeware with this option if you use autoremove!\n" "\n" " Examples:\n" " $ xbps-bin autoremove\n" @@ -77,6 +77,7 @@ static int list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done) { const char *pkgname, *version, *short_desc; + (void)arg; (void)loop_done; @@ -165,21 +166,21 @@ main(int argc, char **argv) if (argc != 2) usage(); - xbps_install_pkg(argv[1], false); + xbps_install_pkg(argv[1], force, false); } else if (strcasecmp(argv[0], "update") == 0) { /* Update an installed package. */ if (argc != 2) usage(); - xbps_install_pkg(argv[1], true); + xbps_install_pkg(argv[1], force, true); } else if (strcasecmp(argv[0], "remove") == 0) { /* Removes a binary package. */ if (argc != 2) usage(); - xbps_remove_pkg(argv[1]); + xbps_remove_pkg(argv[1], force); } else if (strcasecmp(argv[0], "show") == 0) { /* Shows info about an installed binary package. */ diff --git a/bin/xbps-bin/remove.c b/bin/xbps-bin/remove.c index 4665adc7883..c7853d25e13 100644 --- a/bin/xbps-bin/remove.c +++ b/bin/xbps-bin/remove.c @@ -109,7 +109,7 @@ xbps_autoremove_pkgs(void) } void -xbps_remove_pkg(const char *pkgname) +xbps_remove_pkg(const char *pkgname, bool force) { prop_array_t reqby; prop_dictionary_t dict; @@ -133,15 +133,19 @@ xbps_remove_pkg(const char *pkgname) (void)xbps_callback_array_iter_in_dict(dict, "requiredby", list_strings_in_array, NULL); printf("\n\n"); - if (xbps_noyes("Do you want to remove %s?", pkgname) == false) { - printf("Cancelling!\n"); - exit(EXIT_SUCCESS); + if (!force) { + if (!xbps_noyes("Do you want to remove %s?", pkgname)) { + printf("Cancelling!\n"); + exit(EXIT_SUCCESS); + } } printf("Forcing %s-%s for deletion!\n", pkgname, version); } else { - if (xbps_noyes("Do you want to remove %s?", pkgname) == false) { - printf("Cancelling!\n"); - exit(EXIT_SUCCESS); + if (!force) { + if (!xbps_noyes("Do you want to remove %s?", pkgname)) { + printf("Cancelling!\n"); + exit(EXIT_SUCCESS); + } } }