1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-11 03:54:59 -05:00

Ensure correct and consistent usage of depmiss

See comment from Nagy here :
http://www.archlinux.org/pipermail/pacman-dev/2007-April/008134.html
This also makes easier correct usage of checkdeps in sync.c,
which fixes sync901 pactest (and so bug 6057).

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Chantry Xavier 2007-06-10 14:40:25 +02:00 committed by Dan McGee
parent 07069cd502
commit 8588b4823b
5 changed files with 22 additions and 58 deletions

View File

@ -389,8 +389,9 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
if(!satisfied) {
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s which requires %s"),
alpm_pkg_get_name(p), alpm_pkg_get_name(rmpkg));
miss = _alpm_depmiss_new(alpm_pkg_get_name(rmpkg), PM_DEP_TYPE_DEPEND,
PM_DEP_MOD_ANY, alpm_pkg_get_name(p), NULL);
miss = _alpm_depmiss_new(alpm_pkg_get_name(p),
PM_DEP_TYPE_DEPEND, depend->mod, depend->name,
depend->version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
baddeps = alpm_list_add(baddeps, miss);
} else {

View File

@ -115,7 +115,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
alpm_list_t *i;
for(i = lp; i; i = i->next) {
pmdepmissing_t *miss = (pmdepmissing_t *)i->data;
pmpkg_t *info = _alpm_db_scan(db, miss->depend.name);
pmpkg_t *info = _alpm_db_scan(db, miss->target);
if(info) {
_alpm_log(PM_LOG_DEBUG, _("pulling %s in the targets list"), alpm_pkg_get_name(info));
trans->packages = alpm_list_add(trans->packages, info);

View File

@ -684,63 +684,26 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
_alpm_log(PM_LOG_DEBUG, _("checking dependencies of packages designated for removal"));
deps = _alpm_checkdeps(trans, db_local, PM_TRANS_TYPE_REMOVE, list);
if(deps) {
/* Check if broken dependencies are fixed by packages we are installing */
int errorout = 0;
for(i = deps; i; i = i->next) {
pmdepmissing_t *miss = i->data;
if(!_alpm_sync_find(trans->packages, miss->depend.name)) {
int pfound = 0;
alpm_list_t *k;
/* If miss->depend.name depends on something that miss->target and a
* package in final both provide, then it's okay... */
pmpkg_t *leavingp = _alpm_db_get_pkgfromcache(db_local, miss->target);
pmpkg_t *conflictp = _alpm_db_get_pkgfromcache(db_local, miss->depend.name);
if(!leavingp || !conflictp) {
_alpm_log(PM_LOG_ERROR, _("something has gone horribly wrong"));
ret = -1;
goto cleanup;
}
/* Look through the upset package's dependencies and try to match one up
* to a provisio from the package we want to remove */
for(k = alpm_pkg_get_depends(conflictp); k && !pfound; k = k->next) {
alpm_list_t *m;
for(m = alpm_pkg_get_provides(leavingp); m && !pfound; m = m->next) {
if(!strcmp(k->data, m->data)) {
/* Found a match -- now look through final for a package that
* provides the same thing. If none are found, then it truly
* is an unresolvable conflict. */
alpm_list_t *n, *o;
for(n = trans->packages; n && !pfound; n = n->next) {
pmsyncpkg_t *sp = n->data;
pmpkg_t *sppkg = sp->pkg;
for(o = alpm_pkg_get_provides(sppkg); o && !pfound; o = o->next) {
if(!strcmp(m->data, o->data)) {
/* found matching provisio -- we're good to go */
_alpm_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s' -- conflict aborted"),
alpm_pkg_get_name(sppkg), (char *)o->data);
pfound = 1;
}
}
}
}
}
}
if(!pfound) {
if(!errorout) {
errorout = 1;
}
if(data) {
if((miss = malloc(sizeof(pmdepmissing_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t));
FREELIST(*data);
pm_errno = PM_ERR_MEMORY;
ret = -1;
goto cleanup;
}
*miss = *(pmdepmissing_t *)i->data;
*data = alpm_list_add(*data, miss);
}
alpm_list_t *l;
int satisfied = 0;
for(l = trans->packages; l && !satisfied; l = l->next) {
pmsyncpkg_t *sp = l->data;
pmpkg_t *sppkg = sp->pkg;
if(alpm_depcmp(sppkg, &(miss->depend))) {
_alpm_log(PM_LOG_DEBUG, _("sync: dependency '%s' satisfied by package '%s'"),
miss->depend.name, alpm_pkg_get_name(sppkg));
satisfied = 1;
}
}
if(!satisfied) {
errorout++;
*data = alpm_list_add(*data, miss);
}
}
if(errorout) {
pm_errno = PM_ERR_UNSATISFIED_DEPS;

View File

@ -114,7 +114,7 @@ int pacman_remove(alpm_list_t *targets)
case PM_ERR_UNSATISFIED_DEPS:
for(i = data; i; i = alpm_list_next(i)) {
pmdepmissing_t *miss = alpm_list_getdata(i);
printf(_(":: %s is required by %s\n"), alpm_dep_get_target(miss),
printf(_(":: %s depends on %s\n"), alpm_dep_get_target(miss),
alpm_dep_get_name(miss));
}
alpm_list_free(data);

View File

@ -626,8 +626,8 @@ int pacman_sync(alpm_list_t *targets)
case PM_ERR_UNSATISFIED_DEPS:
for(i = data; i; i = alpm_list_next(i)) {
pmdepmissing_t *miss = alpm_list_getdata(i);
printf(":: %s %s %s", alpm_dep_get_target(miss), _("requires"),
alpm_dep_get_name(miss));
printf(_(":: %s depends on %s\n"), alpm_dep_get_target(miss),
alpm_dep_get_name(miss));
switch(alpm_dep_get_mod(miss)) {
case PM_DEP_MOD_ANY:
break;