2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
11 * SAT based dependency solver
27 #define RULES_BLOCK 63
28 #define REGARD_RECOMMENDS_OF_INSTALLED_ITEMS 0
32 solver_dep_installed(Solver *solv, Id dep)
34 /* disable for now, splitprovides don't work anyway and it breaks
37 Pool *pool = solv->pool;
42 Reldep *rd = GETRELDEP(pool, dep);
43 if (rd->flags == REL_AND)
45 if (!solver_dep_installed(solv, rd->name))
47 return solver_dep_installed(solv, rd->evr);
49 if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_INSTALLED)
50 return solver_dep_installed(solv, rd->evr);
52 FOR_PROVIDES(p, pp, dep)
54 if (p == SYSTEMSOLVABLE || (solv->installed && pool->solvables[p].repo == solv->installed))
62 /* this mirrors solver_dep_fulfilled but uses map m instead of the decisionmap */
64 dep_possible(Solver *solv, Id dep, Map *m)
66 Pool *pool = solv->pool;
71 Reldep *rd = GETRELDEP(pool, dep);
72 if (rd->flags == REL_AND)
74 if (!dep_possible(solv, rd->name, m))
76 return dep_possible(solv, rd->evr, m);
78 if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_INSTALLED)
79 return solver_dep_installed(solv, rd->evr);
81 FOR_PROVIDES(p, pp, dep)
89 /*-----------------------------------------------------------------*/
96 printruleelement(Solver *solv, int type, Rule *r, Id v)
98 Pool *pool = solv->pool;
102 s = pool->solvables + -v;
103 POOL_DEBUG(type, " !%s [%d]", solvable2str(pool, s), -v);
107 s = pool->solvables + v;
108 POOL_DEBUG(type, " %s [%d]", solvable2str(pool, s), v);
113 POOL_DEBUG(type, " (w1)");
115 POOL_DEBUG(type, " (w2)");
117 if (solv->decisionmap[s - pool->solvables] > 0)
118 POOL_DEBUG(type, " Install.level%d", solv->decisionmap[s - pool->solvables]);
119 if (solv->decisionmap[s - pool->solvables] < 0)
120 POOL_DEBUG(type, " Conflict.level%d", -solv->decisionmap[s - pool->solvables]);
121 POOL_DEBUG(type, "\n");
130 printrule(Solver *solv, int type, Rule *r)
132 Pool *pool = solv->pool;
136 if (r >= solv->rules && r < solv->rules + solv->nrules) /* r is a solver rule */
137 POOL_DEBUG(type, "Rule #%d:", (int)(r - solv->rules));
139 POOL_DEBUG(type, "Rule:"); /* r is any rule */
141 POOL_DEBUG(type, " (disabled)");
142 POOL_DEBUG(type, "\n");
146 /* print direct literal */
148 else if (r->d == ID_NULL)
152 /* binary rule --> print w2 as second literal */
156 /* every other which is in d */
157 v = solv->pool->whatprovidesdata[r->d + i - 1];
160 printruleelement(solv, type, r, v);
162 POOL_DEBUG(type, " next rules: %d %d\n", r->n1, r->n2);
166 printruleclass(Solver *solv, int type, Rule *r)
168 Pool *pool = solv->pool;
169 if (r - solv->rules >= solv->learntrules)
170 POOL_DEBUG(type, "LEARNT ");
171 else if (r - solv->rules >= solv->weakrules)
172 POOL_DEBUG(type, "WEAK ");
173 else if (r - solv->rules >= solv->systemrules)
174 POOL_DEBUG(type, "SYSTEM ");
175 else if (r - solv->rules >= solv->jobrules)
176 POOL_DEBUG(type, "JOB ");
177 printrule(solv, type, r);
181 /*-----------------------------------------------------------------*/
187 static Pool *unifyrules_sortcmp_data;
190 * compare rules for unification sort
194 unifyrules_sortcmp(const void *ap, const void *bp)
196 Pool *pool = unifyrules_sortcmp_data;
197 Rule *a = (Rule *)ap;
198 Rule *b = (Rule *)bp;
204 return x; /* p differs */
207 if (a->d == 0 && b->d == 0)
208 return a->w2 - b->w2; /* assertion: return w2 diff */
210 if (a->d == 0) /* a is assertion, b not */
212 x = a->w2 - pool->whatprovidesdata[b->d];
216 if (b->d == 0) /* b is assertion, a not */
218 x = pool->whatprovidesdata[a->d] - b->w2;
222 /* compare whatprovidesdata */
223 ad = pool->whatprovidesdata + a->d;
224 bd = pool->whatprovidesdata + b->d;
226 if ((x = *ad++ - *bd++) != 0)
237 unifyrules(Solver *solv)
239 Pool *pool = solv->pool;
243 if (solv->nrules <= 1) /* nothing to unify */
246 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- unifyrules -----\n");
248 /* sort rules first */
249 unifyrules_sortcmp_data = solv->pool;
250 qsort(solv->rules + 1, solv->nrules - 1, sizeof(Rule), unifyrules_sortcmp);
257 for (i = j = 1, ir = solv->rules + 1; i < solv->nrules; i++, ir++)
259 if (jr && !unifyrules_sortcmp(ir, jr))
260 continue; /* prune! */
261 jr = solv->rules + j++; /* keep! */
266 /* reduced count from nrules to j rules */
267 POOL_DEBUG(SAT_DEBUG_STATS, "pruned rules from %d to %d\n", solv->nrules, j);
269 /* adapt rule buffer */
271 solv->rules = (Rule *)sat_realloc(solv->rules, ((solv->nrules + RULES_BLOCK) & ~RULES_BLOCK) * sizeof(Rule));
272 IF_POOLDEBUG (SAT_DEBUG_STATS)
279 for (i = 1; i < solv->nrules; i++)
286 dp = solv->pool->whatprovidesdata + r->d;
291 POOL_DEBUG(SAT_DEBUG_STATS, " binary: %d\n", binr);
292 POOL_DEBUG(SAT_DEBUG_STATS, " normal: %d, %d literals\n", solv->nrules - 1 - binr, lits);
294 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- unifyrules end -----\n");
304 hashrule(Solver *solv, Id p, Id d, int n)
306 unsigned int x = (unsigned int)p;
310 return (x * 37) ^ (unsigned int)d;
311 dp = solv->pool->whatprovidesdata + d;
313 x = (x * 37) ^ (unsigned int)*dp++;
321 * p = direct literal; always < 0 for installed rpm rules
322 * d, if < 0 direct literal, if > 0 offset into whatprovides, if == 0 rule is assertion (look at p only)
325 * A requires b, b provided by B1,B2,B3 => (-A|B1|B2|B3)
327 * p < 0 : pkg id of A
328 * d > 0 : Offset in whatprovidesdata (list of providers of b)
330 * A conflicts b, b provided by B1,B2,B3 => (-A|-B1), (-A|-B2), (-A|-B3)
331 * p < 0 : pkg id of A
332 * d < 0 : Id of solvable (e.g. B1)
334 * d == 0: unary rule, assertion => (A) or (-A)
336 * Install: p > 0, d = 0 (A) user requested install
337 * Remove: p < 0, d = 0 (-A) user requested remove
338 * Requires: p < 0, d > 0 (-A|B1|B2|...) d: <list of providers for requirement of p>
339 * Updates: p > 0, d > 0 (A|B1|B2|...) d: <list of updates for solvable p>
340 * Conflicts: p < 0, d < 0 (-A|-B) either p (conflict issuer) or d (conflict provider) (binary rule)
341 * ? p > 0, d < 0 (A|-B)
342 * No-op ?: p = 0, d = 0 (null) (used as policy rule placeholder)
346 * Direct assertion (no watch needed)( if d <0 ) --> d = 0, w1 = p, w2 = 0
347 * Binary rule: p = first literal, d = 0, w2 = second literal, w1 = p
348 * every other : w1 = p, w2 = whatprovidesdata[d];
349 * Disabled rule: w1 = 0
351 * always returns a rule for non-rpm rules
355 addrule(Solver *solv, Id p, Id d)
357 Pool *pool = solv->pool;
361 int n = 0; /* number of literals in rule - 1
362 0 = direct assertion (single literal)
366 /* it often happenes that requires lead to adding the same rpm rule
367 * multiple times, so we prune those duplicates right away to make
368 * the work for unifyrules a bit easier */
370 if (solv->nrules && !solv->jobrules)
372 r = solv->rules + solv->nrules - 1; /* get the last added rule */
373 if (r->p == p && r->d == d && d != 0) /* identical and not user requested */
379 /* always a binary rule */
381 return 0; /* ignore self conflict */
386 for (dp = pool->whatprovidesdata + d; *dp; dp++, n++)
388 return 0; /* rule is self-fulfilling */
390 d = dp[-1]; /* take single literal */
393 if (n == 0 && !solv->jobrules)
395 /* this is a rpm rule assertion, we do not have to allocate it */
396 /* it can be identified by a level of 1 and a zero reason */
397 /* we must not drop those rules from the decisionq when rewinding! */
399 assert(solv->decisionmap[-p] == 0 || solv->decisionmap[-p] == -1);
400 if (solv->decisionmap[-p])
401 return 0; /* already got that one */
402 queue_push(&solv->decisionq, p);
403 queue_push(&solv->decisionq_why, 0);
404 solv->decisionmap[-p] = -1;
409 /* smallest literal first so we can find dups */
413 n = 1; /* re-set n, was used as temp var */
416 /* check if the last added rule is exactly the same as what we're looking for. */
417 if (r && n == 1 && !r->d && r->p == p && r->w2 == d)
418 return r; /* binary rule */
420 if (r && n > 1 && r->d && r->p == p)
422 /* Rule where d is an offset in whatprovidesdata */
426 dp2 = pool->whatprovidesdata + r->d;
427 for (dp = pool->whatprovidesdata + d; *dp; dp++, dp2++)
438 /* check and extend rule buffer */
439 if ((solv->nrules & RULES_BLOCK) == 0)
441 solv->rules = (Rule *)sat_realloc(solv->rules, (solv->nrules + (RULES_BLOCK + 1)) * sizeof(Rule));
444 r = solv->rules + solv->nrules++; /* point to rule space */
449 /* direct assertion, no watch needed */
465 r->w2 = pool->whatprovidesdata[d];
470 IF_POOLDEBUG (SAT_DEBUG_RULE_CREATION)
472 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, " Add rule: ");
473 printrule(solv, SAT_DEBUG_RULE_CREATION, r);
480 disablerule(Solver *solv, Rule *r)
486 enablerule(Solver *solv, Rule *r)
488 if (r->d == 0 || r->w2 != r->p)
491 r->w1 = solv->pool->whatprovidesdata[r->d];
495 /**********************************************************************************/
497 /* a problem is an item on the solver's problem list. It can either be >0, in that
498 * case it is a system (upgrade) rule, or it can be <0, which makes it refer to a job
499 * consisting of multiple job rules.
503 disableproblem(Solver *solv, Id v)
511 disablerule(solv, solv->rules + v);
515 jp = solv->ruletojob.elements;
516 for (i = solv->jobrules, r = solv->rules + i; i < solv->systemrules; i++, r++, jp++)
518 disablerule(solv, r);
522 enableproblem(Solver *solv, Id v)
530 enablerule(solv, solv->rules + v);
534 jp = solv->ruletojob.elements;
535 for (i = solv->jobrules, r = solv->rules + i; i < solv->systemrules; i++, r++, jp++)
541 printproblem(Solver *solv, Id v)
543 Pool *pool = solv->pool;
549 printrule(solv, SAT_DEBUG_SOLUTIONS, solv->rules + v);
553 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "JOB %d\n", v);
554 jp = solv->ruletojob.elements;
555 for (i = solv->jobrules, r = solv->rules + i; i < solv->systemrules; i++, r++, jp++)
558 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "- ");
559 printrule(solv, SAT_DEBUG_SOLUTIONS, r);
561 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "ENDJOB\n");
567 /************************************************************************/
569 /* go through system and job rules and add direct assertions
570 * to the decisionqueue. If we find a conflict, disable rules and
571 * add them to problem queue.
572 * (disablerules is always true for the cases when we get called)
575 makeruledecisions(Solver *solv)
577 Pool *pool = solv->pool;
583 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- makeruledecisions ; size decisionq: %d -----\n",solv->decisionq.count);
585 decisionstart = solv->decisionq.count;
586 /* rpm rules don't have assertions, so we can start with the job
588 for (ri = solv->jobrules, r = solv->rules + ri; ri < solv->nrules; ri++, r++)
590 if (!r->w1 || r->w2) /* disabled or no assertion */
594 if (solv->decisionmap[vv] == 0)
596 queue_push(&solv->decisionq, v);
597 queue_push(&solv->decisionq_why, r - solv->rules);
598 solv->decisionmap[vv] = v > 0 ? 1 : -1;
599 IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
601 Solvable *s = solv->pool->solvables + vv;
603 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "conflicting %s (assertion)\n", solvable2str(solv->pool, s));
605 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "installing %s (assertion)\n", solvable2str(solv->pool, s));
609 if (v > 0 && solv->decisionmap[vv] > 0)
611 if (v < 0 && solv->decisionmap[vv] < 0)
613 /* found a conflict! */
614 /* ri >= learntrules cannot happen, as this would mean that the
615 * problem was not solvable, so we wouldn't have created the
616 * learnt rule at all */
617 assert(ri < solv->learntrules);
618 /* if we are weak, just disable ourself */
619 if (ri >= solv->weakrules)
621 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "assertion conflict, but I am weak, disabling ");
622 printrule(solv, SAT_DEBUG_UNSOLVABLE, r);
623 disablerule(solv, r);
627 /* only job and system rules left in the decisionq*/
628 /* find the decision which is the "opposite" of the jobrule */
629 for (i = 0; i < solv->decisionq.count; i++)
630 if (solv->decisionq.elements[i] == -v)
632 assert(i < solv->decisionq.count);
633 if (solv->decisionq_why.elements[i] == 0)
635 /* conflict with rpm rule, need only disable our rule */
636 assert(v > 0 || v == -SYSTEMSOLVABLE);
638 queue_push(&solv->problems, solv->learnt_pool.count);
639 queue_push(&solv->learnt_pool, ri);
640 queue_push(&solv->learnt_pool, v != -SYSTEMSOLVABLE ? -v : v);
641 queue_push(&solv->learnt_pool, 0);
642 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "conflict with rpm rule, disabling rule #%d\n", ri);
643 if (ri < solv->systemrules)
644 v = -(solv->ruletojob.elements[ri - solv->jobrules] + 1);
647 queue_push(&solv->problems, v);
648 disableproblem(solv, v);
649 queue_push(&solv->problems, 0);
653 queue_push(&solv->problems, solv->learnt_pool.count);
654 queue_push(&solv->learnt_pool, ri);
655 queue_push(&solv->learnt_pool, solv->decisionq_why.elements[i]);
656 queue_push(&solv->learnt_pool, 0);
658 /* conflict with another job or system rule */
659 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "conflicting system/job assertions over literal %d\n", vv);
660 /* push all of our rules asserting this literal on the problem stack */
661 for (i = solv->jobrules, rr = solv->rules + i; i < solv->nrules; i++, rr++)
663 if (!rr->w1 || rr->w2)
665 if (rr->p != vv && rr->p != -vv)
667 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, " - disabling rule #%d\n", i);
669 if (i < solv->systemrules)
670 v = -(solv->ruletojob.elements[i - solv->jobrules] + 1);
671 queue_push(&solv->problems, v);
672 disableproblem(solv, v);
674 queue_push(&solv->problems, 0);
677 while (solv->decisionq.count > decisionstart)
679 v = solv->decisionq.elements[--solv->decisionq.count];
680 --solv->decisionq_why.count;
682 solv->decisionmap[vv] = 0;
684 ri = solv->jobrules - 1;
685 r = solv->rules + ri;
688 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- makeruledecisions end; size decisionq: %d -----\n",solv->decisionq.count);
692 * we have enabled or disabled some of our rules. We now reenable all
693 * of our learnt rules but the ones that were learnt from rules that
697 enabledisablelearntrules(Solver *solv)
699 Pool *pool = solv->pool;
704 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "enabledisablelearntrules called\n");
705 for (i = solv->learntrules, r = solv->rules + i; i < solv->nrules; i++, r++)
707 whyp = solv->learnt_pool.elements + solv->learnt_why.elements[i - solv->learntrules];
708 while ((why = *whyp++) != 0)
711 continue; /* rpm assertion */
713 if (!solv->rules[why].w1)
716 /* why != 0: we found a disabled rule, disable the learnt rule */
719 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
721 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "disabling learnt ");
722 printrule(solv, SAT_DEBUG_SOLUTIONS, r);
724 disablerule(solv, r);
726 else if (!why && !r->w1)
728 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
730 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "re-enabling learnt ");
731 printrule(solv, SAT_DEBUG_SOLUTIONS, r);
739 /* FIXME: bad code ahead, replace as soon as possible */
741 disableupdaterules(Solver *solv, Queue *job, int jobidx)
743 Pool *pool = solv->pool;
745 Id how, what, p, *pp;
751 installed = solv->installed;
757 how = job->elements[jobidx];
760 case SOLVER_INSTALL_SOLVABLE:
761 case SOLVER_ERASE_SOLVABLE:
762 case SOLVER_ERASE_SOLVABLE_NAME:
763 case SOLVER_ERASE_SOLVABLE_PROVIDES:
769 /* go through all enabled job rules */
770 MAPZERO(&solv->noupdate);
771 for (i = solv->jobrules; i < solv->systemrules; i++)
774 if (!r->w1) /* disabled? */
776 j = solv->ruletojob.elements[i - solv->jobrules];
780 how = job->elements[j];
781 what = job->elements[j + 1];
784 case SOLVER_INSTALL_SOLVABLE: /* install specific solvable */
785 s = pool->solvables + what;
786 FOR_PROVIDES(p, pp, s->name)
788 if (pool->solvables[p].name != s->name)
790 if (pool->solvables[p].repo == installed)
791 MAPSET(&solv->noupdate, p - installed->start);
794 case SOLVER_ERASE_SOLVABLE:
795 s = pool->solvables + what;
796 if (s->repo == installed)
797 MAPSET(&solv->noupdate, what - installed->start);
799 case SOLVER_ERASE_SOLVABLE_NAME: /* remove by capability */
800 case SOLVER_ERASE_SOLVABLE_PROVIDES:
801 FOR_PROVIDES(p, pp, what)
803 if (how == SOLVER_ERASE_SOLVABLE_NAME && pool->solvables[p].name != what)
805 if (pool->solvables[p].repo == installed)
806 MAPSET(&solv->noupdate, p - installed->start);
814 /* fixup update rule status */
815 if (solv->allowuninstall)
816 return; /* no update rules at all */
820 /* we just disabled job #jobidx. enable all update rules
821 * that aren't disabled by the remaining job rules */
822 how = job->elements[jobidx];
823 what = job->elements[jobidx + 1];
826 case SOLVER_INSTALL_SOLVABLE:
827 s = pool->solvables + what;
828 FOR_PROVIDES(p, pp, s->name)
830 if (pool->solvables[p].name != s->name)
832 if (pool->solvables[p].repo != installed)
834 if (MAPTST(&solv->noupdate, p - installed->start))
836 r = solv->rules + solv->systemrules + (p - installed->start);
840 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
842 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "@@@ re-enabling ");
843 printrule(solv, SAT_DEBUG_SOLUTIONS, r);
847 case SOLVER_ERASE_SOLVABLE:
848 s = pool->solvables + what;
849 if (s->repo != installed)
851 if (MAPTST(&solv->noupdate, what - installed->start))
853 r = solv->rules + solv->systemrules + (what - installed->start);
857 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
859 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "@@@ re-enabling ");
860 printrule(solv, SAT_DEBUG_SOLUTIONS, r);
863 case SOLVER_ERASE_SOLVABLE_NAME: /* remove by capability */
864 case SOLVER_ERASE_SOLVABLE_PROVIDES:
865 FOR_PROVIDES(p, pp, what)
867 if (how == SOLVER_ERASE_SOLVABLE_NAME && pool->solvables[p].name != what)
869 if (pool->solvables[p].repo != installed)
871 if (MAPTST(&solv->noupdate, p - installed->start))
873 r = solv->rules + solv->systemrules + (p - installed->start);
877 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
879 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "@@@ re-enabling ");
880 printrule(solv, SAT_DEBUG_SOLUTIONS, r);
890 for (i = 0; i < installed->nsolvables; i++)
892 r = solv->rules + solv->systemrules + i;
893 if (r->w1 && MAPTST(&solv->noupdate, i))
894 disablerule(solv, r); /* was enabled, need to disable */
900 * add (install) rules for solvable
901 * for unfulfilled requirements, conflicts, obsoletes,....
902 * add a negative assertion for solvables that are not installable
906 addrpmrulesforsolvable(Solver *solv, Solvable *s, Map *m)
908 Pool *pool = solv->pool;
909 Repo *installed = solv->installed;
923 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforsolvable -----\n");
925 queue_init_buffer(&q, qbuf, sizeof(qbuf)/sizeof(*qbuf));
926 queue_push(&q, s - pool->solvables); /* push solvable Id */
932 * s: Pointer to solvable
936 if (MAPTST(m, n)) /* continue if already done */
940 s = pool->solvables + n; /* s = Solvable in question */
943 if (installed /* Installed system available */
944 && !solv->fixsystem /* NOT repair errors in rpm dependency graph */
945 && s->repo == installed) /* solvable is installed? */
947 dontfix = 1; /* dont care about broken rpm deps */
950 if (!dontfix && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC && !pool_installable(pool, s))
952 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, "package %s [%d] is not installable\n", solvable2str(pool, s), (Id)(s - pool->solvables));
953 addrule(solv, -n, 0); /* uninstallable */
956 /*-----------------------------------------
957 * check requires of s
962 reqp = s->repo->idarraydata + s->requires;
963 while ((req = *reqp++) != 0) /* go throw all requires */
965 if (req == SOLVABLE_PREREQMARKER) /* skip the marker */
968 dp = pool_whatprovides(pool, req);
970 if (*dp == SYSTEMSOLVABLE) /* always installed */
975 /* the strategy here is to not insist on dependencies
976 * that are already broken. so if we find one provider
977 * that was already installed, we know that the
978 * dependency was not broken before so we enforce it */
979 for (i = 0; (p = dp[i]) != 0; i++) /* for all providers */
981 if (pool->solvables[p].repo == installed)
982 break; /* provider was installed */
984 if (!p) /* previously broken dependency */
986 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, "ignoring broken requires %s of installed package %s\n", dep2str(pool, req), solvable2str(pool, s));
993 /* nothing provides req! */
994 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, "package %s [%d] is not installable (%s)\n", solvable2str(pool, s), (Id)(s - pool->solvables), dep2str(pool, req));
995 addrule(solv, -n, 0); /* mark requestor as uninstallable */
999 IF_POOLDEBUG (SAT_DEBUG_RULE_CREATION)
1001 POOL_DEBUG(SAT_DEBUG_RULE_CREATION," %s requires %s\n", solvable2str(pool, s), dep2str(pool, req));
1002 for (i = 0; dp[i]; i++)
1003 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, " provided by %s\n", solvable2str(pool, pool->solvables + dp[i]));
1006 /* add 'requires' dependency */
1007 /* rule: (-requestor|provider1|provider2|...|providerN) */
1008 addrule(solv, -n, dp - pool->whatprovidesdata);
1010 /* descend the dependency tree */
1011 for (; *dp; dp++) /* loop through all providers */
1013 if (!MAPTST(m, *dp))
1014 queue_push(&q, *dp);
1017 } /* while, requirements of n */
1019 } /* if, requirements */
1021 /* that's all we check for src packages */
1022 if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
1025 /*-----------------------------------------
1026 * check conflicts of s
1031 conp = s->repo->idarraydata + s->conflicts;
1032 while ((con = *conp++) != 0)
1034 FOR_PROVIDES(p, pp, con)
1036 /* dontfix: dont care about conflicts with already installed packs */
1037 if (dontfix && pool->solvables[p].repo == installed)
1039 /* rule: -n|-p: either solvable _or_ provider of conflict */
1040 addrule(solv, -n, -p);
1045 /*-----------------------------------------
1046 * check obsoletes if not installed
1048 if (!installed || pool->solvables[n].repo != installed)
1049 { /* not installed */
1052 obsp = s->repo->idarraydata + s->obsoletes;
1053 while ((obs = *obsp++) != 0)
1055 FOR_PROVIDES(p, pp, obs)
1056 addrule(solv, -n, -p);
1059 FOR_PROVIDES(p, pp, s->name)
1061 if (s->name == pool->solvables[p].name)
1062 addrule(solv, -n, -p);
1066 /*-----------------------------------------
1067 * add recommends to the rule list
1071 recp = s->repo->idarraydata + s->recommends;
1072 while ((rec = *recp++) != 0)
1074 FOR_PROVIDES(p, pp, rec)
1081 sugp = s->repo->idarraydata + s->suggests;
1082 while ((sug = *sugp++) != 0)
1084 FOR_PROVIDES(p, pp, sug)
1091 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforsolvable end -----\n");
1095 addrpmrulesforweak(Solver *solv, Map *m)
1097 Pool *pool = solv->pool;
1102 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforweak -----\n");
1103 for (i = n = 1; n < pool->nsolvables; i++, n++)
1105 if (i == pool->nsolvables)
1109 s = pool->solvables + i;
1110 if (!pool_installable(pool, s))
1115 supp = s->repo->idarraydata + s->supplements;
1116 while ((sup = *supp++) != ID_NULL)
1117 if (dep_possible(solv, sup, m))
1120 if (!sup && s->freshens)
1122 supp = s->repo->idarraydata + s->freshens;
1123 while ((sup = *supp++) != ID_NULL)
1124 if (dep_possible(solv, sup, m))
1127 if (!sup && s->enhances)
1129 supp = s->repo->idarraydata + s->enhances;
1130 while ((sup = *supp++) != ID_NULL)
1131 if (dep_possible(solv, sup, m))
1136 addrpmrulesforsolvable(solv, s, m);
1139 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforweak end -----\n");
1143 addrpmrulesforupdaters(Solver *solv, Solvable *s, Map *m, int allowall)
1145 Pool *pool = solv->pool;
1150 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforupdaters -----\n");
1152 queue_init_buffer(&qs, qsbuf, sizeof(qsbuf)/sizeof(*qsbuf));
1153 policy_findupdatepackages(solv, s, &qs, allowall);
1154 if (!MAPTST(m, s - pool->solvables)) /* add rule for s if not already done */
1155 addrpmrulesforsolvable(solv, s, m);
1156 for (i = 0; i < qs.count; i++)
1157 if (!MAPTST(m, qs.elements[i]))
1158 addrpmrulesforsolvable(solv, pool->solvables + qs.elements[i], m);
1161 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforupdaters -----\n");
1165 * add rule for update
1166 * (A|A1|A2|A3...) An = update candidates for A
1168 * s = (installed) solvable
1172 addupdaterule(Solver *solv, Solvable *s, int allowall)
1174 /* installed packages get a special upgrade allowed rule */
1175 Pool *pool = solv->pool;
1180 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addupdaterule -----\n");
1182 queue_init_buffer(&qs, qsbuf, sizeof(qsbuf)/sizeof(*qsbuf));
1183 policy_findupdatepackages(solv, s, &qs, allowall);
1184 if (qs.count == 0) /* no updaters found */
1187 d = pool_queuetowhatprovides(pool, &qs); /* intern computed queue */
1189 addrule(solv, s - pool->solvables, d); /* allow update of s */
1190 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addupdaterule end -----\n");
1194 /*-----------------------------------------------------------------*/
1203 printWatches(Solver *solv, int type)
1205 Pool *pool = solv->pool;
1208 POOL_DEBUG(type, "Watches: \n");
1210 for (counter = -(pool->nsolvables); counter <= pool->nsolvables; counter ++)
1212 POOL_DEBUG(type, " solvable [%d] -- rule [%d]\n", counter, solv->watches[counter+pool->nsolvables]);
1219 * initial setup for all watches
1223 makewatches(Solver *solv)
1227 int nsolvables = solv->pool->nsolvables;
1229 sat_free(solv->watches);
1230 /* lower half for removals, upper half for installs */
1231 solv->watches = (Id *)sat_calloc(2 * nsolvables, sizeof(Id));
1233 /* do it reverse so rpm rules get triggered first */
1234 for (i = 1, r = solv->rules + solv->nrules - 1; i < solv->nrules; i++, r--)
1236 for (i = 1, r = solv->rules + 1; i < solv->nrules; i++, r++)
1239 if (!r->w1 /* rule is disabled */
1240 || !r->w2) /* rule is assertion */
1243 /* see addwatches(solv, r) */
1244 r->n1 = solv->watches[nsolvables + r->w1];
1245 solv->watches[nsolvables + r->w1] = r - solv->rules;
1247 r->n2 = solv->watches[nsolvables + r->w2];
1248 solv->watches[nsolvables + r->w2] = r - solv->rules;
1254 * add watches (for rule)
1258 addwatches(Solver *solv, Rule *r)
1260 int nsolvables = solv->pool->nsolvables;
1262 r->n1 = solv->watches[nsolvables + r->w1];
1263 solv->watches[nsolvables + r->w1] = r - solv->rules;
1265 r->n2 = solv->watches[nsolvables + r->w2];
1266 solv->watches[nsolvables + r->w2] = r - solv->rules;
1270 /*-----------------------------------------------------------------*/
1271 /* rule propagation */
1273 #define DECISIONMAP_TRUE(p) ((p) > 0 ? (decisionmap[p] > 0) : (decisionmap[-p] < 0))
1278 * propagate decision to all rules
1279 * return : 0 = everything is OK
1280 * watched rule = there is a conflict
1284 propagate(Solver *solv, int level)
1286 Pool *pool = solv->pool;
1291 Id *decisionmap = solv->decisionmap;
1292 Id *watches = solv->watches + pool->nsolvables;
1294 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "----- propagate -----\n");
1296 while (solv->propagate_index < solv->decisionq.count)
1298 /* negate because our watches trigger if literal goes FALSE */
1299 pkg = -solv->decisionq.elements[solv->propagate_index++];
1300 IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
1302 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "popagate for decision %d level %d\n", -pkg, level);
1303 printruleelement(solv, SAT_DEBUG_PROPAGATE, 0, -pkg);
1304 printWatches(solv, SAT_DEBUG_SCHUBI);
1307 for (rp = watches + pkg; *rp; rp = nrp)
1309 r = solv->rules + *rp;
1311 IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
1313 POOL_DEBUG(SAT_DEBUG_PROPAGATE," watch triggered ");
1314 printrule(solv, SAT_DEBUG_PROPAGATE, r);
1319 ow = r->w2; /* regard the second watchpoint to come to a solution */
1324 ow = r->w1; /* regard the first watchpoint to come to a solution */
1327 /* if clause is TRUE, nothing to do */
1328 if (DECISIONMAP_TRUE(ow))
1333 /* not a binary clause, check if we need to move our watch */
1334 /* search for a literal that is not ow and not false */
1335 /* (true is also ok, in that case the rule is fulfilled) */
1336 if (r->p && r->p != ow && !DECISIONMAP_TRUE(-r->p))
1339 for (dp = pool->whatprovidesdata + r->d; (p = *dp++) != 0;)
1340 if (p != ow && !DECISIONMAP_TRUE(-p))
1344 /* p is free to watch, move watch to p */
1345 IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
1348 POOL_DEBUG(SAT_DEBUG_PROPAGATE, " -> move w%d to %s\n", (pkg == r->w1 ? 1 : 2), solvable2str(pool, pool->solvables + p));
1350 POOL_DEBUG(SAT_DEBUG_PROPAGATE," -> move w%d to !%s\n", (pkg == r->w1 ? 1 : 2), solvable2str(pool, pool->solvables - p));
1364 watches[p] = r - solv->rules;
1368 /* unit clause found, set other watch to TRUE */
1369 if (DECISIONMAP_TRUE(-ow))
1370 return r; /* eek, a conflict! */
1371 IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
1373 POOL_DEBUG(SAT_DEBUG_PROPAGATE, " unit ");
1374 printrule(solv, SAT_DEBUG_PROPAGATE, r);
1377 decisionmap[ow] = level;
1379 decisionmap[-ow] = -level;
1380 queue_push(&solv->decisionq, ow);
1381 queue_push(&solv->decisionq_why, r - solv->rules);
1382 IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
1384 Solvable *s = pool->solvables + (ow > 0 ? ow : -ow);
1386 POOL_DEBUG(SAT_DEBUG_PROPAGATE, " -> decided to install %s\n", solvable2str(pool, s));
1388 POOL_DEBUG(SAT_DEBUG_PROPAGATE, " -> decided to conflict %s\n", solvable2str(pool, s));
1392 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "----- propagate end-----\n");
1394 return 0; /* all is well */
1398 /*-----------------------------------------------------------------*/
1407 analyze(Solver *solv, int level, Rule *c, int *pr, int *dr, int *whyp)
1409 Pool *pool = solv->pool;
1412 Map seen; /* global? */
1415 int num = 0, l1num = 0;
1416 int learnt_why = solv->learnt_pool.count;
1417 Id *decisionmap = solv->decisionmap;
1421 POOL_DEBUG(SAT_DEBUG_ANALYZE, "ANALYZE at %d ----------------------\n", level);
1422 map_init(&seen, pool->nsolvables);
1423 idx = solv->decisionq.count;
1426 IF_POOLDEBUG (SAT_DEBUG_ANALYZE)
1427 printruleclass(solv, SAT_DEBUG_ANALYZE, c);
1428 queue_push(&solv->learnt_pool, c - solv->rules);
1429 dp = c->d ? pool->whatprovidesdata + c->d : 0;
1430 /* go through all literals of the rule */
1442 if (DECISIONMAP_TRUE(v)) /* the one true literal */
1444 vv = v > 0 ? v : -v;
1445 if (MAPTST(&seen, vv))
1447 l = solv->decisionmap[vv];
1452 /* a level 1 literal, mark it for later */
1453 MAPSET(&seen, vv); /* mark for scanning in level 1 phase */
1459 num++; /* need to do this one as well */
1470 v = solv->decisionq.elements[--idx];
1471 vv = v > 0 ? v : -v;
1472 if (MAPTST(&seen, vv))
1475 c = solv->rules + solv->decisionq_why.elements[idx];
1480 *pr = -v; /* so that v doesn't get lost */
1482 /* add involved level 1 rules */
1485 POOL_DEBUG(SAT_DEBUG_ANALYZE, "got %d involved level 1 decisions\n", l1num);
1489 v = solv->decisionq.elements[--idx];
1490 vv = v > 0 ? v : -v;
1491 if (!MAPTST(&seen, vv))
1493 why = solv->decisionq_why.elements[idx];
1496 queue_push(&solv->learnt_pool, -vv);
1497 IF_POOLDEBUG (SAT_DEBUG_ANALYZE)
1499 POOL_DEBUG(SAT_DEBUG_ANALYZE, "RPM ASSERT Rule:\n");
1500 printruleelement(solv, SAT_DEBUG_ANALYZE, 0, v);
1504 queue_push(&solv->learnt_pool, why);
1505 c = solv->rules + why;
1506 IF_POOLDEBUG (SAT_DEBUG_ANALYZE)
1507 printruleclass(solv, SAT_DEBUG_ANALYZE, c);
1518 if (DECISIONMAP_TRUE(v)) /* the one true literal */
1520 vv = v > 0 ? v : -v;
1521 l = solv->decisionmap[vv];
1522 if (l != 1 && l != -1)
1532 else if (r.count == 1 && r.elements[0] < 0)
1533 *dr = r.elements[0];
1535 *dr = pool_queuetowhatprovides(pool, &r);
1536 IF_POOLDEBUG (SAT_DEBUG_ANALYZE)
1538 POOL_DEBUG(SAT_DEBUG_ANALYZE, "learned rule for level %d (am %d)\n", rlevel, level);
1539 printruleelement(solv, SAT_DEBUG_ANALYZE, 0, *pr);
1540 for (i = 0; i < r.count; i++)
1541 printruleelement(solv, SAT_DEBUG_ANALYZE, 0, r.elements[i]);
1543 /* push end marker on learnt reasons stack */
1544 queue_push(&solv->learnt_pool, 0);
1553 * reset the solver decisions to right after the rpm rules.
1554 * called after rules have been enabled/disabled
1558 reset_solver(Solver *solv)
1560 Pool *pool = solv->pool;
1564 enabledisablelearntrules(solv);
1566 /* redo all direct rpm rule decisions */
1567 /* we break at the first decision with a why attached, this is
1568 * either a job/system rule assertion or a propagated decision */
1569 for (i = solv->decisionq.count - 1; i >= solv->directdecisions; i--)
1571 v = solv->decisionq.elements[i];
1572 solv->decisionmap[v > 0 ? v : -v] = 0;
1575 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "decisions done reduced from %d to %d\n", solv->decisionq.count, solv->directdecisions);
1577 solv->decisionq_why.count = solv->directdecisions;
1578 solv->decisionq.count = solv->directdecisions;
1579 solv->recommends_index = -1;
1580 solv->propagate_index = 0;
1582 /* redo all job/system decisions */
1583 makeruledecisions(solv);
1584 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "decisions so far: %d\n", solv->decisionq.count);
1585 /* recreate watch chains */
1591 * analyze_unsolvable_rule
1595 analyze_unsolvable_rule(Solver *solv, Rule *r)
1597 Pool *pool = solv->pool;
1599 Id why = r - solv->rules;
1600 IF_POOLDEBUG (SAT_DEBUG_UNSOLVABLE)
1601 printruleclass(solv, SAT_DEBUG_UNSOLVABLE, r);
1602 if (solv->learntrules && why >= solv->learntrules)
1604 for (i = solv->learnt_why.elements[why - solv->learntrules]; solv->learnt_pool.elements[i]; i++)
1605 if (solv->learnt_pool.elements[i] > 0)
1606 analyze_unsolvable_rule(solv, solv->rules + solv->learnt_pool.elements[i]);
1609 /* do not add rpm rules to problem */
1610 if (why < solv->jobrules)
1612 /* turn rule into problem */
1613 if (why >= solv->jobrules && why < solv->systemrules)
1614 why = -(solv->ruletojob.elements[why - solv->jobrules] + 1);
1615 /* return if problem already countains our rule */
1616 if (solv->problems.count)
1618 for (i = solv->problems.count - 1; i >= 0; i--)
1619 if (solv->problems.elements[i] == 0) /* end of last problem reached? */
1621 else if (solv->problems.elements[i] == why)
1624 queue_push(&solv->problems, why);
1629 * analyze_unsolvable
1631 * return: 1 - disabled some rules, try again
1636 analyze_unsolvable(Solver *solv, Rule *cr, int disablerules)
1638 Pool *pool = solv->pool;
1640 Map seen; /* global to speed things up? */
1643 Id *decisionmap = solv->decisionmap;
1644 int oldproblemcount;
1645 int oldlearntpoolcount;
1648 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "ANALYZE UNSOLVABLE ----------------------\n");
1649 oldproblemcount = solv->problems.count;
1650 oldlearntpoolcount = solv->learnt_pool.count;
1652 /* make room for proof index */
1653 /* must update it later, as analyze_unsolvable_rule would confuse
1654 * it with a rule index if we put the real value in already */
1655 queue_push(&solv->problems, 0);
1658 map_init(&seen, pool->nsolvables);
1659 queue_push(&solv->learnt_pool, r - solv->rules);
1660 analyze_unsolvable_rule(solv, r);
1661 dp = r->d ? pool->whatprovidesdata + r->d : 0;
1672 if (DECISIONMAP_TRUE(v)) /* the one true literal */
1674 vv = v > 0 ? v : -v;
1675 l = solv->decisionmap[vv];
1680 idx = solv->decisionq.count;
1683 v = solv->decisionq.elements[--idx];
1684 vv = v > 0 ? v : -v;
1685 if (!MAPTST(&seen, vv))
1687 why = solv->decisionq_why.elements[idx];
1690 /* level 1 and no why, must be an rpm assertion */
1691 IF_POOLDEBUG (SAT_DEBUG_UNSOLVABLE)
1693 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "RPM ");
1694 printruleelement(solv, SAT_DEBUG_UNSOLVABLE, 0, v);
1696 /* this is the only positive rpm assertion */
1697 if (v == SYSTEMSOLVABLE)
1700 queue_push(&solv->learnt_pool, v);
1703 queue_push(&solv->learnt_pool, why);
1704 r = solv->rules + why;
1705 analyze_unsolvable_rule(solv, r);
1706 dp = r->d ? pool->whatprovidesdata + r->d : 0;
1717 if (DECISIONMAP_TRUE(v)) /* the one true literal */
1719 vv = v > 0 ? v : -v;
1720 l = solv->decisionmap[vv];
1727 queue_push(&solv->problems, 0); /* mark end of this problem */
1730 if (solv->weakrules != solv->learntrules)
1732 for (i = oldproblemcount + 1; i < solv->problems.count - 1; i++)
1734 why = solv->problems.elements[i];
1735 if (why < solv->weakrules || why >= solv->learntrules)
1737 if (!lastweak || lastweak < why)
1743 /* disable last weak rule */
1744 solv->problems.count = oldproblemcount;
1745 solv->learnt_pool.count = oldlearntpoolcount;
1746 r = solv->rules + lastweak;
1747 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "disabling weak ");
1748 printrule(solv, SAT_DEBUG_UNSOLVABLE, r);
1749 disablerule(solv, r);
1755 queue_push(&solv->learnt_pool, 0);
1756 solv->problems.elements[oldproblemcount] = oldlearntpoolcount;
1760 for (i = oldproblemcount + 1; i < solv->problems.count - 1; i++)
1761 disableproblem(solv, solv->problems.elements[i]);
1765 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "UNSOLVABLE\n");
1770 /*-----------------------------------------------------------------*/
1771 /* Decision revert */
1775 * revert decision at level
1779 revert(Solver *solv, int level)
1781 Pool *pool = solv->pool;
1783 while (solv->decisionq.count)
1785 v = solv->decisionq.elements[solv->decisionq.count - 1];
1786 vv = v > 0 ? v : -v;
1787 if (solv->decisionmap[vv] <= level && solv->decisionmap[vv] >= -level)
1789 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "reverting decision %d at %d\n", v, solv->decisionmap[vv]);
1790 solv->decisionmap[vv] = 0;
1791 solv->decisionq.count--;
1792 solv->decisionq_why.count--;
1793 solv->propagate_index = solv->decisionq.count;
1795 while (solv->branches.count && solv->branches.elements[solv->branches.count - 1] <= -level)
1797 solv->branches.count--;
1798 while (solv->branches.count && solv->branches.elements[solv->branches.count - 1] >= 0)
1799 solv->branches.count--;
1801 solv->recommends_index = -1;
1806 * watch2onhighest - put watch2 on literal with highest level
1810 watch2onhighest(Solver *solv, Rule *r)
1816 return; /* binary rule, both watches are set */
1817 dp = solv->pool->whatprovidesdata + r->d;
1818 while ((v = *dp++) != 0)
1820 l = solv->decisionmap[v < 0 ? -v : v];
1835 * add free decision to decision q, increase level
1836 * propagate decision, return if no conflict.
1837 * in conflict case, analyze conflict rule, add resulting
1838 * rule to learnt rule set, make decision from learnt
1839 * rule (always unit) and re-propagate.
1843 setpropagatelearn(Solver *solv, int level, Id decision, int disablerules)
1845 Pool *pool = solv->pool;
1854 solv->decisionmap[decision] = level;
1856 solv->decisionmap[-decision] = -level;
1857 queue_push(&solv->decisionq, decision);
1858 queue_push(&solv->decisionq_why, 0);
1862 r = propagate(solv, level);
1866 return analyze_unsolvable(solv, r, disablerules);
1867 POOL_DEBUG(SAT_DEBUG_ANALYZE, "conflict with rule #%d\n", (int)(r - solv->rules));
1868 l = analyze(solv, level, r, &p, &d, &why); /* learnt rule in p and d */
1869 assert(l > 0 && l < level);
1870 POOL_DEBUG(SAT_DEBUG_ANALYZE, "reverting decisions (level %d -> %d)\n", level, l);
1872 revert(solv, level);
1873 r = addrule(solv, p, d); /* p requires d */
1875 assert(solv->learnt_why.count == (r - solv->rules) - solv->learntrules);
1876 queue_push(&solv->learnt_why, why);
1879 /* at least 2 literals, needs watches */
1880 watch2onhighest(solv, r);
1881 addwatches(solv, r);
1883 solv->decisionmap[p > 0 ? p : -p] = p > 0 ? level : -level;
1884 queue_push(&solv->decisionq, p);
1885 queue_push(&solv->decisionq_why, r - solv->rules);
1886 IF_POOLDEBUG (SAT_DEBUG_ANALYZE)
1888 POOL_DEBUG(SAT_DEBUG_ANALYZE, "decision: ");
1889 printruleelement(solv, SAT_DEBUG_ANALYZE, 0, p);
1890 POOL_DEBUG(SAT_DEBUG_ANALYZE, "new rule: ");
1891 printrule(solv, SAT_DEBUG_ANALYZE, r);
1899 * install best package from the queue. We add an extra package, inst, if
1900 * provided. See comment in weak install section.
1903 selectandinstall(Solver *solv, int level, Queue *dq, Id inst, int disablerules)
1905 Pool *pool = solv->pool;
1909 if (dq->count > 1 || inst)
1910 policy_filter_unwanted(solv, dq, inst, POLICY_MODE_CHOOSE);
1915 /* choose the supplemented one */
1916 for (i = 0; i < dq->count; i++)
1917 if (solver_is_supplementing(solv, pool->solvables + dq->elements[i]))
1921 for (i = 1; i < dq->count; i++)
1922 queue_push(&solv->branches, dq->elements[i]);
1923 queue_push(&solv->branches, -level);
1927 p = dq->elements[i];
1929 POOL_DEBUG(SAT_DEBUG_POLICY, "installing %s\n", solvable2str(pool, pool->solvables + p));
1931 return setpropagatelearn(solv, level, p, disablerules);
1935 /*-----------------------------------------------------------------*/
1936 /* Main solver interface */
1941 * create solver structure
1943 * pool: all available solvables
1944 * installed: installed Solvables
1947 * Upon solving, rules are created to flag the Solvables
1948 * of the 'installed' Repo as installed.
1952 solver_create(Pool *pool, Repo *installed)
1955 solv = (Solver *)sat_calloc(1, sizeof(Solver));
1957 solv->installed = installed;
1959 queue_init(&solv->ruletojob);
1960 queue_init(&solv->decisionq);
1961 queue_init(&solv->decisionq_why);
1962 queue_init(&solv->problems);
1963 queue_init(&solv->suggestions);
1964 queue_init(&solv->learnt_why);
1965 queue_init(&solv->learnt_pool);
1966 queue_init(&solv->branches);
1968 map_init(&solv->recommendsmap, pool->nsolvables);
1969 map_init(&solv->suggestsmap, pool->nsolvables);
1970 map_init(&solv->noupdate, installed ? installed->end - installed->start : 0);
1971 solv->recommends_index = 0;
1973 solv->decisionmap = (Id *)sat_calloc(pool->nsolvables, sizeof(Id));
1974 solv->rules = (Rule *)sat_malloc((solv->nrules + (RULES_BLOCK + 1)) * sizeof(Rule));
1975 memset(solv->rules, 0, sizeof(Rule));
1987 solver_free(Solver *solv)
1989 queue_free(&solv->ruletojob);
1990 queue_free(&solv->decisionq);
1991 queue_free(&solv->decisionq_why);
1992 queue_free(&solv->learnt_why);
1993 queue_free(&solv->learnt_pool);
1994 queue_free(&solv->problems);
1995 queue_free(&solv->suggestions);
1996 queue_free(&solv->branches);
1998 map_free(&solv->recommendsmap);
1999 map_free(&solv->suggestsmap);
2000 map_free(&solv->noupdate);
2001 sat_free(solv->decisionmap);
2002 sat_free(solv->rules);
2003 sat_free(solv->watches);
2004 sat_free(solv->weaksystemrules);
2005 sat_free(solv->obsoletes);
2006 sat_free(solv->obsoletes_data);
2011 /*-------------------------------------------------------*/
2016 * all rules have been set up, now actually run the solver
2021 run_solver(Solver *solv, int disablerules, int doweak)
2029 Pool *pool = solv->pool;
2032 IF_POOLDEBUG (SAT_DEBUG_RULE_CREATION)
2034 POOL_DEBUG (SAT_DEBUG_RULE_CREATION, "number of rules: %d\n", solv->nrules);
2035 for (i = 0; i < solv->nrules; i++)
2036 printrule(solv, SAT_DEBUG_RULE_CREATION, solv->rules + i);
2039 /* create watches chains */
2042 POOL_DEBUG(SAT_DEBUG_STATS, "initial decisions: %d\n", solv->decisionq.count);
2044 IF_POOLDEBUG (SAT_DEBUG_SCHUBI)
2045 printdecisions(solv);
2047 /* start SAT algorithm */
2049 systemlevel = level + 1;
2050 POOL_DEBUG(SAT_DEBUG_STATS, "solving...\n");
2061 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "propagating (propagate_index: %d; size decisionq: %d)...\n", solv->propagate_index, solv->decisionq.count);
2062 if ((r = propagate(solv, level)) != 0)
2064 if (analyze_unsolvable(solv, r, disablerules))
2072 * installed packages
2075 if (level < systemlevel && solv->installed && solv->installed->nsolvables)
2077 if (!solv->updatesystem)
2079 /* try to keep as many packages as possible */
2080 POOL_DEBUG(SAT_DEBUG_STATS, "installing system packages\n");
2081 for (i = solv->installed->start, n = 0; ; i++)
2083 if (n == solv->installed->nsolvables)
2085 if (i == solv->installed->end)
2086 i = solv->installed->start;
2087 s = pool->solvables + i;
2088 if (s->repo != solv->installed)
2091 if (solv->decisionmap[i] != 0)
2093 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "keeping %s\n", solvable2str(pool, s));
2095 level = setpropagatelearn(solv, level, i, disablerules);
2101 if (level <= olevel)
2105 if (solv->weaksystemrules)
2107 POOL_DEBUG(SAT_DEBUG_STATS, "installing weak system packages\n");
2108 for (i = solv->installed->start; i < solv->installed->end; i++)
2110 if (pool->solvables[i].repo != solv->installed)
2112 if (solv->decisionmap[i] > 0 || (solv->decisionmap[i] < 0 && solv->weaksystemrules[i - solv->installed->start] == 0))
2114 /* noupdate is set if a job is erasing the installed solvable or installing a specific version */
2115 if (MAPTST(&solv->noupdate, i - solv->installed->start))
2118 if (solv->weaksystemrules[i - solv->installed->start])
2120 dp = pool->whatprovidesdata + solv->weaksystemrules[i - solv->installed->start];
2121 while ((p = *dp++) != 0)
2123 if (solv->decisionmap[p] > 0)
2125 if (solv->decisionmap[p] == 0)
2129 continue; /* update package already installed */
2131 if (!dq.count && solv->decisionmap[i] != 0)
2134 /* FIXME: i is handled a bit different because we do not want
2135 * to have it pruned just because it is not recommened.
2136 * we should not prune installed packages instead */
2137 level = selectandinstall(solv, level, &dq, (solv->decisionmap[i] ? 0 : i), disablerules);
2143 if (level <= olevel)
2146 if (i < solv->installed->end)
2149 systemlevel = level;
2156 POOL_DEBUG(SAT_DEBUG_STATS, "deciding unresolved rules\n");
2157 for (i = 1, n = 1; ; i++, n++)
2159 if (n == solv->nrules)
2161 if (i == solv->nrules)
2163 r = solv->rules + i;
2169 /* binary or unary rule */
2170 /* need two positive undecided literals */
2171 if (r->p < 0 || r->w2 <= 0)
2173 if (solv->decisionmap[r->p] || solv->decisionmap[r->w2])
2175 queue_push(&dq, r->p);
2176 queue_push(&dq, r->w2);
2181 * all negative literals are installed
2182 * no positive literal is installed
2183 * i.e. the rule is not fulfilled and we
2184 * just need to decide on the positive literals
2188 if (solv->decisionmap[-r->p] <= 0)
2193 if (solv->decisionmap[r->p] > 0)
2195 if (solv->decisionmap[r->p] == 0)
2196 queue_push(&dq, r->p);
2198 dp = pool->whatprovidesdata + r->d;
2199 while ((p = *dp++) != 0)
2203 if (solv->decisionmap[-p] <= 0)
2208 if (solv->decisionmap[p] > 0)
2210 if (solv->decisionmap[p] == 0)
2217 /* dq.count < 2 cannot happen as this means that
2218 * the rule is unit */
2219 assert(dq.count > 1);
2220 IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
2222 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "unfulfilled ");
2223 printrule(solv, SAT_DEBUG_PROPAGATE, r);
2227 level = selectandinstall(solv, level, &dq, 0, disablerules);
2233 if (level < systemlevel)
2236 } /* for(), decide */
2238 if (n != solv->nrules) /* continue if level < systemlevel */
2241 if (doweak && !solv->problems.count)
2245 POOL_DEBUG(SAT_DEBUG_STATS, "installing recommended packages\n");
2246 if (!REGARD_RECOMMENDS_OF_INSTALLED_ITEMS)
2248 for (i = 0; i < solv->decisionq.count; i++)
2250 p = solv->decisionq.elements[i];
2251 if (p > 0 && pool->solvables[p].repo == solv->installed)
2252 solv->decisionmap[p] = -solv->decisionmap[p];
2256 for (i = 1; i < pool->nsolvables; i++)
2258 if (solv->decisionmap[i] < 0)
2260 if (solv->decisionmap[i] > 0)
2262 Id *recp, rec, *pp, p;
2263 s = pool->solvables + i;
2264 /* installed, check for recommends */
2265 /* XXX need to special case AND ? */
2268 recp = s->repo->idarraydata + s->recommends;
2269 while ((rec = *recp++) != 0)
2272 FOR_PROVIDES(p, pp, rec)
2274 if (solv->decisionmap[p] > 0)
2279 else if (solv->decisionmap[p] == 0)
2281 queue_pushunique(&dq, p);
2289 s = pool->solvables + i;
2290 if (!s->supplements && !s->freshens)
2292 if (!pool_installable(pool, s))
2294 if (solver_is_supplementing(solv, s))
2295 queue_pushunique(&dq, i);
2298 if (!REGARD_RECOMMENDS_OF_INSTALLED_ITEMS)
2300 for (i = 0; i < solv->decisionq.count; i++)
2302 p = solv->decisionq.elements[i];
2303 if (p > 0 && pool->solvables[p].repo == solv->installed)
2304 solv->decisionmap[p] = -solv->decisionmap[p];
2310 policy_filter_unwanted(solv, &dq, 0, POLICY_MODE_RECOMMEND);
2312 POOL_DEBUG(SAT_DEBUG_STATS, "installing recommended %s\n", solvable2str(pool, pool->solvables + p));
2313 level = setpropagatelearn(solv, level, p, 0);
2318 if (solv->solution_callback)
2320 solv->solution_callback(solv, solv->solution_callback_data);
2321 if (solv->branches.count)
2323 int i = solv->branches.count - 1;
2324 int l = -solv->branches.elements[i];
2326 if (solv->branches.elements[i - 1] < 0)
2328 p = solv->branches.elements[i];
2329 POOL_DEBUG(SAT_DEBUG_STATS, "branching with %s\n", solvable2str(pool, pool->solvables + p));
2331 for (j = i + 1; j < solv->branches.count; j++)
2332 queue_push(&dq, solv->branches.elements[j]);
2333 solv->branches.count = i;
2335 revert(solv, level);
2337 for (j = 0; j < dq.count; j++)
2338 queue_push(&solv->branches, dq.elements[j]);
2340 level = setpropagatelearn(solv, level, p, disablerules);
2348 /* all branches done, we're finally finished */
2352 /* minimization step */
2353 if (solv->branches.count)
2355 int l = 0, lasti = -1, lastl = -1;
2357 for (i = solv->branches.count - 1; i >= 0; i--)
2359 p = solv->branches.elements[i];
2362 else if (p > 0 && solv->decisionmap[p] > l + 1)
2370 /* kill old solvable so that we do not loop */
2371 p = solv->branches.elements[lasti];
2372 solv->branches.elements[lasti] = 0;
2373 POOL_DEBUG(SAT_DEBUG_STATS, "minimizing %d -> %d with %s\n", solv->decisionmap[p], l, solvable2str(pool, pool->solvables + p));
2376 revert(solv, level);
2378 level = setpropagatelearn(solv, level, p, disablerules);
2395 * at this point, all rules that led to conflicts are disabled.
2396 * we re-enable all rules of a problem set but rule "sug", then
2397 * continue to disable more rules until there as again a solution.
2400 /* FIXME: think about conflicting assertions */
2403 refine_suggestion(Solver *solv, Queue *job, Id *problem, Id sug, Queue *refined)
2405 Pool *pool = solv->pool;
2412 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
2414 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "refine_suggestion start\n");
2415 for (i = 0; problem[i]; i++)
2417 if (problem[i] == sug)
2418 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "=> ");
2419 printproblem(solv, problem[i]);
2422 queue_init(&disabled);
2423 queue_empty(refined);
2424 queue_push(refined, sug);
2426 /* re-enable all problem rules with the exception of "sug" */
2430 for (i = 0; problem[i]; i++)
2431 if (problem[i] != sug)
2432 enableproblem(solv, problem[i]);
2435 disableupdaterules(solv, job, -(sug + 1));
2439 /* re-enable as many weak rules as possible */
2440 for (i = solv->weakrules; i < solv->learntrules; i++)
2442 r = solv->rules + i;
2444 enablerule(solv, r);
2447 queue_empty(&solv->problems);
2448 revert(solv, 1); /* XXX move to reset_solver? */
2451 run_solver(solv, 0, 0);
2452 if (!solv->problems.count)
2454 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "no more problems!\n");
2455 IF_POOLDEBUG (SAT_DEBUG_SCHUBI)
2456 printdecisions(solv);
2457 break; /* great, no more problems */
2459 disabledcnt = disabled.count;
2460 /* skip over proof index */
2461 for (i = 1; i < solv->problems.count - 1; i++)
2463 /* ignore solutions in refined */
2464 v = solv->problems.elements[i];
2466 break; /* end of problem reached */
2467 for (j = 0; problem[j]; j++)
2468 if (problem[j] != sug && problem[j] == v)
2472 queue_push(&disabled, v);
2474 if (disabled.count == disabledcnt)
2476 /* no solution found, this was an invalid suggestion! */
2477 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "no solution found!\n");
2481 if (disabled.count == disabledcnt + 1)
2483 /* just one suggestion, add it to refined list */
2484 v = disabled.elements[disabledcnt];
2485 queue_push(refined, v);
2486 disableproblem(solv, v);
2488 disableupdaterules(solv, job, -(v + 1));
2492 /* more than one solution, disable all */
2493 /* do not push anything on refine list */
2494 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
2496 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "more than one solution found:\n");
2497 for (i = disabledcnt; i < disabled.count; i++)
2498 printproblem(solv, disabled.elements[i]);
2500 for (i = disabledcnt; i < disabled.count; i++)
2501 disableproblem(solv, disabled.elements[i]);
2504 /* all done, get us back into the same state as before */
2505 /* enable refined rules again */
2506 for (i = 0; i < disabled.count; i++)
2507 enableproblem(solv, disabled.elements[i]);
2508 /* disable problem rules again */
2509 for (i = 0; problem[i]; i++)
2510 disableproblem(solv, problem[i]);
2511 disableupdaterules(solv, job, -1);
2512 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "refine_suggestion end\n");
2516 problems_to_solutions(Solver *solv, Queue *job)
2518 Pool *pool = solv->pool;
2526 if (!solv->problems.count)
2528 queue_clone(&problems, &solv->problems);
2529 queue_init(&solution);
2530 queue_init(&solutions);
2531 /* copy over proof index */
2532 queue_push(&solutions, problems.elements[0]);
2533 problem = problems.elements + 1;
2534 for (i = 1; i < problems.count; i++)
2536 Id v = problems.elements[i];
2539 /* mark end of this problem */
2540 queue_push(&solutions, 0);
2541 queue_push(&solutions, 0);
2542 if (i + 1 == problems.count)
2544 /* copy over proof of next problem */
2545 queue_push(&solutions, problems.elements[i + 1]);
2547 problem = problems.elements + i + 1;
2550 refine_suggestion(solv, job, problem, v, &solution);
2551 if (!solution.count)
2552 continue; /* this solution didn't work out */
2554 for (j = 0; j < solution.count; j++)
2556 why = solution.elements[j];
2557 /* must be either job descriptor or system rule */
2558 assert(why < 0 || (why >= solv->systemrules && why < solv->weakrules));
2560 printproblem(solv, why);
2564 /* job descriptor */
2565 queue_push(&solutions, 0);
2566 queue_push(&solutions, -why);
2570 /* system rule, find replacement package */
2572 p = solv->installed->start + (why - solv->systemrules);
2573 if (solv->weaksystemrules && solv->weaksystemrules[why - solv->systemrules])
2575 Id *dp = pool->whatprovidesdata + solv->weaksystemrules[why - solv->systemrules];
2578 if (*dp >= solv->installed->start && *dp < solv->installed->start + solv->installed->nsolvables)
2580 if (solv->decisionmap[*dp] > 0)
2587 queue_push(&solutions, p);
2588 queue_push(&solutions, rp);
2591 /* mark end of this solution */
2592 queue_push(&solutions, 0);
2593 queue_push(&solutions, 0);
2595 queue_free(&solution);
2596 queue_free(&problems);
2597 /* copy queue over to solutions */
2598 queue_free(&solv->problems);
2599 queue_clone(&solv->problems, &solutions);
2601 /* bring solver back into problem state */
2602 revert(solv, 1); /* XXX move to reset_solver? */
2605 assert(solv->problems.count == solutions.count);
2606 queue_free(&solutions);
2610 solver_next_problem(Solver *solv, Id problem)
2614 return solv->problems.count ? 1 : 0;
2615 pp = solv->problems.elements + problem;
2616 while (pp[0] || pp[1])
2620 while (pp[0] || pp[1])
2625 problem = pp - solv->problems.elements;
2626 if (problem >= solv->problems.count)
2632 solver_next_solution(Solver *solv, Id problem, Id solution)
2638 pp = solv->problems.elements + solution;
2639 return pp[0] || pp[1] ? solution : 0;
2641 pp = solv->problems.elements + solution;
2642 while (pp[0] || pp[1])
2645 solution = pp - solv->problems.elements;
2646 return pp[0] || pp[1] ? solution : 0;
2650 solver_next_solutionelement(Solver *solv, Id problem, Id solution, Id element, Id *p, Id *rp)
2653 element = element ? element + 2 : solution;
2654 pp = solv->problems.elements + element;
2655 if (!(pp[0] || pp[1]))
2664 * create obsoletesmap from solver decisions
2665 * required for decision handling
2669 create_obsoletesmap(Solver *solv)
2671 Pool *pool = solv->pool;
2672 Repo *installed = solv->installed;
2673 Id p, *obsoletesmap = NULL;
2677 obsoletesmap = (Id *)sat_calloc(pool->nsolvables, sizeof(Id));
2680 for (i = 0; i < solv->decisionq.count; i++)
2684 n = solv->decisionq.elements[i];
2687 if (n == SYSTEMSOLVABLE)
2689 s = pool->solvables + n;
2690 if (s->repo == installed) /* obsoletes don't count for already installed packages */
2692 FOR_PROVIDES(p, pp, s->name)
2693 if (s->name == pool->solvables[p].name)
2695 if (pool->solvables[p].repo == installed && !obsoletesmap[p])
2697 obsoletesmap[p] = n;
2702 for (i = 0; i < solv->decisionq.count; i++)
2707 n = solv->decisionq.elements[i];
2710 if (n == SYSTEMSOLVABLE)
2712 s = pool->solvables + n;
2713 if (s->repo == installed) /* obsoletes don't count for already installed packages */
2717 obsp = s->repo->idarraydata + s->obsoletes;
2718 while ((obs = *obsp++) != 0)
2719 FOR_PROVIDES(p, pp, obs)
2721 if (pool->solvables[p].repo == installed && !obsoletesmap[p])
2723 obsoletesmap[p] = n;
2729 return obsoletesmap;
2738 printdecisions(Solver *solv)
2740 Pool *pool = solv->pool;
2741 Repo *installed = solv->installed;
2742 Id p, *obsoletesmap = create_obsoletesmap( solv );
2746 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- Decisions -----\n");
2748 /* print solvables to be erased */
2752 FOR_REPO_SOLVABLES(installed, p, s)
2754 if (solv->decisionmap[p] >= 0)
2756 if (obsoletesmap[p])
2758 POOL_DEBUG(SAT_DEBUG_RESULT, "erase %s\n", solvable2str(pool, s));
2762 /* print solvables to be installed */
2764 for (i = 0; i < solv->decisionq.count; i++)
2767 p = solv->decisionq.elements[i];
2770 IF_POOLDEBUG (SAT_DEBUG_SCHUBI)
2773 s = pool->solvables + p;
2774 POOL_DEBUG(SAT_DEBUG_SCHUBI, "level of %s is %d\n", solvable2str(pool, s), p);
2778 if (p == SYSTEMSOLVABLE)
2780 POOL_DEBUG(SAT_DEBUG_SCHUBI, "SYSTEMSOLVABLE\n");
2783 s = pool->solvables + p;
2784 if (installed && s->repo == installed)
2787 if (!obsoletesmap[p])
2789 POOL_DEBUG(SAT_DEBUG_RESULT, "install %s", solvable2str(pool, s));
2793 POOL_DEBUG(SAT_DEBUG_RESULT, "update %s", solvable2str(pool, s));
2794 POOL_DEBUG(SAT_DEBUG_RESULT, " (obsoletes");
2795 for (j = installed->start; j < installed->end; j++)
2796 if (obsoletesmap[j] == p)
2797 POOL_DEBUG(SAT_DEBUG_RESULT, " %s", solvable2str(pool, pool->solvables + j));
2798 POOL_DEBUG(SAT_DEBUG_RESULT, ")");
2800 POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
2803 sat_free(obsoletesmap);
2805 if (solv->suggestions.count)
2807 POOL_DEBUG(SAT_DEBUG_RESULT, "\nsuggested packages:\n");
2808 for (i = 0; i < solv->suggestions.count; i++)
2810 s = pool->solvables + solv->suggestions.elements[i];
2811 POOL_DEBUG(SAT_DEBUG_RESULT, "- %s\n", solvable2str(pool, s));
2814 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- Decisions end -----\n");
2817 /* this is basically the reverse of addrpmrulesforsolvable */
2819 solver_problemruleinfo(Solver *solv, Queue *job, Id rid, Id *depp, Id *sourcep, Id *targetp)
2821 Pool *pool = solv->pool;
2822 Repo *installed = solv->installed;
2826 Id p, *pp, req, *reqp, con, *conp, obs, *obsp, *dp;
2828 assert(rid < solv->weakrules);
2829 if (rid >= solv->systemrules)
2832 *sourcep = solv->installed->start + (rid - solv->systemrules);
2834 return SOLVER_PROBLEM_UPDATE_RULE;
2836 if (rid >= solv->jobrules)
2839 r = solv->rules + rid;
2840 p = solv->ruletojob.elements[rid - solv->jobrules];
2841 *depp = job->elements[p + 1];
2843 *targetp = job->elements[p];
2844 if (r->d == 0 && r->w2 == 0 && r->p == -SYSTEMSOLVABLE)
2845 return SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP;
2846 return SOLVER_PROBLEM_JOB_RULE;
2850 /* a rpm rule assertion */
2851 assert(rid != -SYSTEMSOLVABLE);
2852 s = pool->solvables - rid;
2853 if (installed && !solv->fixsystem && s->repo == installed)
2855 assert(!dontfix); /* dontfix packages never have a neg assertion */
2856 /* see why the package is not installable */
2857 if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC && !pool_installable(pool, s))
2858 return SOLVER_PROBLEM_NOT_INSTALLABLE;
2859 /* check requires */
2860 assert(s->requires);
2861 reqp = s->repo->idarraydata + s->requires;
2862 while ((req = *reqp++) != 0)
2864 if (req == SOLVABLE_PREREQMARKER)
2866 dp = pool_whatprovides(pool, req);
2874 return SOLVER_PROBLEM_NOTHING_PROVIDES_DEP;
2876 r = solv->rules + rid;
2878 if (r->d == 0 && r->w2 == 0)
2880 /* an assertion. we don't store them as rpm rules, so
2884 s = pool->solvables - r->p;
2885 if (installed && !solv->fixsystem && s->repo == installed)
2887 if (r->d == 0 && r->w2 < 0)
2889 /* a package conflict */
2890 Solvable *s2 = pool->solvables - r->w2;
2893 if (installed && !solv->fixsystem && s2->repo == installed)
2896 /* if both packages have the same name and at least one of them
2897 * is not installed, they conflict */
2898 if (s->name == s2->name && (!installed || (s->repo != installed || s2->repo != installed)))
2903 return SOLVER_PROBLEM_SAME_NAME;
2906 /* check conflicts in both directions */
2909 conp = s->repo->idarraydata + s->conflicts;
2910 while ((con = *conp++) != 0)
2912 FOR_PROVIDES(p, pp, con)
2914 if (dontfix && pool->solvables[p].repo == installed)
2921 return SOLVER_PROBLEM_PACKAGE_CONFLICT;
2927 conp = s2->repo->idarraydata + s2->conflicts;
2928 while ((con = *conp++) != 0)
2930 FOR_PROVIDES(p, pp, con)
2932 if (dontfix2 && pool->solvables[p].repo == installed)
2939 return SOLVER_PROBLEM_PACKAGE_CONFLICT;
2943 /* check obsoletes in both directions */
2944 if ((!installed || s->repo != installed) && s->obsoletes)
2946 obsp = s->repo->idarraydata + s->obsoletes;
2947 while ((obs = *obsp++) != 0)
2949 FOR_PROVIDES(p, pp, obs)
2956 return SOLVER_PROBLEM_PACKAGE_OBSOLETES;
2960 if ((!installed || s2->repo != installed) && s2->obsoletes)
2962 obsp = s2->repo->idarraydata + s2->obsoletes;
2963 while ((obs = *obsp++) != 0)
2965 FOR_PROVIDES(p, pp, obs)
2972 return SOLVER_PROBLEM_PACKAGE_OBSOLETES;
2976 /* all cases checked, can't happen */
2979 /* simple requires */
2980 assert(s->requires);
2981 reqp = s->repo->idarraydata + s->requires;
2982 while ((req = *reqp++) != 0)
2984 if (req == SOLVABLE_PREREQMARKER)
2986 dp = pool_whatprovides(pool, req);
2989 if (*dp == r->w2 && dp[1] == 0)
2992 else if (dp - pool->whatprovidesdata == r->d)
2999 return SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE;
3003 findproblemrule_internal(Solver *solv, Id idx, Id *reqrp, Id *conrp, Id *sysrp, Id *jobrp)
3006 Id lreqr, lconr, lsysr, ljobr;
3010 lreqr = lconr = lsysr = ljobr = 0;
3011 while ((rid = solv->learnt_pool.elements[idx++]) != 0)
3013 if (rid >= solv->learntrules)
3014 findproblemrule_internal(solv, solv->learnt_why.elements[rid - solv->learntrules], &lreqr, &lconr, &lsysr, &ljobr);
3015 else if (rid >= solv->systemrules)
3020 else if (rid >= solv->jobrules)
3027 r = solv->rules + rid;
3028 if (!r->d && r->w2 < 0)
3041 /* assertion, counts as require rule */
3042 /* ignore system solvable as we need useful info */
3043 if (rid == -SYSTEMSOLVABLE)
3045 if (!*reqrp || !reqassert)
3052 if (!*reqrp && lreqr)
3054 if (!*conrp && lconr)
3056 if (!*jobrp && ljobr)
3058 if (!*sysrp && lsysr)
3063 solver_findproblemrule(Solver *solv, Id problem)
3065 Id reqr, conr, sysr, jobr;
3066 Id idx = solv->problems.elements[problem - 1];
3067 reqr = conr = sysr = jobr = 0;
3068 findproblemrule_internal(solv, idx, &reqr, &conr, &sysr, &jobr);
3081 printprobleminfo(Solver *solv, Queue *job, Id problem)
3083 Pool *pool = solv->pool;
3085 Id dep, source, target;
3088 probr = solver_findproblemrule(solv, problem);
3089 switch (solver_problemruleinfo(solv, job, probr, &dep, &source, &target))
3091 case SOLVER_PROBLEM_UPDATE_RULE:
3092 s = pool_id2solvable(pool, source);
3093 POOL_DEBUG(SAT_DEBUG_RESULT, "problem with installed package %s\n", solvable2str(pool, s));
3095 case SOLVER_PROBLEM_JOB_RULE:
3096 POOL_DEBUG(SAT_DEBUG_RESULT, "conflicting requests\n");
3098 case SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP:
3099 POOL_DEBUG(SAT_DEBUG_RESULT, "nothing provides requested %s\n", dep2str(pool, dep));
3101 case SOLVER_PROBLEM_NOT_INSTALLABLE:
3102 s = pool_id2solvable(pool, source);
3103 POOL_DEBUG(SAT_DEBUG_RESULT, "package %s is not installable\n", solvable2str(pool, s));
3105 case SOLVER_PROBLEM_NOTHING_PROVIDES_DEP:
3106 s = pool_id2solvable(pool, source);
3107 POOL_DEBUG(SAT_DEBUG_RESULT, "nothing provides %s needed by %s\n", dep2str(pool, dep), solvable2str(pool, s));
3109 case SOLVER_PROBLEM_SAME_NAME:
3110 s = pool_id2solvable(pool, source);
3111 s2 = pool_id2solvable(pool, target);
3112 POOL_DEBUG(SAT_DEBUG_RESULT, "cannot install both %s and %s\n", solvable2str(pool, s), solvable2str(pool, s2));
3114 case SOLVER_PROBLEM_PACKAGE_CONFLICT:
3115 s = pool_id2solvable(pool, source);
3116 s2 = pool_id2solvable(pool, target);
3117 POOL_DEBUG(SAT_DEBUG_RESULT, "package %s conflicts with %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
3119 case SOLVER_PROBLEM_PACKAGE_OBSOLETES:
3120 s = pool_id2solvable(pool, source);
3121 s2 = pool_id2solvable(pool, target);
3122 POOL_DEBUG(SAT_DEBUG_RESULT, "package %s obsoletes %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
3124 case SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE:
3125 s = pool_id2solvable(pool, source);
3126 POOL_DEBUG(SAT_DEBUG_RESULT, "package %s requires %s, but none of the providers can be installed\n", solvable2str(pool, s), dep2str(pool, dep));
3132 printsolutions(Solver *solv, Queue *job)
3134 Pool *pool = solv->pool;
3137 Id problem, solution, element;
3140 POOL_DEBUG(SAT_DEBUG_RESULT, "Encountered problems! Here are the solutions:\n\n");
3143 while ((problem = solver_next_problem(solv, problem)) != 0)
3145 POOL_DEBUG(SAT_DEBUG_RESULT, "Problem %d:\n", pcnt++);
3146 POOL_DEBUG(SAT_DEBUG_RESULT, "====================================\n");
3147 printprobleminfo(solv, job, problem);
3148 POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
3150 while ((solution = solver_next_solution(solv, problem, solution)) != 0)
3153 while ((element = solver_next_solutionelement(solv, problem, solution, element, &p, &rp)) != 0)
3157 /* job, rp is index into job queue */
3158 what = job->elements[rp];
3159 switch (job->elements[rp - 1])
3161 case SOLVER_INSTALL_SOLVABLE:
3162 s = pool->solvables + what;
3163 if (solv->installed && s->repo == solv->installed)
3164 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not keep %s installed\n", solvable2str(pool, s));
3166 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install %s\n", solvable2str(pool, s));
3168 case SOLVER_ERASE_SOLVABLE:
3169 s = pool->solvables + what;
3170 if (solv->installed && s->repo == solv->installed)
3171 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall %s\n", solvable2str(pool, s));
3173 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not forbid installation of %s\n", solvable2str(pool, s));
3175 case SOLVER_INSTALL_SOLVABLE_NAME:
3176 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install %s\n", id2str(pool, what));
3178 case SOLVER_ERASE_SOLVABLE_NAME:
3179 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall %s\n", id2str(pool, what));
3181 case SOLVER_INSTALL_SOLVABLE_PROVIDES:
3182 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install a solvable providing %s\n", dep2str(pool, what));
3184 case SOLVER_ERASE_SOLVABLE_PROVIDES:
3185 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall all solvables providing %s\n", dep2str(pool, what));
3187 case SOLVER_INSTALL_SOLVABLE_UPDATE:
3188 s = pool->solvables + what;
3189 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install most recent version of %s\n", solvable2str(pool, s));
3192 POOL_DEBUG(SAT_DEBUG_RESULT, "- do something different\n");
3198 /* policy, replace p with rp */
3199 s = pool->solvables + p;
3200 sd = rp ? pool->solvables + rp : 0;
3204 if (!solv->allowdowngrade && evrcmp(pool, s->evr, sd->evr, EVRCMP_MATCH_RELEASE) > 0)
3206 POOL_DEBUG(SAT_DEBUG_RESULT, "- allow downgrade of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
3209 if (!solv->allowarchchange && s->name == sd->name && s->arch != sd->arch && policy_illegal_archchange(pool, s, sd))
3211 POOL_DEBUG(SAT_DEBUG_RESULT, "- allow architecture change of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
3214 if (!solv->allowvendorchange && s->name == sd->name && s->vendor != sd->vendor && policy_illegal_vendorchange(pool, s, sd))
3217 POOL_DEBUG(SAT_DEBUG_RESULT, "- allow vendor change from '%s' (%s) to '%s' (%s)\n", id2str(pool, s->vendor), solvable2str(pool, s), id2str(pool, sd->vendor), solvable2str(pool, sd));
3219 POOL_DEBUG(SAT_DEBUG_RESULT, "- allow vendor change from '%s' (%s) to no vendor (%s)\n", id2str(pool, s->vendor), solvable2str(pool, s), solvable2str(pool, sd));
3223 POOL_DEBUG(SAT_DEBUG_RESULT, "- allow replacement of %s with %s\n", solvable2str(pool, s), solvable2str(pool, sd));
3227 POOL_DEBUG(SAT_DEBUG_RESULT, "- allow deinstallation of %s\n", solvable2str(pool, s));
3232 POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
3238 /* for each installed solvable find which packages with *different* names
3239 * obsolete the solvable.
3240 * this index is used in policy_findupdatepackages if noupdateprovide is set.
3244 create_obsolete_index(Solver *solv)
3246 Pool *pool = solv->pool;
3248 Repo *installed = solv->installed;
3249 Id p, *pp, obs, *obsp, *obsoletes, *obsoletes_data;
3252 if (!installed || !installed->nsolvables)
3254 /* create reverse obsoletes map for installed solvables */
3255 solv->obsoletes = obsoletes = sat_calloc(installed->end - installed->start, sizeof(Id));
3256 for (i = 1; i < pool->nsolvables; i++)
3258 s = pool->solvables + i;
3259 if (s->repo == installed)
3263 if (!pool_installable(pool, s))
3265 obsp = s->repo->idarraydata + s->obsoletes;
3266 while ((obs = *obsp++) != 0)
3267 FOR_PROVIDES(p, pp, obs)
3269 if (pool->solvables[p].repo != installed)
3271 if (pool->solvables[p].name == s->name)
3273 obsoletes[p - installed->start]++;
3277 for (i = 0; i < installed->nsolvables; i++)
3280 n += obsoletes[i] + 1;
3283 solv->obsoletes_data = obsoletes_data = sat_calloc(n + 1, sizeof(Id));
3284 POOL_DEBUG(SAT_DEBUG_STATS, "obsoletes data: %d entries\n", n + 1);
3285 for (i = pool->nsolvables - 1; i > 0; i--)
3287 s = pool->solvables + i;
3288 if (s->repo == installed)
3292 if (!pool_installable(pool, s))
3294 obsp = s->repo->idarraydata + s->obsoletes;
3295 while ((obs = *obsp++) != 0)
3296 FOR_PROVIDES(p, pp, obs)
3298 if (pool->solvables[p].repo != installed)
3300 if (pool->solvables[p].name == s->name)
3302 p -= installed->start;
3303 if (obsoletes_data[obsoletes[p]] != i)
3304 obsoletes_data[--obsoletes[p]] = i;
3310 /*-----------------------------------------------------------------*/
3320 solver_solve(Solver *solv, Queue *job)
3322 Pool *pool = solv->pool;
3323 Repo *installed = solv->installed;
3326 Map addedmap; /* '1' == have rpm-rules for solvable */
3327 Id how, what, p, *pp, d;
3331 /* create whatprovides if not already there */
3332 if (!pool->whatprovides)
3333 pool_createwhatprovides(pool);
3335 /* create obsolete index if needed */
3336 if (solv->noupdateprovide)
3337 create_obsolete_index(solv);
3340 * create basic rule set of all involved packages
3341 * use addedmap bitmap to make sure we don't create rules twice
3345 map_init(&addedmap, pool->nsolvables);
3349 * always install our system solvable
3351 MAPSET(&addedmap, SYSTEMSOLVABLE);
3352 queue_push(&solv->decisionq, SYSTEMSOLVABLE);
3353 queue_push(&solv->decisionq_why, 0);
3354 solv->decisionmap[SYSTEMSOLVABLE] = 1;
3357 * create rules for all package that could be involved with the solving
3358 * so called: rpm rules
3363 oldnrules = solv->nrules;
3364 POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** create rpm rules for installed solvables ***\n");
3365 FOR_REPO_SOLVABLES(installed, p, s)
3366 addrpmrulesforsolvable(solv, s, &addedmap);
3367 POOL_DEBUG(SAT_DEBUG_STATS, "added %d rpm rules for installed solvables\n", solv->nrules - oldnrules);
3368 POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** create rpm rules for updaters of installed solvables ***\n");
3369 oldnrules = solv->nrules;
3370 FOR_REPO_SOLVABLES(installed, p, s)
3371 addrpmrulesforupdaters(solv, s, &addedmap, 1);
3372 POOL_DEBUG(SAT_DEBUG_STATS, "added %d rpm rules for updaters of installed solvables\n", solv->nrules - oldnrules);
3375 POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** create rpm rules for packages involved with a job ***\n");
3376 oldnrules = solv->nrules;
3377 for (i = 0; i < job->count; i += 2)
3379 how = job->elements[i];
3380 what = job->elements[i + 1];
3384 case SOLVER_INSTALL_SOLVABLE:
3385 addrpmrulesforsolvable(solv, pool->solvables + what, &addedmap);
3387 case SOLVER_INSTALL_SOLVABLE_NAME:
3388 case SOLVER_INSTALL_SOLVABLE_PROVIDES:
3389 FOR_PROVIDES(p, pp, what)
3391 /* if by name, ensure that the name matches */
3392 if (how == SOLVER_INSTALL_SOLVABLE_NAME && pool->solvables[p].name != what)
3394 addrpmrulesforsolvable(solv, pool->solvables + p, &addedmap);
3397 case SOLVER_INSTALL_SOLVABLE_UPDATE:
3398 /* dont allow downgrade */
3399 addrpmrulesforupdaters(solv, pool->solvables + what, &addedmap, 0);
3403 POOL_DEBUG(SAT_DEBUG_STATS, "added %d rpm rules for packages involved in a job\n", solv->nrules - oldnrules);
3405 POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** create rpm rules for recommended/suggested packages ***\n");
3407 oldnrules = solv->nrules;
3408 addrpmrulesforweak(solv, &addedmap);
3409 POOL_DEBUG(SAT_DEBUG_STATS, "added %d rpm rules because of weak dependencies\n", solv->nrules - oldnrules);
3411 IF_POOLDEBUG (SAT_DEBUG_STATS)
3413 int possible = 0, installable = 0;
3414 for (i = 1; i < pool->nsolvables; i++)
3416 if (pool_installable(pool, pool->solvables + i))
3418 if (MAPTST(&addedmap, i))
3421 POOL_DEBUG(SAT_DEBUG_STATS, "%d of %d installable solvables considered for solving (rules has been generated for)\n", possible, installable);
3425 * first pass done, we now have all the rpm rules we need.
3426 * unify existing rules before going over all job rules and
3428 * at this point the system is always solvable,
3429 * as an empty system (remove all packages) is a valid solution
3432 unifyrules(solv); /* remove duplicate rpm rules */
3433 solv->directdecisions = solv->decisionq.count;
3435 POOL_DEBUG(SAT_DEBUG_STATS, "decisions so far: %d\n", solv->decisionq.count);
3436 IF_POOLDEBUG (SAT_DEBUG_SCHUBI)
3437 printdecisions (solv);
3440 * now add all job rules
3443 POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** Add JOB rules ***\n");
3445 solv->jobrules = solv->nrules;
3447 for (i = 0; i < job->count; i += 2)
3449 oldnrules = solv->nrules;
3451 how = job->elements[i];
3452 what = job->elements[i + 1];
3455 case SOLVER_INSTALL_SOLVABLE: /* install specific solvable */
3456 s = pool->solvables + what;
3457 POOL_DEBUG(SAT_DEBUG_JOB, "job: install solvable %s\n", solvable2str(pool, s));
3458 addrule(solv, what, 0); /* install by Id */
3459 queue_push(&solv->ruletojob, i);
3461 case SOLVER_ERASE_SOLVABLE:
3462 s = pool->solvables + what;
3463 POOL_DEBUG(SAT_DEBUG_JOB, "job: erase solvable %s\n", solvable2str(pool, s));
3464 addrule(solv, -what, 0); /* remove by Id */
3465 queue_push(&solv->ruletojob, i);
3467 case SOLVER_INSTALL_SOLVABLE_NAME: /* install by capability */
3468 case SOLVER_INSTALL_SOLVABLE_PROVIDES:
3469 if (how == SOLVER_INSTALL_SOLVABLE_NAME)
3470 POOL_DEBUG(SAT_DEBUG_JOB, "job: install name %s\n", id2str(pool, what));
3471 if (how == SOLVER_INSTALL_SOLVABLE_PROVIDES)
3472 POOL_DEBUG(SAT_DEBUG_JOB, "job: install provides %s\n", dep2str(pool, what));
3474 FOR_PROVIDES(p, pp, what)
3476 /* if by name, ensure that the name matches */
3477 if (how == SOLVER_INSTALL_SOLVABLE_NAME && pool->solvables[p].name != what)
3483 /* no provider, make this an impossible rule */
3484 queue_push(&q, -SYSTEMSOLVABLE);
3487 p = queue_shift(&q); /* get first provider */
3489 d = 0; /* single provider ? -> make assertion */
3491 d = pool_queuetowhatprovides(pool, &q); /* get all providers */
3492 addrule(solv, p, d); /* add 'requires' rule */
3493 queue_push(&solv->ruletojob, i);
3495 case SOLVER_ERASE_SOLVABLE_NAME: /* remove by capability */
3496 case SOLVER_ERASE_SOLVABLE_PROVIDES:
3497 if (how == SOLVER_ERASE_SOLVABLE_NAME)
3498 POOL_DEBUG(SAT_DEBUG_JOB, "job: erase name %s\n", id2str(pool, what));
3499 if (how == SOLVER_ERASE_SOLVABLE_PROVIDES)
3500 POOL_DEBUG(SAT_DEBUG_JOB, "job: erase provides %s\n", dep2str(pool, what));
3501 FOR_PROVIDES(p, pp, what)
3503 /* if by name, ensure that the name matches */
3504 if (how == SOLVER_ERASE_SOLVABLE_NAME && pool->solvables[p].name != what)
3506 addrule(solv, -p, 0); /* add 'remove' rule */
3507 queue_push(&solv->ruletojob, i);
3510 case SOLVER_INSTALL_SOLVABLE_UPDATE: /* find update for solvable */
3511 s = pool->solvables + what;
3512 POOL_DEBUG(SAT_DEBUG_JOB, "job: update %s\n", solvable2str(pool, s));
3513 addupdaterule(solv, s, 0);
3514 queue_push(&solv->ruletojob, i);
3517 IF_POOLDEBUG (SAT_DEBUG_JOB)
3520 if (solv->nrules == oldnrules)
3521 POOL_DEBUG(SAT_DEBUG_JOB, " - no rule created");
3522 for (j = oldnrules; j < solv->nrules; j++)
3524 POOL_DEBUG(SAT_DEBUG_JOB, " - job ");
3525 printrule(solv, SAT_DEBUG_JOB, solv->rules + j);
3529 assert(solv->ruletojob.count == solv->nrules - solv->jobrules);
3532 * now add system rules
3536 POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** Add system rules ***\n");
3539 solv->systemrules = solv->nrules;
3542 * create rules for updating installed solvables
3546 if (installed && !solv->allowuninstall)
3547 { /* loop over all installed solvables */
3548 /* we create all update rules, but disable some later on depending on the job */
3549 for (i = installed->start, s = pool->solvables + i; i < installed->end; i++, s++)
3550 if (s->repo == installed)
3551 addupdaterule(solv, s, 0); /* allowall = 0 */
3553 addupdaterule(solv, 0, 0); /* create dummy rule; allowall = 0 */
3554 /* consistency check: we added a rule for _every_ system solvable */
3555 assert(solv->nrules - solv->systemrules == installed->end - installed->start);
3558 /* create special weak system rules */
3559 /* those are used later on to keep a version of the installed packages in
3561 if (installed && installed->nsolvables)
3563 solv->weaksystemrules = sat_calloc(installed->end - installed->start, sizeof(Id));
3564 FOR_REPO_SOLVABLES(installed, p, s)
3566 policy_findupdatepackages(solv, s, &q, 1);
3568 solv->weaksystemrules[p - installed->start] = pool_queuetowhatprovides(pool, &q);
3572 /* free unneeded memory */
3573 map_free(&addedmap);
3576 solv->weakrules = solv->nrules;
3578 /* try real hard to keep packages installed */
3581 FOR_REPO_SOLVABLES(installed, p, s)
3583 /* FIXME: can't work with refine_suggestion! */
3584 /* need to always add the rule but disable it */
3585 if (MAPTST(&solv->noupdate, p - installed->start))
3587 d = solv->weaksystemrules[p - installed->start];
3588 addrule(solv, p, d);
3592 /* all new rules are learnt after this point */
3593 solv->learntrules = solv->nrules;
3600 disableupdaterules(solv, job, -1);
3601 makeruledecisions(solv);
3603 POOL_DEBUG(SAT_DEBUG_STATS, "problems so far: %d\n", solv->problems.count);
3605 run_solver(solv, 1, 1);
3607 /* find suggested packages */
3608 if (!solv->problems.count)
3610 Id sug, *sugp, p, *pp;
3612 /* create map of all suggests that are still open */
3613 solv->recommends_index = -1;
3614 MAPZERO(&solv->suggestsmap);
3615 for (i = 0; i < solv->decisionq.count; i++)
3617 p = solv->decisionq.elements[i];
3620 s = pool->solvables + p;
3623 sugp = s->repo->idarraydata + s->suggests;
3624 while ((sug = *sugp++) != 0)
3626 FOR_PROVIDES(p, pp, sug)
3627 if (solv->decisionmap[p] > 0)
3630 continue; /* already fulfilled */
3631 FOR_PROVIDES(p, pp, sug)
3632 MAPSET(&solv->suggestsmap, p);
3636 for (i = 1; i < pool->nsolvables; i++)
3638 if (solv->decisionmap[i] != 0)
3640 s = pool->solvables + i;
3641 if (!MAPTST(&solv->suggestsmap, i))
3645 if (!pool_installable(pool, s))
3647 if (!solver_is_enhancing(solv, s))
3650 queue_push(&solv->suggestions, i);
3652 policy_filter_unwanted(solv, &solv->suggestions, 0, POLICY_MODE_SUGGEST);
3655 if (solv->problems.count)
3656 problems_to_solutions(solv, job);