]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Add experimental SOLVER_FOCUS_BEST solver flag
authorMichael Schroeder <mls@suse.de>
Mon, 10 Oct 2016 09:49:55 +0000 (11:49 +0200)
committerMichael Schroeder <mls@suse.de>
Mon, 10 Oct 2016 09:49:55 +0000 (11:49 +0200)
Makes the solver resolve dependencies right after the job rules,
thus pulling in the newest packages for dependencies as well.

bindings/solv.i
ext/testcase.c
src/solver.c
src/solver.h

index 0d6184012ee0b2951dbcb64dd6db8ebd8d9af57c..64f51d07bc07a7fa02b72da152f761eddc1abeb6 100644 (file)
@@ -3280,6 +3280,7 @@ rb_eval_string(
   static const int SOLVER_FLAG_FOCUS_INSTALLED = SOLVER_FLAG_FOCUS_INSTALLED;
   static const int SOLVER_FLAG_YUM_OBSOLETES = SOLVER_FLAG_YUM_OBSOLETES;
   static const int SOLVER_FLAG_NEED_UPDATEPROVIDE = SOLVER_FLAG_NEED_UPDATEPROVIDE;
+  static const int SOLVER_FLAG_FOCUS_BEST = SOLVER_FLAG_FOCUS_BEST;
 
   static const int SOLVER_REASON_UNRELATED = SOLVER_REASON_UNRELATED;
   static const int SOLVER_REASON_UNIT_RULE = SOLVER_REASON_UNIT_RULE;
index a4b98be87fedf90239b8375bd94df56b52f03d37..d4640de4b5fe1ee693596c4a9217c46e5c9d5915 100644 (file)
@@ -115,6 +115,7 @@ static struct solverflags2str {
   { SOLVER_FLAG_YUM_OBSOLETES,              "yumobsoletes", 0 },
   { SOLVER_FLAG_NEED_UPDATEPROVIDE,         "needupdateprovide", 0 },
   { SOLVER_FLAG_URPM_REORDER,               "urpmreorder", 0 },
+  { SOLVER_FLAG_FOCUS_BEST,                 "focusbest", 0 },
   { 0, 0, 0 }
 };
 
index 49244ffab7b70eee974c75758162a7f88e4fb786..742dfc518ac4f5689b4e2b0a06ea8fff1c7965c5 100644 (file)
@@ -1367,7 +1367,7 @@ setpropagatelearn(Solver *solv, int level, Id decision, int disablerules, Id rul
 }
 
 static void
-reorder_dq_for_jobrules(Solver *solv, int level, Queue *dq)
+reorder_dq_for_future_installed(Solver *solv, int level, Queue *dq)
 {
   Pool *pool = solv->pool;
   int i, j, haveone = 0, dqcount = dq->count;
@@ -1498,10 +1498,10 @@ selectandinstall(Solver *solv, int level, Queue *dq, int disablerules, Id ruleid
 
   if (dq->count > 1)
     policy_filter_unwanted(solv, dq, POLICY_MODE_CHOOSE);
-  /* if we're resolving job rules and didn't resolve the installed packages yet,
+  /* if we're resolving rules and didn't resolve the installed packages yet,
    * do some special supplements ordering */
-  if (dq->count > 1 && ruleid >= solv->jobrules && ruleid < solv->jobrules_end && solv->installed && !solv->focus_installed)
-    reorder_dq_for_jobrules(solv, level, dq);
+  if (dq->count > 1 && solv->do_extra_reordering)
+    reorder_dq_for_future_installed(solv, level, dq);
   /* if we have multiple candidates we open a branch */
   if (dq->count > 1)
     createbranch(solv, level, dq, 0, ruleid);
@@ -1772,6 +1772,8 @@ solver_get_flag(Solver *solv, int flag)
     return solv->break_orphans;
   case SOLVER_FLAG_FOCUS_INSTALLED:
     return solv->focus_installed;
+  case SOLVER_FLAG_FOCUS_BEST:
+    return solv->focus_best;
   case SOLVER_FLAG_YUM_OBSOLETES:
     return solv->do_yum_obsoletes;
   case SOLVER_FLAG_NEED_UPDATEPROVIDE:
@@ -1850,6 +1852,9 @@ solver_set_flag(Solver *solv, int flag, int value)
   case SOLVER_FLAG_FOCUS_INSTALLED:
     solv->focus_installed = value;
     break;
+  case SOLVER_FLAG_FOCUS_BEST:
+    solv->focus_best = value;
+    break;
   case SOLVER_FLAG_YUM_OBSOLETES:
     solv->do_yum_obsoletes = value;
     break;
@@ -2403,6 +2408,7 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
   queue_init(&dq);
   queue_init(&dqs);
   solv->installedpos = 0;
+  solv->do_extra_reordering = 0;
 
   /*
    * here's the main loop:
@@ -2447,13 +2453,28 @@ solver_run_sat(Solver *solv, int disablerules, int doweak)
        */
      if (level < systemlevel && !solv->focus_installed)
        {
+         if (solv->installed && solv->installed->nsolvables && !solv->installed->disabled)
+           solv->do_extra_reordering = 1;
          olevel = level;
          level = resolve_jobrules(solv, level, disablerules, &dq);
+         solv->do_extra_reordering = 0;
          if (level < olevel)
            continue;
          systemlevel = level + 1;
        }
 
+      /* resolve job dependencies in the focus_best case */
+      if (level < systemlevel && solv->focus_best && !solv->focus_installed && solv->installed && solv->installed->nsolvables && !solv->installed->disabled)
+       {
+         solv->do_extra_reordering = 1;
+         olevel = level;
+         level = resolve_dependencies(solv, level, disablerules, &dq);
+         solv->do_extra_reordering = 0;
+         if (level < olevel)
+           continue;           /* start over */
+         systemlevel = level + 1;
+       }
+
       /*
        * installed packages
        */
index 2b3a0458c85e077314ee1a36afdfc378764a1c85..be240c9de0401a851b58e23386c693412085aa3d 100644 (file)
@@ -160,6 +160,7 @@ struct _Solver {
   int bestobeypolicy;                  /* true: stay in policy with the best rules */
   int noautotarget;                    /* true: do not assume targeted for up/dup jobs that contain no installed solvable */
   int focus_installed;                 /* true: resolve update rules first */
+  int focus_best;                      /* true: resolve job dependencies first */
   int do_yum_obsoletes;                        /* true: add special yumobs rules */
   int urpmreorder;                     /* true: do special urpm package reordering */
 
@@ -306,6 +307,7 @@ typedef struct _Solver Solver;
 #define SOLVER_FLAG_YUM_OBSOLETES              21
 #define SOLVER_FLAG_NEED_UPDATEPROVIDE         22
 #define SOLVER_FLAG_URPM_REORDER               23
+#define SOLVER_FLAG_FOCUS_BEST                 24
 
 #define GET_USERINSTALLED_NAMES                        (1 << 0)        /* package names instead of ids */
 #define GET_USERINSTALLED_INVERTED             (1 << 1)        /* autoinstalled */