Imported Upstream version 0.6.30
[platform/upstream/libsolv.git] / src / problems.c
index c82baa8..2ffb6f9 100644 (file)
@@ -152,6 +152,8 @@ enableweakrules(Solver *solv)
   int i;
   Rule *r;
 
+  if (!solv->weakrulemap.size)
+    return;
   for (i = 1, r = solv->rules + i; i < solv->learntrules; i++, r++)
     {
       if (r->d >= 0) /* already enabled? */
@@ -227,9 +229,7 @@ refine_suggestion(Solver *solv, Id *problem, Id sug, Queue *refined, int essenti
       int njob, nfeature, nupdate, pass;
       queue_empty(&solv->problems);
       solver_reset(solv);
-
-      if (!solv->problems.count)
-        solver_run_sat(solv, 0, 0);
+      solver_run_sat(solv, 0, 0);
 
       if (!solv->problems.count)
        {
@@ -454,13 +454,6 @@ convertsolution(Solver *solv, Id why, Queue *solutionq)
          return;       /* false alarm */
 
       p = solv->installed->start + (why - solv->updaterules);
-      if (solv->dupmap_all && solv->rules[why].p != p && solv->decisionmap[p] > 0)
-       {
-         /* distupgrade case, allow to keep old package */
-         queue_push(solutionq, SOLVER_SOLUTION_DISTUPGRADE);
-         queue_push(solutionq, p);
-         return;
-       }
       if (solv->decisionmap[p] > 0)
        return;         /* false alarm, turned out we can keep the package */
       rr = solv->rules + solv->featurerules + (why - solv->updaterules);
@@ -588,17 +581,12 @@ create_solutions(Solver *solv, int probnr, int solidx)
 {
   Pool *pool = solv->pool;
   Queue redoq;
-  Queue problem, solution, problems_save;
+  Queue problem, solution, problems_save, branches_save, decisionq_reason_save;
   int i, j, nsol;
   int essentialok;
   unsigned int now;
   int oldmistakes = solv->cleandeps_mistakes ? solv->cleandeps_mistakes->count : 0;
   Id extraflags = -1;
-  int decisioncnt_update;
-  int decisioncnt_keep;
-  int decisioncnt_resolve;
-  int decisioncnt_weak;
-  int decisioncnt_orphan;
 
   now = solv_timems(0);
   queue_init(&redoq);
@@ -610,16 +598,19 @@ create_solutions(Solver *solv, int probnr, int solidx)
       queue_push(&redoq, solv->decisionq_why.elements[i]);
       queue_push(&redoq, solv->decisionmap[p > 0 ? p : -p]);
     }
-  decisioncnt_update = solv->decisioncnt_update;
-  decisioncnt_keep = solv->decisioncnt_keep;
-  decisioncnt_resolve = solv->decisioncnt_resolve;
-  decisioncnt_weak = solv->decisioncnt_weak;
-  decisioncnt_orphan = solv->decisioncnt_orphan;
 
   /* save problems queue */
   problems_save = solv->problems;
   memset(&solv->problems, 0, sizeof(solv->problems));
 
+  /* save branches queue */
+  branches_save = solv->problems;
+  memset(&solv->branches, 0, sizeof(solv->branches));
+
+  /* save decisionq_reason */
+  decisionq_reason_save = solv->decisionq_reason;
+  memset(&solv->decisionq_reason, 0, sizeof(solv->decisionq_reason));
+
   /* extract problem from queue */
   queue_init(&problem);
   for (i = solidx + 1; i < solv->solutions.count; i++)
@@ -707,16 +698,19 @@ create_solutions(Solver *solv, int probnr, int solidx)
       solv->decisionmap[p > 0 ? p : -p] = redoq.elements[i + 2];
     }
   queue_free(&redoq);
-  solv->decisioncnt_update = decisioncnt_update;
-  solv->decisioncnt_keep = decisioncnt_keep;
-  solv->decisioncnt_resolve = decisioncnt_resolve;
-  solv->decisioncnt_weak = decisioncnt_weak;
-  solv->decisioncnt_orphan = decisioncnt_orphan;
+
+  /* restore decision reasons */
+  queue_free(&solv->decisionq_reason);
+  solv->decisionq_reason = decisionq_reason_save;
 
   /* restore problems */
   queue_free(&solv->problems);
   solv->problems = problems_save;
 
+  /* restore branches */
+  queue_free(&solv->branches);
+  solv->branches = branches_save;
+
   if (solv->cleandeps_mistakes)
     {
       if (oldmistakes)
@@ -954,8 +948,11 @@ findproblemrule_internal(Solver *solv, Id idx, Id *reqrp, Id *conrp, Id *sysrp,
                {
                  if (*reqrp > 0 && r->p < -1)
                    {
+                     Pool *pool = solv->pool;
                      Id op = -solv->rules[*reqrp].p;
-                     if (op > 1 && solv->pool->solvables[op].arch != solv->pool->solvables[-r->p].arch)
+                     if (op > 1 && pool->solvables[op].arch != pool->solvables[-r->p].arch &&
+                         pool->solvables[op].arch != pool->noarchid &&
+                         pool->solvables[-r->p].arch != pool->noarchid)
                        continue;       /* different arch, skip */
                    }
                  /* prefer assertions */
@@ -1085,6 +1082,7 @@ solver_problemruleinfo2str(Solver *solv, SolverRuleinfo type, Id source, Id targ
 {
   Pool *pool = solv->pool;
   char *s;
+  Solvable *ss;
   switch (type)
     {
     case SOLVER_RULE_DISTUPGRADE:
@@ -1110,6 +1108,12 @@ solver_problemruleinfo2str(Solver *solv, SolverRuleinfo type, Id source, Id targ
         return pool_tmpjoin(pool, "cannot install the best update candidate for package ", pool_solvid2str(pool, source), 0);
      return "cannot install the best candidate for the job";
     case SOLVER_RULE_PKG_NOT_INSTALLABLE:
+      ss = pool->solvables + source;
+      if (pool_disabled_solvable(pool, ss))
+        return pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), " is disabled");
+      if (ss->arch && ss->arch != ARCH_SRC && ss->arch != ARCH_NOSRC &&
+          pool->id2arch && (ss->arch > pool->lastarch || !pool->id2arch[ss->arch]))
+        return pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), " does not have a compatible architecture");
       return pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), " is not installable");
     case SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP:
       s = pool_tmpjoin(pool, "nothing provides ", pool_dep2str(pool, dep), 0);