Repair upgrades of preserve packages, i.e kernel.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20100125052754-6xri8lfmykhof5dz
This commit is contained in:
Juan RP 2010-01-25 06:27:54 +01:00
parent 7f343b8dbe
commit 17d87b3559
4 changed files with 17 additions and 13 deletions

View File

@ -474,7 +474,8 @@ replace_packages(prop_object_iterator_t iter, const char *pkgver)
prop_object_release(instd);
version = xbps_get_pkg_version(pkgver);
if ((rv = xbps_remove_pkg(reppkgn, version, false)) != 0) {
rv = xbps_remove_pkg(reppkgn, version, false, false);
if (rv != 0) {
fprintf(stderr, "xbps-bin: couldn't remove %s (%s)\n",
reppkgn, strerror(rv));
return rv;
@ -607,7 +608,7 @@ exec_transaction(struct transaction *trans)
printf("Removing %s-%s before installing new "
"version ...\n", pkgname, instver);
rv = xbps_remove_pkg(pkgname, version, true);
rv = xbps_remove_pkg(pkgname, version, true, essential);
if (rv != 0) {
fprintf(stderr, "xbps-bin: error "
"%s %s-%s (%s)\n", essential ?

View File

@ -105,7 +105,7 @@ xbps_autoremove_pkgs(bool force)
goto out;
}
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, false)) != 0)
goto out2;
}
out2:
@ -185,7 +185,8 @@ xbps_remove_installed_pkgs(int argc, char **argv, bool force)
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) {
rv = xbps_remove_pkg(argv[i], version, false, false);
if (rv != 0) {
fprintf(stderr, "E: unable to remove %s-%s (%s).\n",
argv[i], version, strerror(errno));
return rv;

View File

@ -640,10 +640,12 @@ void xbps_regpkgs_dictionary_release(void);
* @param[in] update If true, and depending if \a pkgname is an
* <em>essential</em> package, some steps will be skipped. See in the
* detailed description section for more information.
* @param[in] essential Set it to true if \a pkgname is essential.
*
* @return 0 on success, or an errno value otherwise.
*/
int xbps_remove_pkg(const char *pkgname, const char *version, bool update);
int xbps_remove_pkg(const char *pkgname, const char *version,
bool update, bool essential);
/**
* Remove files defined in a proplib array as specified by \a key

View File

@ -174,13 +174,14 @@ xbps_remove_pkg_files(prop_dictionary_t dict, const char *key)
}
int
xbps_remove_pkg(const char *pkgname, const char *version, bool update)
xbps_remove_pkg(const char *pkgname, const char *version,
bool update, bool essential)
{
prop_dictionary_t dict, pkgd;
prop_dictionary_t dict;
const char *rootdir = xbps_get_rootdir();
char *path, *buf;
int rv = 0;
bool essential = false, prepostf = false;
bool prepostf = false;
assert(pkgname != NULL);
assert(version != NULL);
@ -188,12 +189,9 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update)
/*
* Check if pkg is installed before anything else.
*/
if ((pkgd = xbps_find_pkg_dict_installed(pkgname, false)) == NULL)
if (!xbps_check_is_installed_pkgname(pkgname))
return ENOENT;
prop_dictionary_get_bool(pkgd, "essential", &essential);
prop_object_release(pkgd);
if (strcmp(rootdir, "") == 0)
rootdir = "/";
@ -230,8 +228,10 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update)
* entries and continue. Its files will be overwritten later in
* the unpack phase.
*/
if (essential && update)
if (essential && update) {
free(buf);
return xbps_requiredby_pkg_remove(pkgname);
}
/*
* Remove links, files and dirs.