xbps-bin: use -f to bypass questions while installing/removing.

--HG--
extra : convert_revision : edefc4dbf4dbbcdac53579100732e77004a45463
This commit is contained in:
Juan RP 2009-04-09 18:42:07 +02:00
parent 58c6a31297
commit f0f53cb07e
4 changed files with 26 additions and 19 deletions

View file

@ -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_ */

View file

@ -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");

View file

@ -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. */

View file

@ -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);
}
}
}