summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorChantry Xavier <shiningxc@gmail.com>2007-06-10 14:40:25 +0200
committerDan McGee <dan@archlinux.org>2007-06-11 03:41:06 +0200
commit8588b4823b579bc41909734f5a13a420d64487d6 (patch)
tree92f8e03efdd0c5aa82963eddde2531227a633947 /lib/libalpm
parent07069cd50291753ff6a99750cce4ea3a5a06ddb6 (diff)
downloadpacman-8588b4823b579bc41909734f5a13a420d64487d6.tar.gz
pacman-8588b4823b579bc41909734f5a13a420d64487d6.tar.xz
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>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/deps.c5
-rw-r--r--lib/libalpm/remove.c2
-rw-r--r--lib/libalpm/sync.c67
3 files changed, 19 insertions, 55 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 37fe2ea5..52fdd9ac 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -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 {
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index ce7ef9e4..920739aa 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -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);
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 5d9e1e6c..f7f24622 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -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;