1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

Fix overzealous package removal with unmet dependencies

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>

[Allan: Remove expected failure from fixed pactests]
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Andrew Gregory 2012-09-16 12:53:40 -04:00 committed by Allan McRae
parent 927fdc0079
commit 5a247ccbd4
4 changed files with 41 additions and 47 deletions

View File

@ -725,7 +725,7 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs,
alpm_list_t *rem, alpm_list_t **data) alpm_list_t *rem, alpm_list_t **data)
{ {
int ret = 0; int ret = 0;
alpm_list_t *i, *j; alpm_list_t *j;
alpm_list_t *targ; alpm_list_t *targ;
alpm_list_t *deps = NULL; alpm_list_t *deps = NULL;
alpm_list_t *packages_copy; alpm_list_t *packages_copy;
@ -742,49 +742,49 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs,
*packages = alpm_list_add(*packages, pkg); *packages = alpm_list_add(*packages, pkg);
_alpm_log(handle, ALPM_LOG_DEBUG, "started resolving dependencies\n"); _alpm_log(handle, ALPM_LOG_DEBUG, "started resolving dependencies\n");
for(i = alpm_list_last(*packages); i; i = i->next) { targ = alpm_list_add(NULL, pkg);
alpm_pkg_t *tpkg = i->data; deps = alpm_checkdeps(handle, localpkgs, rem, targ, 0);
targ = alpm_list_add(NULL, tpkg); alpm_list_free(targ);
deps = alpm_checkdeps(handle, localpkgs, rem, targ, 0); targ = NULL;
alpm_list_free(targ);
for(j = deps; j; j = j->next) { for(j = deps; j; j = j->next) {
alpm_depmissing_t *miss = j->data; alpm_depmissing_t *miss = j->data;
alpm_depend_t *missdep = miss->depend; alpm_depend_t *missdep = miss->depend;
/* check if one of the packages in the [*packages] list already satisfies /* check if one of the packages in the [*packages] list already satisfies
* this dependency */ * this dependency */
if(find_dep_satisfier(*packages, missdep)) { if(find_dep_satisfier(*packages, missdep)) {
_alpm_depmiss_free(miss); _alpm_depmiss_free(miss);
continue; continue;
} }
/* check if one of the packages in the [preferred] list already satisfies /* check if one of the packages in the [preferred] list already satisfies
* this dependency */ * this dependency */
alpm_pkg_t *spkg = find_dep_satisfier(preferred, missdep); alpm_pkg_t *spkg = find_dep_satisfier(preferred, missdep);
if(!spkg) { if(!spkg) {
/* find a satisfier package in the given repositories */ /* find a satisfier package in the given repositories */
spkg = resolvedep(handle, missdep, handle->dbs_sync, *packages, 0); spkg = resolvedep(handle, missdep, handle->dbs_sync, *packages, 0);
} }
if(!spkg) { if(spkg && _alpm_resolvedeps(handle, localpkgs, spkg, preferred, packages, rem, data) == 0) {
handle->pm_errno = ALPM_ERR_UNSATISFIED_DEPS; _alpm_log(handle, ALPM_LOG_DEBUG,
char *missdepstring = alpm_dep_compute_string(missdep); "pulling dependency %s (needed by %s)\n",
_alpm_log(handle, ALPM_LOG_WARNING, spkg->name, pkg->name);
_("cannot resolve \"%s\", a dependency of \"%s\"\n"), _alpm_depmiss_free(miss);
missdepstring, tpkg->name); } else if(resolvedep(handle, missdep, (targ = alpm_list_add(NULL, handle->db_local)), rem, 0)) {
free(missdepstring); _alpm_depmiss_free(miss);
if(data) { } else {
*data = alpm_list_add(*data, miss); handle->pm_errno = ALPM_ERR_UNSATISFIED_DEPS;
} char *missdepstring = alpm_dep_compute_string(missdep);
ret = -1; _alpm_log(handle, ALPM_LOG_WARNING,
} else { _("cannot resolve \"%s\", a dependency of \"%s\"\n"),
_alpm_log(handle, ALPM_LOG_DEBUG, missdepstring, pkg->name);
"pulling dependency %s (needed by %s)\n", free(missdepstring);
spkg->name, tpkg->name); if(data) {
*packages = alpm_list_add(*packages, spkg); *data = alpm_list_add(*data, miss);
_alpm_depmiss_free(miss); }
} ret = -1;
} }
alpm_list_free(deps);
} }
alpm_list_free(targ);
alpm_list_free(deps);
if(ret != 0) { if(ret != 0) {
alpm_list_free(*packages); alpm_list_free(*packages);

View File

@ -24,5 +24,3 @@ self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_VERSION=glibc|1.0-1") self.addrule("PKG_VERSION=glibc|1.0-1")
self.addrule("PKG_VERSION=gcc-libs|1.0-1") self.addrule("PKG_VERSION=gcc-libs|1.0-1")
self.addrule("PKG_VERSION=pcre|1.0-2") self.addrule("PKG_VERSION=pcre|1.0-2")
self.expectfailure = True

View File

@ -24,5 +24,3 @@ self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_VERSION=c_glibc|1.0-1") self.addrule("PKG_VERSION=c_glibc|1.0-1")
self.addrule("PKG_VERSION=b_gcc-libs|1.0-1") self.addrule("PKG_VERSION=b_gcc-libs|1.0-1")
self.addrule("PKG_VERSION=a_pcre|1.0-2") self.addrule("PKG_VERSION=a_pcre|1.0-2")
self.expectfailure = True

View File

@ -17,5 +17,3 @@ self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_EXIST=package") self.addrule("PKG_EXIST=package")
self.addrule("PKG_EXIST=dep") self.addrule("PKG_EXIST=dep")
self.addrule("PKG_VERSION=dep|1.0-1") self.addrule("PKG_VERSION=dep|1.0-1")
self.expectfailure = True