Index: pkgset-install.c =================================================================== RCS file: /cvsroot/installer/poldek/pkgset-install.c,v retrieving revision 1.149 diff -u -r1.149 pkgset-install.c --- pkgset-install.c 3 Nov 2005 00:21:00 -0000 1.149 +++ pkgset-install.c 21 Nov 2005 20:42:04 -0000 @@ -126,6 +126,13 @@ static int marked_for_removal(struct pkg *pkg, struct upgrade_s *upg); +#define mark_package(a, b) do_mark_package(a, b, PKGMARK_MARK); + +static int do_mark_package(struct pkg *pkg, struct upgrade_s *upg, + unsigned mark); + + + /* anyone of pkgs is marked? */ static inline int one_is_marked(struct pkgmark_set *pms, struct pkg *pkgs[], int npkgs) @@ -226,6 +233,30 @@ return install; } +static +struct pkg *installset_obsoletes(const struct pkg *pkg, struct pkgset *ps, + struct upgrade_s *upg) +{ + tn_array *pkgs; + int i; + + pkgs = pkgset_search(ps, PS_SEARCH_OBSL, pkg->name); + DBGF("%s => found %d packages\n", pkg->name, pkgs ? n_array_size(pkgs) : 0); + if (pkgs == NULL) + return NULL; + + for (i=0; its->pms, pkg)) + mark_package(pkg, upg); + + if (pkg_is_marked(upg->ts->pms, pkg)) + return pkg; + } + return NULL; +} + /* looks into Obsoletes only */ static @@ -235,14 +266,21 @@ struct pkg *bypkg = NULL; tn_array *pkgs; int i, best_i; - - if ((pkgs = pkgset_search(ps, PS_SEARCH_CAP, pkg->name)) == NULL) + + pkgs = pkgset_search(ps, PS_SEARCH_CAP, pkg->name); + if (pkgs == NULL) { + DBGF("%s => found 0 packages\n"); return NULL; + } + best_i = select_best_pkg(pkg, pkgs, ps, upg); + DBGF("%s => found %d packages, best=%d\n", pkg->name, n_array_size(pkgs), + best_i); + for (i=best_i; i < n_array_size(pkgs); i++) { struct pkg *p = n_array_nth(pkgs, i); - + if (strcmp(pkg->name, p->name) == 0) continue; @@ -264,6 +302,8 @@ return bypkg; } + + static int other_version_marked(struct pkgmark_set *pms, struct pkg *pkg, tn_array *pkgs, struct capreq *req) @@ -605,8 +645,6 @@ -#define mark_package(a, b) do_mark_package(a, b, PKGMARK_MARK); - static int do_mark_package(struct pkg *pkg, struct upgrade_s *upg, unsigned mark) { @@ -1146,8 +1184,11 @@ p = select_pkg(pkg->name, ps->pkgs, upg); if ((p == NULL || pkg_cmp_evr(p, pkg) == 0) && upg->ts->getop(upg->ts, POLDEK_OP_OBSOLETES)) { - p = select_supersede_pkg(pkg, ps, upg); - *by_obsoletes = 1; + if ((p = installset_obsoletes(pkg, ps, upg)) == NULL) + p = select_supersede_pkg(pkg, ps, upg); + + if (p) + *by_obsoletes = 1; } return p; }