summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChantry Xavier <shiningxc@gmail.com>2007-06-10 04:00:50 +0200
committerDan McGee <dan@archlinux.org>2007-06-10 21:25:01 -0400
commit796cc4e6ed06644081f05c1aff4624a6e11eade3 (patch)
tree7347c60e80a404e8cc4a2d47ed41a18dee6ecb41
parent1da78a7d2551579a744267162057245309284516 (diff)
downloadpacman-796cc4e6ed06644081f05c1aff4624a6e11eade3.tar.xz
Fix for removing a package that is no longer needed
Fix for remove041 pactest. You could not remove a package before that was provided by something else already installed on the system. This fixes this problem. Reference: http://archlinux.org/pipermail/pacman-dev/2007-April/008131.html http://archlinux.org/pipermail/pacman-dev/2007-April/008134.html Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/deps.c78
1 files changed, 42 insertions, 36 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index bcb7ef53..37fe2ea5 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -349,50 +349,56 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
} else if(op == PM_TRANS_TYPE_REMOVE) {
/* check requiredby fields */
for(i = packages; i; i = i->next) {
- pmpkg_t *tp = i->data;
- if(tp == NULL) {
+ pmpkg_t *rmpkg = alpm_list_getdata(i);
+
+ if(rmpkg == NULL) {
+ _alpm_log(PM_LOG_DEBUG, _("null package found in package list"));
continue;
}
+ for(j = alpm_pkg_get_requiredby(rmpkg); j; j = j->next) {
+ pmpkg_t *p;
+ found = 0;
+ if(_alpm_pkg_find(j->data, packages)) {
+ /* package also in the remove list, so don't worry about it */
+ continue;
+ }
- found=0;
- for(j = alpm_pkg_get_requiredby(tp); j; j = j->next) {
- /* Search for 'reqname' in packages for removal */
- char *reqname = j->data;
- alpm_list_t *x = NULL;
- for(x = packages; x; x = x->next) {
- pmpkg_t *xp = x->data;
- if(strcmp(reqname, alpm_pkg_get_name(xp)) == 0) {
- found = 1;
- break;
- }
+ if((p = _alpm_db_get_pkgfromcache(db, j->data)) == NULL) {
+ /* hmmm... package isn't installed... */
+ continue;
}
- if(!found) {
- /* check if a package in trans->packages provides this package */
- for(k = trans->packages; !found && k; k=k->next) {
- pmpkg_t *spkg = NULL;
- if(trans->type == PM_TRANS_TYPE_SYNC) {
- pmsyncpkg_t *sync = k->data;
- spkg = sync->pkg;
- } else {
- spkg = k->data;
- }
- if(spkg) {
- if(alpm_list_find_str(alpm_pkg_get_provides(spkg), tp->name)) {
- found = 1;
+ for(k = alpm_pkg_get_depends(p); k; k = k->next) {
+ pmdepend_t *depend = alpm_splitdep(k->data);
+ if(depend == NULL) {
+ continue;
+ }
+ /* if rmpkg satisfied this dep, try to find an other satisfier
+ * (which won't be removed)*/
+ if(alpm_depcmp(rmpkg, depend)) {
+ int satisfied = 0;
+ for(l = _alpm_db_get_pkgcache(db); l; l = l->next) {
+ pmpkg_t *pkg = l->data;
+ if(alpm_depcmp(pkg, depend) && !_alpm_pkg_find(alpm_pkg_get_name(pkg), packages)) {
+ _alpm_log(PM_LOG_DEBUG, _("checkdeps: dependency '%s' satisfied by installed package '%s'"),
+ depend->name, alpm_pkg_get_name(pkg));
+ satisfied = 1;
+ break;
}
}
- }
- if(!found) {
- _alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"),
- reqname, alpm_pkg_get_name(tp));
- miss = _alpm_depmiss_new(alpm_pkg_get_name(tp), PM_DEP_TYPE_DEPEND,
- PM_DEP_MOD_ANY, j->data, NULL);
- if(!_alpm_depmiss_isin(miss, baddeps)) {
- baddeps = alpm_list_add(baddeps, miss);
- } else {
- FREE(miss);
+
+ 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);
+ if(!_alpm_depmiss_isin(miss, baddeps)) {
+ baddeps = alpm_list_add(baddeps, miss);
+ } else {
+ FREE(miss);
+ }
}
}
+ free(depend);
}
}
}