---- pkgset-install.c 16 Nov 2002 00:23:22 -0000 1.82
-+++ pkgset-install.c 16 Jul 2003 10:55:04 -0000 1.82.4.1
-@@ -224,11 +224,11 @@
-
- if (p != pkg && pkg_is_marked(p)) {
- if (req == NULL || pkg_statisfies_req(p, req, 0)) {
-- DBGF("%s -> yes, %s\n", pkg_snprintf_s0(pkg), pkg_snprintf_s1(p));
-- return 1;
-+ DBGF("%s -> yes, %s\n", pkg_snprintf_s0(pkg), pkg_snprintf_s1(p));
-+ return 1;
-+ }
- }
- }
-- }
-
- return 0;
+Index: pkg.c
+===================================================================
+RCS file: /cvsroot/installer/poldek/pkg.c,v
+retrieving revision 1.51.4.5
+diff -u -r1.51.4.5 pkg.c
+--- pkg.c 5 May 2004 16:56:43 -0000 1.51.4.5
++++ pkg.c 11 Aug 2004 13:20:15 -0000
+@@ -949,20 +949,31 @@
+ return rc;
}
-@@ -303,7 +303,7 @@
- struct pkg **candidates, int npkgs,
- struct pkgset *ps, struct upgrade_s *upg)
+
++static int do_pkg_match_req(const struct pkg *pkg, const struct capreq *req,
++ int strict, int pkgnvr)
++{
++ if (pkgnvr && pkg_evr_match_req(pkg, req, strict))
++ return 1;
++ return pkg_caps_match_req(pkg, req, strict);
++}
++
++
+ int pkg_match_req(const struct pkg *pkg, const struct capreq *req, int strict)
{
-- int *ncnfls, i, j, i_min, cnfl_min;
-+ int *ncnfls, i, j, i_best, cnfl_min;
- int i_ver_eq = -1, i_evr_eq = -1;
++ int rc, v = strcmp(pkg->name, capreq_name(req)) == 0;
++
++ rc = do_pkg_match_req(pkg, req, 1, v);
+ #if 0
+- if (strcmp(pkg->name, "nspr") == 0 && strcmp(pkg->name, capreq_name(req)) == 0) {
+- printf("\nMATCH %d %s %s => %d\n", strict,
+- pkg_snprintf_epoch_s(pkg), capreq_snprintf_s(req),
+- pkg_evr_match_req(pkg, req, strict));
++ if (strcmp(capreq_name(req), "XFree86-OpenGL-core") == 0) {
++ printf("\n");
++ DBGF_F("%s, %s => %d; strict %d\n", pkg_snprintf_epoch_s(pkg),
++ capreq_snprintf_s(req), rc, strict);
+ }
+ #endif
+-
+- if (strcmp(pkg->name, capreq_name(req)) == 0 && pkg_evr_match_req(pkg, req, strict))
+- return 1;
+-
+- return pkg_caps_match_req(pkg, req, strict);
++ if (!rc && !strict)
++ rc = do_pkg_match_req(pkg, req, 0, v);
++
++ return rc;
+ }
- DBGF("%s (%d)\n", pkg_snprintf_s(marker), npkgs);
-@@ -345,38 +345,44 @@
- return i_ver_eq;
- cnfl_min = INT_MAX;
-- i_min = -1;
-+ i_best = -1;
- for (i=0; i < npkgs; i++) {
- DBGF("%d. %s %d\n", i, pkg_snprintf_s(candidates[i]), ncnfls[i]);
- if (cnfl_min > ncnfls[i]) {
- cnfl_min = ncnfls[i];
-- i_min = i;
-+ i_best = i;
- }
+Index: pkgset-install.c
+===================================================================
+RCS file: /cvsroot/installer/poldek/pkgset-install.c,v
+retrieving revision 1.82.4.13
+diff -u -r1.82.4.13 pkgset-install.c
+--- pkgset-install.c 6 Jul 2004 18:18:00 -0000 1.82.4.13
++++ pkgset-install.c 11 Aug 2004 13:20:15 -0000
+@@ -706,7 +706,7 @@
+ {
+ struct db_dep *db_dep;
+ struct capreq *req;
+-
++
+ DBGF("VUN %s: %s\n", pkg_snprintf_s(pkg), capreq_snprintf_s(cap));
+ if ((db_dep = db_deps_contains(upg->db_deps, cap, 0)) == NULL) {
+ DBGF(" [1] -> NO in db_deps\n");
+@@ -728,7 +728,7 @@
+ return 1;
}
+
+- if (db_dep->spkg && installset_provides(db_dep->spkg, req, ps, upg)) {
++ if (db_dep->spkg && installset_provides(NULL, req, ps, upg)) {
+ if (verbose > 1)
+ logn(LOGWARN, "cap %s satisfied by install set, shouldn't happen",
+ capreq_snprintf_s(req));
+@@ -837,6 +837,7 @@
+ {
+ int n, i;
+ rpmdb dbh = upg->inst->db->dbh;
++ tn_array *orphans;
-- DBGF("[after cnfls] i_min = %d\n", i_min);
-+ DBGF("[after cnfls] i_best = %d\n", i_best);
- if (cnfl_min == 0) {
- int n = INT_MAX, *nmarks;
-
- nmarks = alloca(npkgs * sizeof(*nmarks));
-
- for (i=0; i < npkgs; i++) {
-+ if (other_version_marked(candidates[i], ps->pkgs, NULL)) {
-+ DBGF("%d. %s other version is already marked, skipped\n",
-+ i, pkg_snprintf_s(candidates[i]));
-+ continue;
-+ }
-+
- nmarks[i] = pkg_drags(candidates[i], ps, upg);
-- DBGF("%d %s -> %d\n", i, pkg_snprintf_s(candidates[i]), nmarks[i]);
-- if (n > nmarks[i]) {
-+ DBGF("%d. %s -> %d\n", i, pkg_snprintf_s(candidates[i]), nmarks[i]);
-+ if (n > nmarks[i])
- n = nmarks[i];
-- }
+ if (upg->inst->flags & INSTS_INSTALL)
+ return;
+@@ -854,88 +855,84 @@
+ n = 0;
+ for (i=0; i < n_array_size(upg->uninst_set->dbpkgs); i++) {
+ struct dbpkg *dbpkg = n_array_nth(upg->uninst_set->dbpkgs, i);
+- if ((dbpkg->flags & DBPKG_TOUCHED) == 0) {
++ if ((dbpkg->flags & DBPKG_TOUCHED))
++ continue;
++
++ dbpkg->flags |= DBPKG_TOUCHED;
++ msgn_i(1, indent, _("%s obsoleted by %s"), dbpkg_snprintf_s(dbpkg),
++ pkg_snprintf_s(pkg));
++ pkg_rm_mark(dbpkg->pkg);
++ db_deps_remove_pkg(upg->db_deps, dbpkg->pkg);
++ db_deps_remove_pkg_caps(upg->db_deps, pkg,
++ (ps->flags & PSDBDIRS_LOADED) == 0);
+
+- msgn_i(1, indent, _("%s obsoleted by %s"), dbpkg_snprintf_s(dbpkg),
+- pkg_snprintf_s(pkg));
+- pkg_rm_mark(dbpkg->pkg);
+- db_deps_remove_pkg(upg->db_deps, dbpkg->pkg);
+- db_deps_remove_pkg_caps(upg->db_deps, pkg,
+- (ps->flags & PSDBDIRS_LOADED) == 0);
-
-+
- if (n == 0 && ncnfls[i] == 0) {
-- i_min = i;
-+ i_best = i;
- break;
+- dbpkg->flags |= DBPKG_TOUCHED;
+-
+- if (dbpkg->pkg->caps) {
+- int j;
+- for (j=0; j < n_array_size(dbpkg->pkg->caps); j++) {
+- struct capreq *cap = n_array_nth(dbpkg->pkg->caps, j);
+- verify_unistalled_cap(indent, cap, dbpkg->pkg, ps, upg);
+- }
++
++ if (dbpkg->pkg->caps) {
++ int j;
++ for (j=0; j < n_array_size(dbpkg->pkg->caps); j++) {
++ struct capreq *cap = n_array_nth(dbpkg->pkg->caps, j);
++ verify_unistalled_cap(indent, cap, dbpkg->pkg, ps, upg);
}
- }
- }
++ }
-- if (i_min == -1)
-- i_min = 0;
-- return i_min;
-+ if (i_best == -1)
-+ i_best = 0;
-+ DBGF("RET %d. %s\n", i_best, pkg_snprintf_s(candidates[i]));
-+ return i_best;
- }
+- if (pkg->fl && dbpkg->pkg->fl) {
+- struct capreq *cap;
+- int j, k;
+-
++ if (pkg->fl && dbpkg->pkg->fl) {
++ struct capreq *cap;
++ int j, k;
++
+
+- cap = alloca(sizeof(cap) + PATH_MAX);
+- memset(cap, 0, sizeof(*cap));
+- cap->_buf[0] = '\0';
+-
+- for (j=0; j < n_array_size(dbpkg->pkg->fl); j++) {
+- struct pkgfl_ent *flent = n_array_nth(dbpkg->pkg->fl, j);
+- char *path, *endp;
+- int path_left_size;
++ cap = alloca(sizeof(cap) + PATH_MAX);
++ memset(cap, 0, sizeof(*cap));
++ cap->_buf[0] = '\0';
++
++ for (j=0; j < n_array_size(dbpkg->pkg->fl); j++) {
++ struct pkgfl_ent *flent = n_array_nth(dbpkg->pkg->fl, j);
++ char *path, *endp;
++ int path_left_size;
+
+- endp = path = &cap->_buf[1];
++ endp = path = &cap->_buf[1];
- #define FINDREQ_BESTSEL 0
-@@ -1009,7 +1015,7 @@
- capreq_snprintf(reqname, 256, req);
+- // not needed cause depdirs module is used
+- //if (n_array_bsearch(ps->depdirs, flent->dirname) == NULL)
+- // continue;
++ // not needed cause depdirs module is used
++ //if (n_array_bsearch(ps->depdirs, flent->dirname) == NULL)
++ // continue;
+
+- if (*flent->dirname != '/')
+- *endp++ = '/';
++ if (*flent->dirname != '/')
++ *endp++ = '/';
+
+- endp = n_strncpy(endp, flent->dirname, PATH_MAX);
+- if (*(endp - 1) != '/')
+- *endp++ = '/';
++ endp = n_strncpy(endp, flent->dirname, PATH_MAX);
++ if (*(endp - 1) != '/')
++ *endp++ = '/';
+
+- path_left_size = PATH_MAX - (endp - path);
++ path_left_size = PATH_MAX - (endp - path);
+
+- for (k=0; k < flent->items; k++) {
+- struct flfile *file = flent->files[k];
++ for (k=0; k < flent->items; k++) {
++ struct flfile *file = flent->files[k];
+
+- n_strncpy(endp, file->basename, path_left_size);
+- verify_unistalled_cap(indent, cap, dbpkg->pkg, ps, upg);
+- }
++ n_strncpy(endp, file->basename, path_left_size);
++ verify_unistalled_cap(indent, cap, dbpkg->pkg, ps, upg);
+ }
+ }
+-
+- n += process_pkg_orphans(dbpkg->pkg, ps, upg);
}
++
++ n += process_pkg_orphans(dbpkg->pkg, ps, upg);
+ }
++
++ if (n == 0)
++ return;
-- DBGF("req %s\n", capreq_snprintf_s(req));
-+ DBGF("%s: REQ %s\n", pkg_snprintf_s(pkg), capreq_snprintf_s(req));
-
- if ((upg->inst->flags & INSTS_EQPKG_ASKUSER) && upg->inst->askpkg_fn)
- tomark_candidates_ptr = &tomark_candidates;
-@@ -1022,7 +1028,8 @@
- goto l_end_loop;
- }
+- if (n)
+- for (i=0; i<n_array_size(upg->orphan_dbpkgs); i++) {
+- struct dbpkg *dbpkg = n_array_nth(upg->orphan_dbpkgs, i);
+- int process_as;
+-
+- if (dbpkg->flags & DBPKG_DEPS_PROCESSED)
+- continue;
++ orphans = pkgs_array_new(n_array_size(upg->orphan_dbpkgs));
++ for (i=0; i<n_array_size(upg->orphan_dbpkgs); i++) {
++ struct dbpkg *dbpkg = n_array_nth(upg->orphan_dbpkgs, i);
++ if ((dbpkg->flags & DBPKG_DEPS_PROCESSED) == 0) {
+ dbpkg->flags |= DBPKG_DEPS_PROCESSED;
+-#if 0
+- if ((pkg = is_pkg_obsoletedby_installset(ps, dbpkg->pkg))) {
+- process_as = PROCESS_AS_NEW;
+-
+- } else
+-#endif
+- {
+- pkg = dbpkg->pkg;
+- process_as = PROCESS_AS_ORPHAN;
+- }
+-
+- process_pkg_deps(indent, pkg, ps, upg, process_as);
++ n_array_push(orphans, pkg_link(dbpkg->pkg));
}
--
-+ DBGF("%s: TOMARK %s\n", pkg_snprintf_s1(pkg),
-+ tomark ? pkg_snprintf_s0(tomark) : "NULL");
- /* don't check foreign dependencies */
- if (process_as == PROCESS_AS_ORPHAN) {
- #if 0 /* buggy, TODO - unmark foreign on adding to uninst_set */
++ }
++
++ for (i=0; i<n_array_size(orphans); i++) {
++ struct pkg *dbpkg = n_array_nth(orphans, i);
++ process_pkg_deps(indent, dbpkg, ps, upg, PROCESS_AS_ORPHAN);
++ }
++ n_array_free(orphans);
+ }
+
+ static