xbps-bin: make the 'autoremove' target respect -f flag to bypass question.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20091207055227-8kiks1f3k2tuoe2z
This commit is contained in:
Juan RP 2009-12-07 06:52:27 +01:00
parent 972af411d1
commit 2d68cec780
3 changed files with 14 additions and 19 deletions

View File

@ -27,7 +27,7 @@
#define _XBPS_BIN_DEFS_H_ #define _XBPS_BIN_DEFS_H_
int xbps_exec_transaction(const char *, bool, bool); 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_remove_installed_pkg(const char *, bool);
int xbps_check_pkg_integrity(const char *); int xbps_check_pkg_integrity(const char *);
int xbps_check_pkg_integrity_all(void); int xbps_check_pkg_integrity_all(void);

View File

@ -62,7 +62,7 @@ usage(void)
" -r\t\t<rootdir>\n" " -r\t\t<rootdir>\n"
" -v\t\tShows verbose messages\n" " -v\t\tShows verbose messages\n"
" -V\t\tPrints the xbps release version\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" " -f\t\tBypasses the questions.\n"
"\n"); "\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -256,7 +256,7 @@ main(int argc, char **argv)
if (argc != 1) if (argc != 1)
usage(); usage();
rv = xbps_autoremove_pkgs(); rv = xbps_autoremove_pkgs(force);
} else if (strcasecmp(argv[0], "purge") == 0) { } else if (strcasecmp(argv[0], "purge") == 0) {
/* /*

View File

@ -34,7 +34,7 @@
#include "../xbps-repo/defs.h" #include "../xbps-repo/defs.h"
int int
xbps_autoremove_pkgs(void) xbps_autoremove_pkgs(bool force)
{ {
prop_array_t orphans; prop_array_t orphans;
prop_object_t obj; prop_object_t obj;
@ -88,7 +88,7 @@ xbps_autoremove_pkgs(void)
prop_object_iterator_reset(iter); prop_object_iterator_reset(iter);
printf("\n\n"); 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"); printf("Cancelled!\n");
goto out2; goto out2;
} }
@ -123,6 +123,7 @@ xbps_remove_installed_pkg(const char *pkgname, bool force)
prop_dictionary_t dict; prop_dictionary_t dict;
const char *version; const char *version;
int rv = 0; int rv = 0;
bool reqby_force = false;
/* /*
* First check if package is required by other packages. * 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, (void)xbps_callback_array_iter_in_dict(dict,
"requiredby", list_strings_in_array, NULL); "requiredby", list_strings_in_array, NULL);
printf("\n\n"); printf("\n\n");
if (!force) { reqby_force = true;
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;
}
}
} }
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); printf("Removing package %s-%s ...\n", pkgname, version);
if ((rv = xbps_remove_pkg(pkgname, version, false)) != 0) { if ((rv = xbps_remove_pkg(pkgname, version, false)) != 0) {
printf("Unable to remove %s-%s (%s).\n", printf("Unable to remove %s-%s (%s).\n",