Add the concept of purging a package, such as with dpkg.

By default a package when is removed, its configuration files
and metadata files won't be removed unless the package is purged.

While here add two targets for xbps-bin:

 * purge [<pkgname>|<all>], passing the "all" string (case insensitive)
   will purge all packages that are in this state (XBPS_PKG_STATE_CONFIG_FILES).

 * reconfigure [<pkgname>|<all>], reconfigures a package or "all"
   if package hasn't been configured. Passing -f reconfigures it again
   even if it's state is ok.

--HG--
extra : convert_revision : bd2d3913ca087a0565b05fa9ee3f9b6d5e3cb934
This commit is contained in:
Juan RP 2009-08-13 16:46:20 +02:00
parent 09cede6d8a
commit 0d04547576
10 changed files with 389 additions and 195 deletions

View file

@ -36,29 +36,41 @@
* package state to installed.
*/
int
xbps_configure_pkg(const char *pkgname, const char *version)
xbps_configure_pkg(const char *pkgname)
{
const char *rootdir;
prop_dictionary_t pkgd;
const char *rootdir, *version;
char *buf;
int rv = 0;
int rv = 0, flags = 0;
pkg_state_t state = 0;
assert(pkgname != NULL);
assert(version != NULL);
rootdir = xbps_get_rootdir();
flags = xbps_get_flags();
if ((rv = xbps_get_pkg_state_installed(pkgname, &state)) != 0)
return rv;
/*
* If package is already installed do nothing, and only
* continue if it's unpacked.
*/
if (state == XBPS_PKG_STATE_INSTALLED)
return 0;
else if (state != XBPS_PKG_STATE_UNPACKED)
if (state == XBPS_PKG_STATE_INSTALLED) {
if ((flags & XBPS_FLAG_FORCE) == 0)
return 0;
} else if (state != XBPS_PKG_STATE_UNPACKED)
return EINVAL;
pkgd = xbps_find_pkg_installed_from_plist(pkgname);
prop_dictionary_get_cstring_nocopy(pkgd, "version", &version);
prop_object_release(pkgd);
printf("%sonfiguring package %s-%s...\n",
flags & XBPS_FLAG_FORCE ? "Rec" : "C", pkgname, version);
if (strcmp(rootdir, "") == 0)
rootdir = "/";
if (chdir(rootdir) == -1)
return errno;
buf = xbps_xasprintf(".%s/metadata/%s/INSTALL",
XBPS_META_PATH, pkgname);
if (buf == NULL)