Also look at obsoletes of installed packages, like newer versions of rpm do
authorMichael Schroeder <mls@suse.de>
Mon, 12 Apr 2010 14:06:02 +0000 (16:06 +0200)
committerMichael Schroeder <mls@suse.de>
Mon, 12 Apr 2010 14:06:02 +0000 (16:06 +0200)
src/pool.h
src/repo.h
src/rules.c
src/rules.h
src/solverdebug.c
src/solverdebug.h

index 7459143..f5d1dfb 100644 (file)
@@ -80,6 +80,7 @@ struct _Pool {
   int obsoleteusesprovides;    /* true: obsoletes are matched against provides, not names */
   int implicitobsoleteusesprovides;    /* true: implicit obsoletes due to same name are matched against provides, not names */
   int obsoleteusescolors;      /* true: obsoletes check arch color */
+  int noinstalledobsoletes;    /* true: ignore obsoletes of installed packages */
   int novirtualconflicts;      /* true: conflicts on names, not on provides */
   int allowselfconflicts;      /* true: packages which conflict with itself are installable */
 #ifdef MULTI_SEMANTICS
index 3d16151..9adce29 100644 (file)
@@ -114,7 +114,7 @@ static inline Id repo_add_solvable_block(Repo *repo, int count)
 
 static inline Repo *pool_id2repo(Pool *pool, Id repoid)
 {
-  return pool->repos[repoid - 1];
+  return repoid ? pool->repos[repoid - 1] : 0;
 }
 
 static inline int pool_installable(const Pool *pool, Solvable *s)
index 4903d3b..cc14c88 100644 (file)
@@ -383,9 +383,9 @@ solver_addrule(Solver *solv, Id p, Id d)
 
 /*
  *  special multiversion patch conflict handling:
- *  a patch conflict is also satisfied, if some other
+ *  a patch conflict is also satisfied if some other
  *  version with the same name/arch that doesn't conflict
- *  get's installed. The generated rule is thus:
+ *  gets installed. The generated rule is thus:
  *  -patch|-cpack|opack1|opack2|...
  */
 static Id
@@ -656,12 +656,14 @@ solver_addrpmrulesforsolvable(Solver *solv, Solvable *s, Map *m)
        }
 
       /*-----------------------------------------
-       * check obsoletes if not installed
-       * (only installation will trigger the obsoletes in rpm)
+       * check obsoletes and implicit obsoletes of a package
+       * if ignoreinstalledsobsoletes is not set, we're also checking
+       * obsoletes of installed packages (like newer rpm versions)
        */
-      if (!installed || pool->solvables[n].repo != installed)
-       {                              /* not installed */
+      if ((!installed || s->repo != installed) || !pool->noinstalledobsoletes)
+       {
          int noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, n);
+         int isinstalled = (installed && s->repo == installed);
          if (s->obsoletes && !noobs)
            {
              obsp = s->repo->idarraydata + s->obsoletes;
@@ -672,30 +674,49 @@ solver_addrpmrulesforsolvable(Solver *solv, Solvable *s, Map *m)
                  FOR_PROVIDES(p, pp, obs)
                    {
                      Solvable *ps = pool->solvables + p;
+                     if (p == n)
+                       continue;
+                     if (isinstalled && dontfix && ps->repo == installed)
+                       continue;       /* don't repair installed/installed problems */
                      if (!pool->obsoleteusesprovides /* obsoletes are matched names, not provides */
                          && !pool_match_nevr(pool, ps, obs))
                        continue;
                      if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
                        continue;
-                     addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_PACKAGE_OBSOLETES, obs);
+                     if (!isinstalled)
+                       addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_PACKAGE_OBSOLETES, obs);
+                     else
+                       addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES, obs);
                    }
                }
            }
-         FOR_PROVIDES(p, pp, s->name)
+         /* check implicit obsoletes
+           * for installed packages we only need to check installed/installed problems (and
+           * only when dontfix is not set), as the others are picked up when looking at the
+           * uninstalled package.
+           */
+         if (!isinstalled || !dontfix)
            {
-             Solvable *ps = pool->solvables + p;
-             /* we still obsolete packages with same nevra, like rpm does */
-             /* (actually, rpm mixes those packages. yuck...) */
-             if (noobs && (s->name != ps->name || s->evr != ps->evr || s->arch != ps->arch))
-               continue;
-             if (!pool->implicitobsoleteusesprovides && s->name != ps->name)
-               continue;
-             if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
-               continue;
-             if (s->name == ps->name)
-               addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_SAME_NAME, 0);
-             else
-               addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_IMPLICIT_OBSOLETES, s->name);
+             FOR_PROVIDES(p, pp, s->name)
+               {
+                 Solvable *ps = pool->solvables + p;
+                 if (p == n)
+                   continue;
+                 if (isinstalled && ps->repo != installed)
+                   continue;
+                 /* we still obsolete packages with same nevra, like rpm does */
+                 /* (actually, rpm mixes those packages. yuck...) */
+                 if (noobs && (s->name != ps->name || s->evr != ps->evr || s->arch != ps->arch))
+                   continue;
+                 if (!pool->implicitobsoleteusesprovides && s->name != ps->name)
+                   continue;
+                 if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
+                   continue;
+                 if (s->name == ps->name)
+                   addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_SAME_NAME, 0);
+                 else
+                   addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_IMPLICIT_OBSOLETES, s->name);
+               }
            }
        }
 
