xbps-bin(8): added -p flag to also purge packages for the 'remove'
and 'autoremove' targets, after successful removal. --HG-- extra : convert_revision : xtraeme%40gmail.com-20100428012613-e2wpzknmrxkjntsd
This commit is contained in:
parent
1771aacfab
commit
e274585c3c
3
NEWS
3
NEWS
@ -1,5 +1,8 @@
|
||||
xbps-0.5.0 (2010-05-01):
|
||||
|
||||
* xbps-bin(8): added new flag '-p' for the 'remove' and 'autoremove'
|
||||
targets, to also purge the package(s) after successful removal.
|
||||
|
||||
* xbps-repo(8): print a warning when registering a repository that has
|
||||
been already added previously.
|
||||
|
||||
|
@ -29,9 +29,9 @@
|
||||
int xbps_install_new_pkg(const char *);
|
||||
int xbps_update_pkg(const char *);
|
||||
int xbps_autoupdate_pkgs(bool);
|
||||
int xbps_autoremove_pkgs(bool);
|
||||
int xbps_autoremove_pkgs(bool, bool);
|
||||
int xbps_exec_transaction(bool);
|
||||
int xbps_remove_installed_pkgs(int, char **, bool);
|
||||
int xbps_remove_installed_pkgs(int, char **, bool, bool);
|
||||
int xbps_check_pkg_integrity(const char *);
|
||||
int xbps_check_pkg_integrity_all(void);
|
||||
int xbps_show_pkg_deps(const char *);
|
||||
|
@ -61,6 +61,7 @@ usage(void)
|
||||
" -V\t\tPrints the xbps release version\n"
|
||||
" Options used by the install/(auto)remove/update targets:\n"
|
||||
" -y\t\tAssume \"yes\" for all questions.\n"
|
||||
" -p\t\tAlso purge package(s) in the (auto)remove targets.\n"
|
||||
" Options used by the purge/reconfigure/remove targets:\n"
|
||||
" -f\t\tForce reconfiguration or removal of files.\n"
|
||||
"\n");
|
||||
@ -119,11 +120,11 @@ main(int argc, char **argv)
|
||||
prop_dictionary_t dict;
|
||||
struct sigaction sa;
|
||||
int i = 0, c, flags = 0, rv = 0;
|
||||
bool yes, verbose;
|
||||
bool yes, verbose, purge;
|
||||
|
||||
yes = verbose = false;
|
||||
yes = verbose = purge = false;
|
||||
|
||||
while ((c = getopt(argc, argv, "Vcfr:vy")) != -1) {
|
||||
while ((c = getopt(argc, argv, "Vcfpr:vy")) != -1) {
|
||||
switch (c) {
|
||||
case 'c':
|
||||
xbps_set_cachedir(optarg);
|
||||
@ -131,6 +132,9 @@ main(int argc, char **argv)
|
||||
case 'f':
|
||||
flags |= XBPS_FLAG_FORCE;
|
||||
break;
|
||||
case 'p':
|
||||
purge = true;
|
||||
break;
|
||||
case 'r':
|
||||
/* To specify the root directory */
|
||||
xbps_set_rootdir(optarg);
|
||||
@ -222,7 +226,7 @@ main(int argc, char **argv)
|
||||
if (argc < 2)
|
||||
usage();
|
||||
|
||||
rv = xbps_remove_installed_pkgs(argc, argv, yes);
|
||||
rv = xbps_remove_installed_pkgs(argc, argv, yes, purge);
|
||||
|
||||
} else if (strcasecmp(argv[0], "show") == 0) {
|
||||
/* Shows info about an installed binary package. */
|
||||
@ -274,7 +278,7 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage();
|
||||
|
||||
rv = xbps_autoremove_pkgs(yes);
|
||||
rv = xbps_autoremove_pkgs(yes, purge);
|
||||
|
||||
} else if (strcasecmp(argv[0], "purge") == 0) {
|
||||
/*
|
||||
|
@ -33,8 +33,36 @@
|
||||
#include "defs.h"
|
||||
#include "../xbps-repo/defs.h"
|
||||
|
||||
static int
|
||||
pkg_remove_and_purge(const char *pkgname, const char *version, bool purge)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
printf("Removing package %s-%s ... ", pkgname, version);
|
||||
(void)fflush(stdout);
|
||||
|
||||
if ((rv = xbps_remove_pkg(pkgname, version, false)) != 0) {
|
||||
fprintf(stderr, "\nE: unable to remove %s-%s (%s).\n",
|
||||
pkgname, version, strerror(errno));
|
||||
return rv;
|
||||
}
|
||||
if (purge) {
|
||||
printf("purging ... ");
|
||||
(void)fflush(stdout);
|
||||
if ((rv = xbps_purge_pkg(pkgname, false)) != 0) {
|
||||
fprintf(stderr, "\nE: unable to purge %s-%s "
|
||||
"(%s).\n", pkgname, version,
|
||||
strerror(errno));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
printf("done.\n");
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
xbps_autoremove_pkgs(bool force)
|
||||
xbps_autoremove_pkgs(bool force, bool purge)
|
||||
{
|
||||
prop_array_t orphans = NULL;
|
||||
prop_object_t obj = NULL;
|
||||
@ -103,8 +131,7 @@ xbps_autoremove_pkgs(bool force)
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
printf("Removing package %s-%s ...\n", pkgname, version);
|
||||
if ((rv = xbps_remove_pkg(pkgname, version, false)) != 0)
|
||||
if ((rv = pkg_remove_and_purge(pkgname, version, purge)) != 0)
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -118,7 +145,7 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
xbps_remove_installed_pkgs(int argc, char **argv, bool force)
|
||||
xbps_remove_installed_pkgs(int argc, char **argv, bool force, bool purge)
|
||||
{
|
||||
prop_array_t reqby;
|
||||
prop_dictionary_t dict;
|
||||
@ -185,13 +212,9 @@ xbps_remove_installed_pkgs(int argc, char **argv, bool force)
|
||||
if (dict == NULL)
|
||||
continue;
|
||||
prop_dictionary_get_cstring_nocopy(dict, "version", &version);
|
||||
printf("Removing package %s-%s ...\n", argv[i], version);
|
||||
if ((rv = xbps_remove_pkg(argv[i], version, false)) != 0) {
|
||||
fprintf(stderr, "E: unable to remove %s-%s (%s).\n",
|
||||
argv[i], version, strerror(errno));
|
||||
if ((rv = pkg_remove_and_purge(argv[i], version, purge)) != 0)
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -36,6 +36,11 @@ OPTIONS
|
||||
with the 'reconfigure target, or to force removal of package files
|
||||
even if its hash doesn't match in the 'purge' and 'remove' targets.
|
||||
|
||||
*-p*::
|
||||
Used currently in the 'remove' and 'autoremove' targets, if enabled
|
||||
after removing a package it is also purged.
|
||||
|
||||
|
||||
*-r* 'rootdir'::
|
||||
Sets the 'root' directory. By default the root directory is
|
||||
set to '/'. Please note that the database directory is always
|
||||
|
Loading…
Reference in New Issue
Block a user