Look in target-list first to resolve dependencies
This fixes a bug introduced by my previous changes which changes the behavior of IgnorePkg/IgnoreGroup to allow the user to remove unresolvable packages from the transaction. The bug is that the target-list was no longer being consulted first to resolve dependencies, which means that if two packages in the sync database satisfied a dependency, and the user explicitly requested one of those two packages in the sync, the other package was still being pulled in. A new test was added, sync993.py, to verify the desired behavior. Signed-off-by: Bryan Ischo <bji-keyword-pacman.3644cb@www.ischo.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
d70465decc
commit
db3e166503
4 changed files with 38 additions and 10 deletions
|
@ -594,8 +594,8 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs,
|
||||||
* unmodified by this function
|
* unmodified by this function
|
||||||
*/
|
*/
|
||||||
int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *pkg,
|
int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *pkg,
|
||||||
alpm_list_t **packages, alpm_list_t *remove,
|
alpm_list_t *preferred, alpm_list_t **packages,
|
||||||
alpm_list_t **data)
|
alpm_list_t *remove, alpm_list_t **data)
|
||||||
{
|
{
|
||||||
alpm_list_t *i, *j;
|
alpm_list_t *i, *j;
|
||||||
alpm_list_t *targ;
|
alpm_list_t *targ;
|
||||||
|
@ -632,17 +632,21 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *pkg,
|
||||||
if(_alpm_find_dep_satisfier(*packages, missdep)) {
|
if(_alpm_find_dep_satisfier(*packages, missdep)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* find a satisfier package in the given repositories */
|
/* check if one of the packages in the [preferred] list already satisfies this dependency */
|
||||||
pmpkg_t *spkg = _alpm_resolvedep(missdep, dbs_sync, *packages, 0);
|
pmpkg_t *spkg = _alpm_find_dep_satisfier(preferred, missdep);
|
||||||
|
if(!spkg) {
|
||||||
|
/* find a satisfier package in the given repositories */
|
||||||
|
spkg = _alpm_resolvedep(missdep, dbs_sync, *packages, 0);
|
||||||
|
}
|
||||||
if(!spkg) {
|
if(!spkg) {
|
||||||
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
||||||
char *missdepstring = alpm_dep_compute_string(missdep);
|
char *missdepstring = alpm_dep_compute_string(missdep);
|
||||||
_alpm_log(PM_LOG_WARNING, _("cannot resolve \"%s\", a dependency of \"%s\"\n"),
|
_alpm_log(PM_LOG_WARNING, _("cannot resolve \"%s\", a dependency of \"%s\"\n"),
|
||||||
missdepstring, tpkg->name);
|
missdepstring, tpkg->name);
|
||||||
free(missdepstring);
|
free(missdepstring);
|
||||||
if(data) {
|
if(data) {
|
||||||
pmdepmissing_t *missd = _alpm_depmiss_new(miss->target,
|
pmdepmissing_t *missd = _alpm_depmiss_new(miss->target,
|
||||||
miss->depend, miss->causingpkg);
|
miss->depend, miss->causingpkg);
|
||||||
if(missd) {
|
if(missd) {
|
||||||
*data = alpm_list_add(*data, missd);
|
*data = alpm_list_add(*data, missd);
|
||||||
}
|
}
|
||||||
|
@ -654,7 +658,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *pkg,
|
||||||
return(-1);
|
return(-1);
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_DEBUG, "pulling dependency %s (needed by %s)\n",
|
_alpm_log(PM_LOG_DEBUG, "pulling dependency %s (needed by %s)\n",
|
||||||
alpm_pkg_get_name(spkg), alpm_pkg_get_name(tpkg));
|
alpm_pkg_get_name(spkg), alpm_pkg_get_name(tpkg));
|
||||||
*packages = alpm_list_add(*packages, spkg);
|
*packages = alpm_list_add(*packages, spkg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,8 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, int reverse);
|
||||||
void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit);
|
void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit);
|
||||||
pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs, alpm_list_t *excluding, int prompt);
|
pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs, alpm_list_t *excluding, int prompt);
|
||||||
int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *pkg,
|
int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *pkg,
|
||||||
alpm_list_t **packages, alpm_list_t *remove, alpm_list_t **data);
|
alpm_list_t *preferred, alpm_list_t **packages, alpm_list_t *remove,
|
||||||
|
alpm_list_t **data);
|
||||||
int _alpm_dep_edge(pmpkg_t *pkg1, pmpkg_t *pkg2);
|
int _alpm_dep_edge(pmpkg_t *pkg1, pmpkg_t *pkg2);
|
||||||
pmdepend_t *_alpm_splitdep(const char *depstring);
|
pmdepend_t *_alpm_splitdep(const char *depstring);
|
||||||
pmpkg_t *_alpm_find_dep_satisfier(alpm_list_t *pkgs, pmdepend_t *dep);
|
pmpkg_t *_alpm_find_dep_satisfier(alpm_list_t *pkgs, pmdepend_t *dep);
|
||||||
|
|
|
@ -348,6 +348,7 @@ static int compute_download_size(pmpkg_t *newpkg)
|
||||||
int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data)
|
int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data)
|
||||||
{
|
{
|
||||||
alpm_list_t *deps = NULL;
|
alpm_list_t *deps = NULL;
|
||||||
|
alpm_list_t *preferred = NULL;
|
||||||
alpm_list_t *unresolvable = NULL;
|
alpm_list_t *unresolvable = NULL;
|
||||||
alpm_list_t *remove = NULL; /* allow checkdeps usage with trans->packages */
|
alpm_list_t *remove = NULL; /* allow checkdeps usage with trans->packages */
|
||||||
alpm_list_t *i, *j;
|
alpm_list_t *i, *j;
|
||||||
|
@ -370,19 +371,21 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
|
||||||
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
|
||||||
_alpm_log(PM_LOG_DEBUG, "resolving target's dependencies\n");
|
_alpm_log(PM_LOG_DEBUG, "resolving target's dependencies\n");
|
||||||
|
|
||||||
/* build remove list for resolvedeps */
|
/* build remove list and preferred list for resolvedeps */
|
||||||
for(i = trans->packages; i; i = i->next) {
|
for(i = trans->packages; i; i = i->next) {
|
||||||
pmpkg_t *spkg = i->data;
|
pmpkg_t *spkg = i->data;
|
||||||
for(j = spkg->removes; j; j = j->next) {
|
for(j = spkg->removes; j; j = j->next) {
|
||||||
remove = alpm_list_add(remove, j->data);
|
remove = alpm_list_add(remove, j->data);
|
||||||
}
|
}
|
||||||
|
preferred = alpm_list_add(preferred, spkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Resolve packages in the transaction one at a time, in addtion
|
/* Resolve packages in the transaction one at a time, in addtion
|
||||||
building up a list of packages which could not be resolved. */
|
building up a list of packages which could not be resolved. */
|
||||||
for(i = trans->packages; i; i = i->next) {
|
for(i = trans->packages; i; i = i->next) {
|
||||||
pmpkg_t *pkg = i->data;
|
pmpkg_t *pkg = i->data;
|
||||||
if(_alpm_resolvedeps(db_local, dbs_sync, pkg, &resolved, remove, data) == -1) {
|
if(_alpm_resolvedeps(db_local, dbs_sync, pkg, preferred,
|
||||||
|
&resolved, remove, data) == -1) {
|
||||||
unresolvable = alpm_list_add(unresolvable, pkg);
|
unresolvable = alpm_list_add(unresolvable, pkg);
|
||||||
}
|
}
|
||||||
/* Else, [resolved] now additionally contains [pkg] and all of its
|
/* Else, [resolved] now additionally contains [pkg] and all of its
|
||||||
|
|
20
pactest/tests/sync993.py
Normal file
20
pactest/tests/sync993.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
self.description = "Choose a dependency satisfier (target-list vs. database)"
|
||||||
|
|
||||||
|
sp1 = pmpkg("pkg1")
|
||||||
|
sp1.depends = ["dep"]
|
||||||
|
|
||||||
|
sp2 = pmpkg("pkg2")
|
||||||
|
sp2.provides = ["dep"]
|
||||||
|
|
||||||
|
sp3 = pmpkg("pkg3")
|
||||||
|
sp3.provides = ["dep"]
|
||||||
|
|
||||||
|
for p in sp1, sp2, sp3:
|
||||||
|
self.addpkg2db("sync", p)
|
||||||
|
|
||||||
|
self.args = "-S pkg1 pkg3"
|
||||||
|
|
||||||
|
self.addrule("PACMAN_RETCODE=0")
|
||||||
|
self.addrule("PKG_EXIST=pkg1")
|
||||||
|
self.addrule("!PKG_EXIST=pkg2")
|
||||||
|
self.addrule("PKG_EXIST=pkg3")
|
Loading…
Add table
Reference in a new issue