index 2cd4035..7ac1c9d 100644 (file)
@@ -57,6 +57,7 @@ typedef enum {
   SOLVER_RULE_RPM_SAME_NAME,
   SOLVER_RULE_RPM_PACKAGE_OBSOLETES,
   SOLVER_RULE_RPM_IMPLICIT_OBSOLETES,
+  SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES,
   SOLVER_RULE_UPDATE = 0x200,
   SOLVER_RULE_FEATURE = 0x300,
   SOLVER_RULE_JOB = 0x400,
index c3dfd9b..dec87d6 100644 (file)
@@ -543,14 +543,12 @@ solver_printtransaction(Solver *solv)
   queue_free(&pkgs);
 }
 
-void
-solver_printprobleminfo(Solver *solv, Id problem)
+static void
+solver_printproblemruleinfo(Solver *solv, Id probr)
 {
   Pool *pool = solv->pool;
-  Id probr;
   Id dep, source, target;
 
-  probr = solver_findproblemrule(solv, problem);
   switch (solver_ruleinfo(solv, probr, &source, &target, &dep))
     {
     case SOLVER_RULE_DISTUPGRADE:
@@ -586,6 +584,9 @@ solver_printprobleminfo(Solver *solv, Id problem)
     case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
       POOL_DEBUG(SAT_DEBUG_RESULT, "package %s obsoletes %s provided by %s\n", solvid2str(pool, source), dep2str(pool, dep), solvid2str(pool, target));
       return;
+    case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
+      POOL_DEBUG(SAT_DEBUG_RESULT, "installed package %s obsoletes %s provided by %s\n", solvid2str(pool, source), dep2str(pool, dep), solvid2str(pool, target));
+      return;
     case SOLVER_RULE_RPM_IMPLICIT_OBSOLETES:
       POOL_DEBUG(SAT_DEBUG_RESULT, "package %s implicitely obsoletes %s provided by %s\n", solvid2str(pool, source), dep2str(pool, dep), solvid2str(pool, target));
       return;
@@ -605,6 +606,40 @@ solver_printprobleminfo(Solver *solv, Id problem)
 }
 
 void
+solver_printprobleminfo(Solver *solv, Id problem)
+{
+  solver_printproblemruleinfo(solv, solver_findproblemrule(solv, problem));
+}
+
+void
+solver_printcompleteprobleminfo(Solver *solv, Id problem)
+{
+  Queue q;
+  Id probr;
+  int i, nobad = 0;
+
+  queue_init(&q);
+  solver_findallproblemrules(solv, problem, &q);
+  for (i = 0; i < q.count; i++)
+    {
+      probr = q.elements[i];
+      if (!(probr >= solv->updaterules && probr < solv->updaterules_end) && !(probr >= solv->jobrules && probr < solv->jobrules_end))
+       {
+         nobad = 1;
+         break;
+       }
+    }
+  for (i = 0; i < q.count; i++)
+    {
+      probr = q.elements[i];
+      if (nobad && ((probr >= solv->updaterules && probr < solv->updaterules_end) || (probr >= solv->jobrules && probr < solv->jobrules_end)))
+       continue;
+      solver_printproblemruleinfo(solv, probr);
+    }
+  queue_free(&q);
+}
+
+void
 solver_printsolution(Solver *solv, Id problem, Id solution)
 {
   Pool *pool = solv->pool;
@@ -722,7 +757,11 @@ solver_printallsolutions(Solver *solv)
       pcnt++;
       POOL_DEBUG(SAT_DEBUG_RESULT, "Problem %d:\n", pcnt);
       POOL_DEBUG(SAT_DEBUG_RESULT, "====================================\n");
+#if 1
       solver_printprobleminfo(solv, problem);
+#else
+      solver_printcompleteprobleminfo(solv, problem);
+#endif
       POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
       solution = 0;
       while ((solution = solver_next_solution(solv, problem, solution)) != 0)
index 50fff6b..e1033e7 100644 (file)
@@ -27,6 +27,7 @@ extern void solver_printdecisionq(Solver *solv, int type);
 extern void solver_printdecisions(Solver *solv);
 extern void solver_printtransaction(Solver *solv);
 extern void solver_printprobleminfo(Solver *solv, Id problem);
+extern void solver_printcompleteprobleminfo(Solver *solv, Id problem);
 extern void solver_printsolution(Solver *solv, Id problem, Id solution);
 extern void solver_printallsolutions(Solver *solv);
 extern void solver_printtrivial(Solver *solv);