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_
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);

View File

@ -62,7 +62,7 @@ usage(void)
" -r\t\t<rootdir>\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) {
/*

View File

@ -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",