]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Postpone creation of alternatives until all other rules are resolved
authorMichael Schroeder <mls@suse.de>
Wed, 8 Apr 2015 11:22:58 +0000 (13:22 +0200)
committerMichael Schroeder <mls@suse.de>
Wed, 8 Apr 2015 11:22:58 +0000 (13:22 +0200)
Also optimize the sort_by_common_deps code a bit.

src/policy.c
src/policy.h
src/solver.c

index 773b829a6a9968397dfb4ea594f09524bad7670b..fadfcdae4d65546f7137c0ba676153365213b858 100644 (file)
@@ -891,9 +891,11 @@ sort_by_name_evr_sortcmp(const void *ap, const void *bp, void *dp)
   Id r = aa[1] - bb[1];
   if (r)
     return r < 0 ? -1 : 1;
+  if (aa[2] == bb[2])
+    return 0;
   a = aa[2] < 0 ? -aa[2] : aa[2];
   b = bb[2] < 0 ? -bb[2] : bb[2];
-  if (pool->disttype != DISTTYPE_DEB)
+  if (pool->disttype != DISTTYPE_DEB && a != b)
     {
       /* treat release-less versions different */
       const char *as = pool_id2str(pool, a);
@@ -1127,10 +1129,10 @@ policy_filter_unwanted(Solver *solv, Queue *plist, int mode)
     prune_to_best_arch(pool, plist);
   if (plist->count > 1)
     prune_to_best_version(pool, plist);
-  if (plist->count > 1 && mode == POLICY_MODE_CHOOSE)
+  if (plist->count > 1 && (mode == POLICY_MODE_CHOOSE || mode == POLICY_MODE_CHOOSE_NOREORDER))
     {
       prune_to_recommended(solv, plist);
-      if (plist->count > 1)
+      if (plist->count > 1 && mode != POLICY_MODE_CHOOSE_NOREORDER)
        {
          /* do some fancy reordering */
 #if 0
index a4dd4c422359da37e2512218979f2d775c4fc724..73410eedba9a18a4ade30db2f6923f3c292c902b 100644 (file)
@@ -19,6 +19,7 @@ extern "C" {
 #define POLICY_MODE_CHOOSE     0
 #define POLICY_MODE_RECOMMEND  1
 #define POLICY_MODE_SUGGEST    2
+#define POLICY_MODE_CHOOSE_NOREORDER   3       /* internal, do not use */
 
 
 #define POLICY_ILLEGAL_DOWNGRADE       1
index 53b4bc81e35080b73dac01af72c084bb824daf78..69e89ef311e524c684b39af3eb3d141035034cd1 100644 (file)
@@ -2071,7 +2071,7 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
   int i, j, n;
   Solvable *s;
   Pool *pool = solv->pool;
-  Id p, pp, *dp;
+  Id p, pp, *dp, postponed;
   int minimizationsteps;
   int installedpos = solv->installed ? solv->installed->start : 0;
 
@@ -2338,8 +2338,17 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
       if (!solv->decisioncnt_resolve)
         solv->decisioncnt_resolve = solv->decisionq.count;
       POOL_DEBUG(SOLV_DEBUG_POLICY, "deciding unresolved rules\n");
-      for (i = 1, n = 1; n < solv->nrules; i++, n++)
+      postponed = 0;
+      for (i = 1, n = 1; ; i++, n++)
        {
+         if (n >= solv->nrules)
+           {
+             if (postponed <= 0)
+               break;
+             i = postponed;
+             postponed = -1;
+             n = 1;
+           }
          if (i == solv->nrules)
            i = 1;
          r = solv->rules + i;
@@ -2421,6 +2430,17 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
                }
            }
 
+         if (dq.count > 1 && postponed >= 0)
+           {
+             policy_filter_unwanted(solv, &dq, POLICY_MODE_CHOOSE_NOREORDER);
+             if (dq.count > 1)
+               {
+                 if (!postponed)
+                   postponed = i;
+                 continue;
+               }
+           }
+
          olevel = level;
          level = selectandinstall(solv, level, &dq, disablerules, r - solv->rules);
          if (level == 0)
@@ -2431,7 +2451,7 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
          n = 0;
        }
 
-      if (n != solv->nrules)   /* ran into trouble? */
+      if (n < solv->nrules)    /* ran into trouble? */
        {
          if (level == 0)
            break;              /* unsolvable */