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.
574 makeruledecisions(Solver *solv)
576 Pool *pool = solv->pool;
582 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- makeruledecisions ; size decisionq: %d -----\n",solv->decisionq.count);
584 decisionstart = solv->decisionq.count;
585 /* rpm rules don't have assertions, so we can start with the job
587 for (ri = solv->jobrules, r = solv->rules + ri; ri < solv->nrules; ri++, r++)
589 if (!r->w1 || r->w2) /* disabled or no assertion */
593 if (solv->decisionmap[vv] == 0)
595 queue_push(&solv->decisionq, v);
596 queue_push(&solv->decisionq_why, r - solv->rules);
597 solv->decisionmap[vv] = v > 0 ? 1 : -1;
598 IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
600 Solvable *s = solv->pool->solvables + vv;
602 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "conflicting %s (assertion)\n", solvable2str(solv->pool, s));
604 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "installing %s (assertion)\n", solvable2str(solv->pool, s));
608 if (v > 0 && solv->decisionmap[vv] > 0)
610 if (v < 0 && solv->decisionmap[vv] < 0)
612 /* found a conflict! */
613 /* ri >= learntrules cannot happen, as this would mean that the
614 * problem was not solvable, so we wouldn't have created the
615 * learnt rule at all */
616 assert(ri < solv->learntrules);
617 /* if we are weak, just disable ourself */
618 if (ri >= solv->weakrules)
620 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "assertion conflict, but I am weak, disabling ");
621 printrule(solv, SAT_DEBUG_UNSOLVABLE, r);
622 disablerule(solv, r);
626 /* only job and system rules left in the decisionq*/
627 /* find the decision which is the "opposite" of the jobrule */
628 for (i = 0; i < solv->decisionq.count; i++)
629 if (solv->decisionq.elements[i] == -v)
631 assert(i < solv->decisionq.count);
632 if (solv->decisionq_why.elements[i] == 0)
634 /* conflict with rpm rule, need only disable our rule */
635 assert(v > 0 || v == -SYSTEMSOLVABLE);
637 queue_push(&solv->problems, solv->learnt_pool.count);
638 queue_push(&solv->learnt_pool, ri);
639 queue_push(&solv->learnt_pool, v != -SYSTEMSOLVABLE ? -v : v);
640 queue_push(&solv->learnt_pool, 0);
641 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "conflict with rpm rule, disabling rule #%d\n", ri);
642 if (ri < solv->systemrules)
643 v = -(solv->ruletojob.elements[ri - solv->jobrules] + 1);
646 queue_push(&solv->problems, v);
647 queue_push(&solv->problems, 0);
648 disableproblem(solv, v);
652 /* conflict with another job or system rule */
654 queue_push(&solv->problems, solv->learnt_pool.count);
655 queue_push(&solv->learnt_pool, ri);
656 queue_push(&solv->learnt_pool, solv->decisionq_why.elements[i]);
657 queue_push(&solv->learnt_pool, 0);
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 = 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 /* rewind decisions to direct rpm rule assertions */
1565 for (i = solv->decisionq.count - 1; i >= solv->directdecisions; i--)
1567 v = solv->decisionq.elements[i];
1568 solv->decisionmap[v > 0 ? v : -v] = 0;
1571 POOL_DEBUG(SAT_DEBUG_UNSOLVABLE, "decisions done reduced from %d to %d\n", solv->decisionq.count, solv->directdecisions);
1573 solv->decisionq_why.count = solv->directdecisions;
1574 solv->decisionq.count = solv->directdecisions;
1575 solv->recommends_index = -1;
1576 solv->propagate_index = 0;
1578 /* adapt learnt rule status to new set of enabled/disabled rules */
1579 enabledisablelearntrules(solv);
1581 /* redo all job/system decisions */
1582 makeruledecisions(solv);
1583 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.
1841 * returns the current solver level
1846 setpropagatelearn(Solver *solv, int level, Id decision, int disablerules)
1848 Pool *pool = solv->pool;
1857 solv->decisionmap[decision] = level;
1859 solv->decisionmap[-decision] = -level;
1860 queue_push(&solv->decisionq, decision);
1861 queue_push(&solv->decisionq_why, 0);
1865 r = propagate(solv, level);
1869 return analyze_unsolvable(solv, r, disablerules);
1870 POOL_DEBUG(SAT_DEBUG_ANALYZE, "conflict with rule #%d\n", (int)(r - solv->rules));
1871 l = analyze(solv, level, r, &p, &d, &why); /* learnt rule in p and d */
1872 assert(l > 0 && l < level);
1873 POOL_DEBUG(SAT_DEBUG_ANALYZE, "reverting decisions (level %d -> %d)\n", level, l);
1875 revert(solv, level);
1876 r = addrule(solv, p, d); /* p requires d */
1878 assert(solv->learnt_why.count == (r - solv->rules) - solv->learntrules);
1879 queue_push(&solv->learnt_why, why);
1882 /* at least 2 literals, needs watches */
1883 watch2onhighest(solv, r);
1884 addwatches(solv, r);
1886 solv->decisionmap[p > 0 ? p : -p] = p > 0 ? level : -level;
1887 queue_push(&solv->decisionq, p);
1888 queue_push(&solv->decisionq_why, r - solv->rules);
1889 IF_POOLDEBUG (SAT_DEBUG_ANALYZE)
1891 POOL_DEBUG(SAT_DEBUG_ANALYZE, "decision: ");
1892 printruleelement(solv, SAT_DEBUG_ANALYZE, 0, p);
1893 POOL_DEBUG(SAT_DEBUG_ANALYZE, "new rule: ");
1894 printrule(solv, SAT_DEBUG_ANALYZE, r);
1902 * install best package from the queue. We add an extra package, inst, if
1903 * provided. See comment in weak install section.
1905 * returns the current solver level
1909 selectandinstall(Solver *solv, int level, Queue *dq, Id inst, int disablerules)
1911 Pool *pool = solv->pool;
1915 if (dq->count > 1 || inst)
1916 policy_filter_unwanted(solv, dq, inst, POLICY_MODE_CHOOSE);
1921 /* choose the supplemented one */
1922 for (i = 0; i < dq->count; i++)
1923 if (solver_is_supplementing(solv, pool->solvables + dq->elements[i]))
1927 for (i = 1; i < dq->count; i++)
1928 queue_push(&solv->branches, dq->elements[i]);
1929 queue_push(&solv->branches, -level);
1933 p = dq->elements[i];
1935 POOL_DEBUG(SAT_DEBUG_POLICY, "installing %s\n", solvable2str(pool, pool->solvables + p));
1937 return setpropagatelearn(solv, level, p, disablerules);
1941 /*-----------------------------------------------------------------*/
1942 /* Main solver interface */
1947 * create solver structure
1949 * pool: all available solvables
1950 * installed: installed Solvables
1953 * Upon solving, rules are created to flag the Solvables
1954 * of the 'installed' Repo as installed.
1958 solver_create(Pool *pool, Repo *installed)
1961 solv = (Solver *)sat_calloc(1, sizeof(Solver));
1963 solv->installed = installed;
1965 queue_init(&solv->ruletojob);
1966 queue_init(&solv->decisionq);
1967 queue_init(&solv->decisionq_why);
1968 queue_init(&solv->problems);
1969 queue_init(&solv->suggestions);
1970 queue_init(&solv->learnt_why);
1971 queue_init(&solv->learnt_pool);
1972 queue_init(&solv->branches);
1974 map_init(&solv->recommendsmap, pool->nsolvables);
1975 map_init(&solv->suggestsmap, pool->nsolvables);
1976 map_init(&solv->noupdate, installed ? installed->end - installed->start : 0);
1977 solv->recommends_index = 0;
1979 solv->decisionmap = (Id *)sat_calloc(pool->nsolvables, sizeof(Id));
1980 solv->rules = (Rule *)sat_malloc((solv->nrules + (RULES_BLOCK + 1)) * sizeof(Rule));
1981 memset(solv->rules, 0, sizeof(Rule));
1993 solver_free(Solver *solv)
1995 queue_free(&solv->ruletojob);
1996 queue_free(&solv->decisionq);
1997 queue_free(&solv->decisionq_why);
1998 queue_free(&solv->learnt_why);
1999 queue_free(&solv->learnt_pool);
2000 queue_free(&solv->problems);
2001 queue_free(&solv->suggestions);
2002 queue_free(&solv->branches);
2004 map_free(&solv->recommendsmap);
2005 map_free(&solv->suggestsmap);
2006 map_free(&solv->noupdate);
2008 sat_free(solv->decisionmap);
2009 sat_free(solv->rules);
2010 sat_free(solv->watches);
2011 sat_free(solv->weaksystemrules);
2012 sat_free(solv->obsoletes);
2013 sat_free(solv->obsoletes_data);
2018 /*-------------------------------------------------------*/
2023 * all rules have been set up, now actually run the solver
2028 run_solver(Solver *solv, int disablerules, int doweak)
2036 Pool *pool = solv->pool;
2039 IF_POOLDEBUG (SAT_DEBUG_RULE_CREATION)
2041 POOL_DEBUG (SAT_DEBUG_RULE_CREATION, "number of rules: %d\n", solv->nrules);
2042 for (i = 0; i < solv->nrules; i++)
2043 printrule(solv, SAT_DEBUG_RULE_CREATION, solv->rules + i);
2046 POOL_DEBUG(SAT_DEBUG_STATS, "initial decisions: %d\n", solv->decisionq.count);
2048 IF_POOLDEBUG (SAT_DEBUG_SCHUBI)
2049 printdecisions(solv);
2051 /* start SAT algorithm */
2053 systemlevel = level + 1;
2054 POOL_DEBUG(SAT_DEBUG_STATS, "solving...\n");
2065 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "propagating (propagate_index: %d; size decisionq: %d)...\n", solv->propagate_index, solv->decisionq.count);
2066 if ((r = propagate(solv, level)) != 0)
2068 if (analyze_unsolvable(solv, r, disablerules))
2076 * installed packages
2079 if (level < systemlevel && solv->installed && solv->installed->nsolvables)
2081 if (!solv->updatesystem)
2083 /* try to keep as many packages as possible */
2084 POOL_DEBUG(SAT_DEBUG_STATS, "installing system packages\n");
2085 for (i = solv->installed->start, n = 0; ; i++)
2087 if (n == solv->installed->nsolvables)
2089 if (i == solv->installed->end)
2090 i = solv->installed->start;
2091 s = pool->solvables + i;
2092 if (s->repo != solv->installed)
2095 if (solv->decisionmap[i] != 0)
2097 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "keeping %s\n", solvable2str(pool, s));
2099 level = setpropagatelearn(solv, level, i, disablerules);
2105 if (level <= olevel)
2109 if (solv->weaksystemrules)
2111 POOL_DEBUG(SAT_DEBUG_STATS, "installing weak system packages\n");
2112 for (i = solv->installed->start; i < solv->installed->end; i++)
2114 if (pool->solvables[i].repo != solv->installed)
2116 if (solv->decisionmap[i] > 0 || (solv->decisionmap[i] < 0 && solv->weaksystemrules[i - solv->installed->start] == 0))
2118 /* noupdate is set if a job is erasing the installed solvable or installing a specific version */
2119 if (MAPTST(&solv->noupdate, i - solv->installed->start))
2122 if (solv->weaksystemrules[i - solv->installed->start])
2124 dp = pool->whatprovidesdata + solv->weaksystemrules[i - solv->installed->start];
2125 while ((p = *dp++) != 0)
2127 if (solv->decisionmap[p] > 0)
2129 if (solv->decisionmap[p] == 0)
2133 continue; /* update package already installed */
2135 if (!dq.count && solv->decisionmap[i] != 0)
2138 /* FIXME: i is handled a bit different because we do not want
2139 * to have it pruned just because it is not recommened.
2140 * we should not prune installed packages instead */
2141 level = selectandinstall(solv, level, &dq, (solv->decisionmap[i] ? 0 : i), disablerules);
2147 if (level <= olevel)
2150 if (i < solv->installed->end)
2153 systemlevel = level;
2160 POOL_DEBUG(SAT_DEBUG_STATS, "deciding unresolved rules\n");
2161 for (i = 1, n = 1; ; i++, n++)
2163 if (n == solv->nrules)
2165 if (i == solv->nrules)
2167 r = solv->rules + i;
2168 if (!r->w1) // disabled rule
2173 /* binary or unary rule */
2174 /* need two positive undecided literals */
2175 if (r->p < 0 || r->w2 <= 0)
2177 if (solv->decisionmap[r->p] || solv->decisionmap[r->w2])
2179 queue_push(&dq, r->p);
2180 queue_push(&dq, r->w2);
2185 * all negative literals are installed
2186 * no positive literal is installed
2187 * i.e. the rule is not fulfilled and we
2188 * just need to decide on the positive literals
2192 if (solv->decisionmap[-r->p] <= 0)
2197 if (solv->decisionmap[r->p] > 0)
2199 if (solv->decisionmap[r->p] == 0)
2200 queue_push(&dq, r->p);
2202 dp = pool->whatprovidesdata + r->d;
2203 while ((p = *dp++) != 0)
2207 if (solv->decisionmap[-p] <= 0)
2212 if (solv->decisionmap[p] > 0)
2214 if (solv->decisionmap[p] == 0)
2221 /* dq.count < 2 cannot happen as this means that
2222 * the rule is unit */
2223 assert(dq.count > 1);
2224 IF_POOLDEBUG (SAT_DEBUG_PROPAGATE)
2226 POOL_DEBUG(SAT_DEBUG_PROPAGATE, "unfulfilled ");
2227 printrule(solv, SAT_DEBUG_PROPAGATE, r);
2231 level = selectandinstall(solv, level, &dq, 0, disablerules);
2237 if (level < systemlevel)
2240 } /* for(), decide */
2242 if (n != solv->nrules) /* continue if level < systemlevel */
2245 if (doweak && !solv->problems.count)
2249 POOL_DEBUG(SAT_DEBUG_STATS, "installing recommended packages\n");
2250 if (!REGARD_RECOMMENDS_OF_INSTALLED_ITEMS)
2252 for (i = 0; i < solv->decisionq.count; i++)
2254 p = solv->decisionq.elements[i];
2255 if (p > 0 && pool->solvables[p].repo == solv->installed)
2256 solv->decisionmap[p] = -solv->decisionmap[p];
2260 for (i = 1; i < pool->nsolvables; i++)
2262 if (solv->decisionmap[i] < 0)
2264 if (solv->decisionmap[i] > 0)
2266 Id *recp, rec, *pp, p;
2267 s = pool->solvables + i;
2268 /* installed, check for recommends */
2269 /* XXX need to special case AND ? */
2272 recp = s->repo->idarraydata + s->recommends;
2273 while ((rec = *recp++) != 0)
2276 FOR_PROVIDES(p, pp, rec)
2278 if (solv->decisionmap[p] > 0)
2283 else if (solv->decisionmap[p] == 0)
2285 queue_pushunique(&dq, p);
2293 s = pool->solvables + i;
2294 if (!s->supplements && !s->freshens)
2296 if (!pool_installable(pool, s))
2298 if (solver_is_supplementing(solv, s))
2299 queue_pushunique(&dq, i);
2302 if (!REGARD_RECOMMENDS_OF_INSTALLED_ITEMS)
2304 for (i = 0; i < solv->decisionq.count; i++)
2306 p = solv->decisionq.elements[i];
2307 if (p > 0 && pool->solvables[p].repo == solv->installed)
2308 solv->decisionmap[p] = -solv->decisionmap[p];
2314 policy_filter_unwanted(solv, &dq, 0, POLICY_MODE_RECOMMEND);
2316 POOL_DEBUG(SAT_DEBUG_STATS, "installing recommended %s\n", solvable2str(pool, pool->solvables + p));
2317 level = setpropagatelearn(solv, level, p, 0);
2322 if (solv->solution_callback)
2324 solv->solution_callback(solv, solv->solution_callback_data);
2325 if (solv->branches.count)
2327 int i = solv->branches.count - 1;
2328 int l = -solv->branches.elements[i];
2330 if (solv->branches.elements[i - 1] < 0)
2332 p = solv->branches.elements[i];
2333 POOL_DEBUG(SAT_DEBUG_STATS, "branching with %s\n", solvable2str(pool, pool->solvables + p));
2335 for (j = i + 1; j < solv->branches.count; j++)
2336 queue_push(&dq, solv->branches.elements[j]);
2337 solv->branches.count = i;
2339 revert(solv, level);
2341 for (j = 0; j < dq.count; j++)
2342 queue_push(&solv->branches, dq.elements[j]);
2344 level = setpropagatelearn(solv, level, p, disablerules);
2352 /* all branches done, we're finally finished */
2356 /* minimization step */
2357 if (solv->branches.count)
2359 int l = 0, lasti = -1, lastl = -1;
2361 for (i = solv->branches.count - 1; i >= 0; i--)
2363 p = solv->branches.elements[i];
2366 else if (p > 0 && solv->decisionmap[p] > l + 1)
2374 /* kill old solvable so that we do not loop */
2375 p = solv->branches.elements[lasti];
2376 solv->branches.elements[lasti] = 0;
2377 POOL_DEBUG(SAT_DEBUG_STATS, "minimizing %d -> %d with %s\n", solv->decisionmap[p], l, solvable2str(pool, pool->solvables + p));
2380 revert(solv, level);
2382 level = setpropagatelearn(solv, level, p, disablerules);
2399 * at this point, all rules that led to conflicts are disabled.
2400 * we re-enable all rules of a problem set but rule "sug", then
2401 * continue to disable more rules until there as again a solution.
2404 /* FIXME: think about conflicting assertions */
2407 refine_suggestion(Solver *solv, Queue *job, Id *problem, Id sug, Queue *refined)
2409 Pool *pool = solv->pool;
2416 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
2418 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "refine_suggestion start\n");
2419 for (i = 0; problem[i]; i++)
2421 if (problem[i] == sug)
2422 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "=> ");
2423 printproblem(solv, problem[i]);
2426 queue_init(&disabled);
2427 queue_empty(refined);
2428 queue_push(refined, sug);
2430 /* re-enable all problem rules with the exception of "sug" */
2434 for (i = 0; problem[i]; i++)
2435 if (problem[i] != sug)
2436 enableproblem(solv, problem[i]);
2439 disableupdaterules(solv, job, -(sug + 1));
2443 /* re-enable as many weak rules as possible */
2444 for (i = solv->weakrules; i < solv->learntrules; i++)
2446 r = solv->rules + i;
2448 enablerule(solv, r);
2451 queue_empty(&solv->problems);
2452 revert(solv, 1); /* XXX move to reset_solver? */
2455 if (!solv->problems.count)
2456 run_solver(solv, 0, 0);
2458 if (!solv->problems.count)
2460 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "no more problems!\n");
2461 IF_POOLDEBUG (SAT_DEBUG_SCHUBI)
2462 printdecisions(solv);
2463 break; /* great, no more problems */
2465 disabledcnt = disabled.count;
2466 /* start with 1 to skip over proof index */
2467 for (i = 1; i < solv->problems.count - 1; i++)
2469 /* ignore solutions in refined */
2470 v = solv->problems.elements[i];
2472 break; /* end of problem reached */
2473 for (j = 0; problem[j]; j++)
2474 if (problem[j] != sug && problem[j] == v)
2478 queue_push(&disabled, v);
2480 if (disabled.count == disabledcnt)
2482 /* no solution found, this was an invalid suggestion! */
2483 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "no solution found!\n");
2487 if (disabled.count == disabledcnt + 1)
2489 /* just one suggestion, add it to refined list */
2490 v = disabled.elements[disabledcnt];
2491 queue_push(refined, v);
2492 disableproblem(solv, v);
2494 disableupdaterules(solv, job, -(v + 1));
2498 /* more than one solution, disable all */
2499 /* do not push anything on refine list */
2500 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
2502 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "more than one solution found:\n");
2503 for (i = disabledcnt; i < disabled.count; i++)
2504 printproblem(solv, disabled.elements[i]);
2506 for (i = disabledcnt; i < disabled.count; i++)
2507 disableproblem(solv, disabled.elements[i]);
2510 /* all done, get us back into the same state as before */
2511 /* enable refined rules again */
2512 for (i = 0; i < disabled.count; i++)
2513 enableproblem(solv, disabled.elements[i]);
2514 /* disable problem rules again */
2515 for (i = 0; problem[i]; i++)
2516 disableproblem(solv, problem[i]);
2517 disableupdaterules(solv, job, -1);
2518 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "refine_suggestion end\n");
2522 problems_to_solutions(Solver *solv, Queue *job)
2524 Pool *pool = solv->pool;
2532 if (!solv->problems.count)
2534 queue_clone(&problems, &solv->problems);
2535 queue_init(&solution);
2536 queue_init(&solutions);
2537 /* copy over proof index */
2538 queue_push(&solutions, problems.elements[0]);
2539 problem = problems.elements + 1;
2540 for (i = 1; i < problems.count; i++)
2542 Id v = problems.elements[i];
2545 /* mark end of this problem */
2546 queue_push(&solutions, 0);
2547 queue_push(&solutions, 0);
2548 if (i + 1 == problems.count)
2550 /* copy over proof of next problem */
2551 queue_push(&solutions, problems.elements[i + 1]);
2553 problem = problems.elements + i + 1;
2556 refine_suggestion(solv, job, problem, v, &solution);
2557 if (!solution.count)
2558 continue; /* this solution didn't work out */
2560 for (j = 0; j < solution.count; j++)
2562 why = solution.elements[j];
2563 /* must be either job descriptor or system rule */
2564 assert(why < 0 || (why >= solv->systemrules && why < solv->weakrules));
2566 printproblem(solv, why);
2570 /* job descriptor */
2571 queue_push(&solutions, 0);
2572 queue_push(&solutions, -why);
2576 /* system rule, find replacement package */
2578 p = solv->installed->start + (why - solv->systemrules);
2579 if (solv->weaksystemrules && solv->weaksystemrules[why - solv->systemrules])
2581 Id *dp = pool->whatprovidesdata + solv->weaksystemrules[why - solv->systemrules];
2584 if (*dp >= solv->installed->start && *dp < solv->installed->start + solv->installed->nsolvables)
2586 if (solv->decisionmap[*dp] > 0)
2593 queue_push(&solutions, p);
2594 queue_push(&solutions, rp);
2597 /* mark end of this solution */
2598 queue_push(&solutions, 0);
2599 queue_push(&solutions, 0);
2601 queue_free(&solution);
2602 queue_free(&problems);
2603 /* copy queue over to solutions */
2604 queue_free(&solv->problems);
2605 queue_clone(&solv->problems, &solutions);
2607 /* bring solver back into problem state */
2608 revert(solv, 1); /* XXX move to reset_solver? */
2611 assert(solv->problems.count == solutions.count);
2612 queue_free(&solutions);
2616 solver_next_problem(Solver *solv, Id problem)
2620 return solv->problems.count ? 1 : 0;
2621 pp = solv->problems.elements + problem;
2622 while (pp[0] || pp[1])
2626 while (pp[0] || pp[1])
2631 problem = pp - solv->problems.elements;
2632 if (problem >= solv->problems.count)
2638 solver_next_solution(Solver *solv, Id problem, Id solution)
2644 pp = solv->problems.elements + solution;
2645 return pp[0] || pp[1] ? solution : 0;
2647 pp = solv->problems.elements + solution;
2648 while (pp[0] || pp[1])
2651 solution = pp - solv->problems.elements;
2652 return pp[0] || pp[1] ? solution : 0;
2656 solver_next_solutionelement(Solver *solv, Id problem, Id solution, Id element, Id *p, Id *rp)
2659 element = element ? element + 2 : solution;
2660 pp = solv->problems.elements + element;
2661 if (!(pp[0] || pp[1]))
2670 * create obsoletesmap from solver decisions
2671 * required for decision handling
2675 create_obsoletesmap(Solver *solv)
2677 Pool *pool = solv->pool;
2678 Repo *installed = solv->installed;
2679 Id p, *obsoletesmap = NULL;
2683 obsoletesmap = (Id *)sat_calloc(pool->nsolvables, sizeof(Id));
2686 for (i = 0; i < solv->decisionq.count; i++)
2690 n = solv->decisionq.elements[i];
2693 if (n == SYSTEMSOLVABLE)
2695 s = pool->solvables + n;
2696 if (s->repo == installed) /* obsoletes don't count for already installed packages */
2698 FOR_PROVIDES(p, pp, s->name)
2699 if (s->name == pool->solvables[p].name)
2701 if (pool->solvables[p].repo == installed && !obsoletesmap[p])
2703 obsoletesmap[p] = n;
2708 for (i = 0; i < solv->decisionq.count; i++)
2713 n = solv->decisionq.elements[i];
2716 if (n == SYSTEMSOLVABLE)
2718 s = pool->solvables + n;
2719 if (s->repo == installed) /* obsoletes don't count for already installed packages */
2723 obsp = s->repo->idarraydata + s->obsoletes;
2724 while ((obs = *obsp++) != 0)
2725 FOR_PROVIDES(p, pp, obs)
2727 if (pool->solvables[p].repo == installed && !obsoletesmap[p])
2729 obsoletesmap[p] = n;
2735 return obsoletesmap;
2744 printdecisions(Solver *solv)
2746 Pool *pool = solv->pool;
2747 Repo *installed = solv->installed;
2748 Id p, *obsoletesmap = create_obsoletesmap( solv );
2752 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- Decisions -----\n");
2754 /* print solvables to be erased */
2758 FOR_REPO_SOLVABLES(installed, p, s)
2760 if (solv->decisionmap[p] >= 0)
2762 if (obsoletesmap[p])
2764 POOL_DEBUG(SAT_DEBUG_RESULT, "erase %s\n", solvable2str(pool, s));
2768 /* print solvables to be installed */
2770 for (i = 0; i < solv->decisionq.count; i++)
2773 p = solv->decisionq.elements[i];
2776 IF_POOLDEBUG (SAT_DEBUG_SCHUBI)
2779 s = pool->solvables + p;
2780 POOL_DEBUG(SAT_DEBUG_SCHUBI, "level of %s is %d\n", solvable2str(pool, s), p);
2784 if (p == SYSTEMSOLVABLE)
2786 POOL_DEBUG(SAT_DEBUG_SCHUBI, "SYSTEMSOLVABLE\n");
2789 s = pool->solvables + p;
2790 if (installed && s->repo == installed)
2793 if (!obsoletesmap[p])
2795 POOL_DEBUG(SAT_DEBUG_RESULT, "install %s", solvable2str(pool, s));
2799 POOL_DEBUG(SAT_DEBUG_RESULT, "update %s", solvable2str(pool, s));
2800 POOL_DEBUG(SAT_DEBUG_RESULT, " (obsoletes");
2801 for (j = installed->start; j < installed->end; j++)
2802 if (obsoletesmap[j] == p)
2803 POOL_DEBUG(SAT_DEBUG_RESULT, " %s", solvable2str(pool, pool->solvables + j));
2804 POOL_DEBUG(SAT_DEBUG_RESULT, ")");
2806 POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
2809 sat_free(obsoletesmap);
2811 if (solv->suggestions.count)
2813 POOL_DEBUG(SAT_DEBUG_RESULT, "\nsuggested packages:\n");
2814 for (i = 0; i < solv->suggestions.count; i++)
2816 s = pool->solvables + solv->suggestions.elements[i];
2817 POOL_DEBUG(SAT_DEBUG_RESULT, "- %s\n", solvable2str(pool, s));
2820 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- Decisions end -----\n");
2823 /* this is basically the reverse of addrpmrulesforsolvable */
2825 solver_problemruleinfo(Solver *solv, Queue *job, Id rid, Id *depp, Id *sourcep, Id *targetp)
2827 Pool *pool = solv->pool;
2828 Repo *installed = solv->installed;
2832 Id p, *pp, req, *reqp, con, *conp, obs, *obsp, *dp;
2834 assert(rid < solv->weakrules);
2835 if (rid >= solv->systemrules)
2838 *sourcep = solv->installed->start + (rid - solv->systemrules);
2840 return SOLVER_PROBLEM_UPDATE_RULE;
2842 if (rid >= solv->jobrules)
2845 r = solv->rules + rid;
2846 p = solv->ruletojob.elements[rid - solv->jobrules];
2847 *depp = job->elements[p + 1];
2849 *targetp = job->elements[p];
2850 if (r->d == 0 && r->w2 == 0 && r->p == -SYSTEMSOLVABLE)
2851 return SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP;
2852 return SOLVER_PROBLEM_JOB_RULE;
2856 /* a rpm rule assertion */
2857 assert(rid != -SYSTEMSOLVABLE);
2858 s = pool->solvables - rid;
2859 if (installed && !solv->fixsystem && s->repo == installed)
2861 assert(!dontfix); /* dontfix packages never have a neg assertion */
2862 /* see why the package is not installable */
2863 if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC && !pool_installable(pool, s))
2864 return SOLVER_PROBLEM_NOT_INSTALLABLE;
2865 /* check requires */
2866 assert(s->requires);
2867 reqp = s->repo->idarraydata + s->requires;
2868 while ((req = *reqp++) != 0)
2870 if (req == SOLVABLE_PREREQMARKER)
2872 dp = pool_whatprovides(pool, req);
2880 return SOLVER_PROBLEM_NOTHING_PROVIDES_DEP;
2882 r = solv->rules + rid;
2884 if (r->d == 0 && r->w2 == 0)
2886 /* an assertion. we don't store them as rpm rules, so
2890 s = pool->solvables - r->p;
2891 if (installed && !solv->fixsystem && s->repo == installed)
2893 if (r->d == 0 && r->w2 < 0)
2895 /* a package conflict */
2896 Solvable *s2 = pool->solvables - r->w2;
2899 if (installed && !solv->fixsystem && s2->repo == installed)
2902 /* if both packages have the same name and at least one of them
2903 * is not installed, they conflict */
2904 if (s->name == s2->name && (!installed || (s->repo != installed || s2->repo != installed)))
2909 return SOLVER_PROBLEM_SAME_NAME;
2912 /* check conflicts in both directions */
2915 conp = s->repo->idarraydata + s->conflicts;
2916 while ((con = *conp++) != 0)
2918 FOR_PROVIDES(p, pp, con)
2920 if (dontfix && pool->solvables[p].repo == installed)
2927 return SOLVER_PROBLEM_PACKAGE_CONFLICT;
2933 conp = s2->repo->idarraydata + s2->conflicts;
2934 while ((con = *conp++) != 0)
2936 FOR_PROVIDES(p, pp, con)
2938 if (dontfix2 && pool->solvables[p].repo == installed)
2945 return SOLVER_PROBLEM_PACKAGE_CONFLICT;
2949 /* check obsoletes in both directions */
2950 if ((!installed || s->repo != installed) && s->obsoletes)
2952 obsp = s->repo->idarraydata + s->obsoletes;
2953 while ((obs = *obsp++) != 0)
2955 FOR_PROVIDES(p, pp, obs)
2962 return SOLVER_PROBLEM_PACKAGE_OBSOLETES;
2966 if ((!installed || s2->repo != installed) && s2->obsoletes)
2968 obsp = s2->repo->idarraydata + s2->obsoletes;
2969 while ((obs = *obsp++) != 0)
2971 FOR_PROVIDES(p, pp, obs)
2978 return SOLVER_PROBLEM_PACKAGE_OBSOLETES;
2982 /* all cases checked, can't happen */
2985 /* simple requires */
2986 assert(s->requires);
2987 reqp = s->repo->idarraydata + s->requires;
2988 while ((req = *reqp++) != 0)
2990 if (req == SOLVABLE_PREREQMARKER)
2992 dp = pool_whatprovides(pool, req);
2995 if (*dp == r->w2 && dp[1] == 0)
2998 else if (dp - pool->whatprovidesdata == r->d)
3005 return SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE;
3009 findproblemrule_internal(Solver *solv, Id idx, Id *reqrp, Id *conrp, Id *sysrp, Id *jobrp)
3012 Id lreqr, lconr, lsysr, ljobr;
3016 lreqr = lconr = lsysr = ljobr = 0;
3017 while ((rid = solv->learnt_pool.elements[idx++]) != 0)
3019 if (rid >= solv->learntrules)
3020 findproblemrule_internal(solv, solv->learnt_why.elements[rid - solv->learntrules], &lreqr, &lconr, &lsysr, &ljobr);
3021 else if (rid >= solv->systemrules)
3026 else if (rid >= solv->jobrules)
3033 r = solv->rules + rid;
3034 if (!r->d && r->w2 < 0)
3047 /* assertion, counts as require rule */
3048 /* ignore system solvable as we need useful info */
3049 if (rid == -SYSTEMSOLVABLE)
3051 if (!*reqrp || !reqassert)
3058 if (!*reqrp && lreqr)
3060 if (!*conrp && lconr)
3062 if (!*jobrp && ljobr)
3064 if (!*sysrp && lsysr)
3069 solver_findproblemrule(Solver *solv, Id problem)
3071 Id reqr, conr, sysr, jobr;
3072 Id idx = solv->problems.elements[problem - 1];
3073 reqr = conr = sysr = jobr = 0;
3074 findproblemrule_internal(solv, idx, &reqr, &conr, &sysr, &jobr);
3087 printprobleminfo(Solver *solv, Queue *job, Id problem)
3089 Pool *pool = solv->pool;
3091 Id dep, source, target;
3094 probr = solver_findproblemrule(solv, problem);
3095 switch (solver_problemruleinfo(solv, job, probr, &dep, &source, &target))
3097 case SOLVER_PROBLEM_UPDATE_RULE:
3098 s = pool_id2solvable(pool, source);
3099 POOL_DEBUG(SAT_DEBUG_RESULT, "problem with installed package %s\n", solvable2str(pool, s));
3101 case SOLVER_PROBLEM_JOB_RULE:
3102 POOL_DEBUG(SAT_DEBUG_RESULT, "conflicting requests\n");
3104 case SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP:
3105 POOL_DEBUG(SAT_DEBUG_RESULT, "nothing provides requested %s\n", dep2str(pool, dep));
3107 case SOLVER_PROBLEM_NOT_INSTALLABLE:
3108 s = pool_id2solvable(pool, source);
3109 POOL_DEBUG(SAT_DEBUG_RESULT, "package %s is not installable\n", solvable2str(pool, s));
3111 case SOLVER_PROBLEM_NOTHING_PROVIDES_DEP:
3112 s = pool_id2solvable(pool, source);
3113 POOL_DEBUG(SAT_DEBUG_RESULT, "nothing provides %s needed by %s\n", dep2str(pool, dep), solvable2str(pool, s));
3115 case SOLVER_PROBLEM_SAME_NAME:
3116 s = pool_id2solvable(pool, source);
3117 s2 = pool_id2solvable(pool, target);
3118 POOL_DEBUG(SAT_DEBUG_RESULT, "cannot install both %s and %s\n", solvable2str(pool, s), solvable2str(pool, s2));
3120 case SOLVER_PROBLEM_PACKAGE_CONFLICT:
3121 s = pool_id2solvable(pool, source);
3122 s2 = pool_id2solvable(pool, target);
3123 POOL_DEBUG(SAT_DEBUG_RESULT, "package %s conflicts with %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
3125 case SOLVER_PROBLEM_PACKAGE_OBSOLETES:
3126 s = pool_id2solvable(pool, source);
3127 s2 = pool_id2solvable(pool, target);
3128 POOL_DEBUG(SAT_DEBUG_RESULT, "package %s obsoletes %s provided by %s\n", solvable2str(pool, s), dep2str(pool, dep), solvable2str(pool, s2));
3130 case SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE:
3131 s = pool_id2solvable(pool, source);
3132 POOL_DEBUG(SAT_DEBUG_RESULT, "package %s requires %s, but none of the providers can be installed\n", solvable2str(pool, s), dep2str(pool, dep));
3138 printsolutions(Solver *solv, Queue *job)
3140 Pool *pool = solv->pool;
3143 Id problem, solution, element;
3146 POOL_DEBUG(SAT_DEBUG_RESULT, "Encountered problems! Here are the solutions:\n\n");
3149 while ((problem = solver_next_problem(solv, problem)) != 0)
3151 POOL_DEBUG(SAT_DEBUG_RESULT, "Problem %d:\n", pcnt++);
3152 POOL_DEBUG(SAT_DEBUG_RESULT, "====================================\n");
3153 printprobleminfo(solv, job, problem);
3154 POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
3156 while ((solution = solver_next_solution(solv, problem, solution)) != 0)
3159 while ((element = solver_next_solutionelement(solv, problem, solution, element, &p, &rp)) != 0)
3163 /* job, rp is index into job queue */
3164 what = job->elements[rp];
3165 switch (job->elements[rp - 1])
3167 case SOLVER_INSTALL_SOLVABLE:
3168 s = pool->solvables + what;
3169 if (solv->installed && s->repo == solv->installed)
3170 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not keep %s installed\n", solvable2str(pool, s));
3172 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install %s\n", solvable2str(pool, s));
3174 case SOLVER_ERASE_SOLVABLE:
3175 s = pool->solvables + what;
3176 if (solv->installed && s->repo == solv->installed)
3177 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall %s\n", solvable2str(pool, s));
3179 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not forbid installation of %s\n", solvable2str(pool, s));
3181 case SOLVER_INSTALL_SOLVABLE_NAME:
3182 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install %s\n", id2str(pool, what));
3184 case SOLVER_ERASE_SOLVABLE_NAME:
3185 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall %s\n", id2str(pool, what));
3187 case SOLVER_INSTALL_SOLVABLE_PROVIDES:
3188 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install a solvable providing %s\n", dep2str(pool, what));
3190 case SOLVER_ERASE_SOLVABLE_PROVIDES:
3191 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall all solvables providing %s\n", dep2str(pool, what));
3193 case SOLVER_INSTALL_SOLVABLE_UPDATE:
3194 s = pool->solvables + what;
3195 POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install most recent version of %s\n", solvable2str(pool, s));
3198 POOL_DEBUG(SAT_DEBUG_RESULT, "- do something different\n");
3204 /* policy, replace p with rp */
3205 s = pool->solvables + p;
3206 sd = rp ? pool->solvables + rp : 0;
3210 if (!solv->allowdowngrade && evrcmp(pool, s->evr, sd->evr, EVRCMP_MATCH_RELEASE) > 0)
3212 POOL_DEBUG(SAT_DEBUG_RESULT, "- allow downgrade of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
3215 if (!solv->allowarchchange && s->name == sd->name && s->arch != sd->arch && policy_illegal_archchange(pool, s, sd))
3217 POOL_DEBUG(SAT_DEBUG_RESULT, "- allow architecture change of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
3220 if (!solv->allowvendorchange && s->name == sd->name && s->vendor != sd->vendor && policy_illegal_vendorchange(pool, s, sd))
3223 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));
3225 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));
3229 POOL_DEBUG(SAT_DEBUG_RESULT, "- allow replacement of %s with %s\n", solvable2str(pool, s), solvable2str(pool, sd));
3233 POOL_DEBUG(SAT_DEBUG_RESULT, "- allow deinstallation of %s\n", solvable2str(pool, s));
3238 POOL_DEBUG(SAT_DEBUG_RESULT, "\n");
3244 /* for each installed solvable find which packages with *different* names
3245 * obsolete the solvable.
3246 * this index is used in policy_findupdatepackages if noupdateprovide is set.
3250 create_obsolete_index(Solver *solv)
3252 Pool *pool = solv->pool;
3254 Repo *installed = solv->installed;
3255 Id p, *pp, obs, *obsp, *obsoletes, *obsoletes_data;
3258 if (!installed || !installed->nsolvables)
3260 /* create reverse obsoletes map for installed solvables */
3261 solv->obsoletes = obsoletes = sat_calloc(installed->end - installed->start, sizeof(Id));
3262 for (i = 1; i < pool->nsolvables; i++)
3264 s = pool->solvables + i;
3265 if (s->repo == installed)
3269 if (!pool_installable(pool, s))
3271 obsp = s->repo->idarraydata + s->obsoletes;
3272 while ((obs = *obsp++) != 0)
3273 FOR_PROVIDES(p, pp, obs)
3275 if (pool->solvables[p].repo != installed)
3277 if (pool->solvables[p].name == s->name)
3279 obsoletes[p - installed->start]++;
3283 for (i = 0; i < installed->nsolvables; i++)
3286 n += obsoletes[i] + 1;
3289 solv->obsoletes_data = obsoletes_data = sat_calloc(n + 1, sizeof(Id));
3290 POOL_DEBUG(SAT_DEBUG_STATS, "obsoletes data: %d entries\n", n + 1);
3291 for (i = pool->nsolvables - 1; i > 0; i--)
3293 s = pool->solvables + i;
3294 if (s->repo == installed)
3298 if (!pool_installable(pool, s))
3300 obsp = s->repo->idarraydata + s->obsoletes;
3301 while ((obs = *obsp++) != 0)
3302 FOR_PROVIDES(p, pp, obs)
3304 if (pool->solvables[p].repo != installed)
3306 if (pool->solvables[p].name == s->name)
3308 p -= installed->start;
3309 if (obsoletes_data[obsoletes[p]] != i)
3310 obsoletes_data[--obsoletes[p]] = i;
3316 /*-----------------------------------------------------------------*/
3326 solver_solve(Solver *solv, Queue *job)
3328 Pool *pool = solv->pool;
3329 Repo *installed = solv->installed;
3332 Map addedmap; /* '1' == have rpm-rules for solvable */
3333 Id how, what, p, *pp, d;
3337 /* create whatprovides if not already there */
3338 if (!pool->whatprovides)
3339 pool_createwhatprovides(pool);
3341 /* create obsolete index if needed */
3342 if (solv->noupdateprovide)
3343 create_obsolete_index(solv);
3346 * create basic rule set of all involved packages
3347 * use addedmap bitmap to make sure we don't create rules twice
3351 map_init(&addedmap, pool->nsolvables);
3355 * always install our system solvable
3357 MAPSET(&addedmap, SYSTEMSOLVABLE);
3358 queue_push(&solv->decisionq, SYSTEMSOLVABLE);
3359 queue_push(&solv->decisionq_why, 0);
3360 solv->decisionmap[SYSTEMSOLVABLE] = 1;
3363 * create rules for all package that could be involved with the solving
3364 * so called: rpm rules
3369 oldnrules = solv->nrules;
3370 POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** create rpm rules for installed solvables ***\n");
3371 FOR_REPO_SOLVABLES(installed, p, s)
3372 addrpmrulesforsolvable(solv, s, &addedmap);
3373 POOL_DEBUG(SAT_DEBUG_STATS, "added %d rpm rules for installed solvables\n", solv->nrules - oldnrules);
3374 POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** create rpm rules for updaters of installed solvables ***\n");
3375 oldnrules = solv->nrules;
3376 FOR_REPO_SOLVABLES(installed, p, s)
3377 addrpmrulesforupdaters(solv, s, &addedmap, 1);
3378 POOL_DEBUG(SAT_DEBUG_STATS, "added %d rpm rules for updaters of installed solvables\n", solv->nrules - oldnrules);
3381 POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** create rpm rules for packages involved with a job ***\n");
3382 oldnrules = solv->nrules;
3383 for (i = 0; i < job->count; i += 2)
3385 how = job->elements[i];
3386 what = job->elements[i + 1];
3390 case SOLVER_INSTALL_SOLVABLE:
3391 addrpmrulesforsolvable(solv, pool->solvables + what, &addedmap);
3393 case SOLVER_INSTALL_SOLVABLE_NAME:
3394 case SOLVER_INSTALL_SOLVABLE_PROVIDES:
3395 FOR_PROVIDES(p, pp, what)
3397 /* if by name, ensure that the name matches */
3398 if (how == SOLVER_INSTALL_SOLVABLE_NAME && pool->solvables[p].name != what)
3400 addrpmrulesforsolvable(solv, pool->solvables + p, &addedmap);
3403 case SOLVER_INSTALL_SOLVABLE_UPDATE:
3404 /* dont allow downgrade */
3405 addrpmrulesforupdaters(solv, pool->solvables + what, &addedmap, 0);
3409 POOL_DEBUG(SAT_DEBUG_STATS, "added %d rpm rules for packages involved in a job\n", solv->nrules - oldnrules);
3411 POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** create rpm rules for recommended/suggested packages ***\n");
3413 oldnrules = solv->nrules;
3414 addrpmrulesforweak(solv, &addedmap);
3415 POOL_DEBUG(SAT_DEBUG_STATS, "added %d rpm rules because of weak dependencies\n", solv->nrules - oldnrules);
3417 IF_POOLDEBUG (SAT_DEBUG_STATS)
3419 int possible = 0, installable = 0;
3420 for (i = 1; i < pool->nsolvables; i++)
3422 if (pool_installable(pool, pool->solvables + i))
3424 if (MAPTST(&addedmap, i))
3427 POOL_DEBUG(SAT_DEBUG_STATS, "%d of %d installable solvables considered for solving (rules has been generated for)\n", possible, installable);
3431 * first pass done, we now have all the rpm rules we need.
3432 * unify existing rules before going over all job rules and
3434 * at this point the system is always solvable,
3435 * as an empty system (remove all packages) is a valid solution
3438 unifyrules(solv); /* remove duplicate rpm rules */
3439 solv->directdecisions = solv->decisionq.count;
3441 POOL_DEBUG(SAT_DEBUG_STATS, "decisions so far: %d\n", solv->decisionq.count);
3442 IF_POOLDEBUG (SAT_DEBUG_SCHUBI)
3443 printdecisions (solv);
3446 * now add all job rules
3449 POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** Add JOB rules ***\n");
3451 solv->jobrules = solv->nrules;
3453 for (i = 0; i < job->count; i += 2)
3455 oldnrules = solv->nrules;
3457 how = job->elements[i];
3458 what = job->elements[i + 1];
3461 case SOLVER_INSTALL_SOLVABLE: /* install specific solvable */
3462 s = pool->solvables + what;
3463 POOL_DEBUG(SAT_DEBUG_JOB, "job: install solvable %s\n", solvable2str(pool, s));
3464 addrule(solv, what, 0); /* install by Id */
3465 queue_push(&solv->ruletojob, i);
3467 case SOLVER_ERASE_SOLVABLE:
3468 s = pool->solvables + what;
3469 POOL_DEBUG(SAT_DEBUG_JOB, "job: erase solvable %s\n", solvable2str(pool, s));
3470 addrule(solv, -what, 0); /* remove by Id */
3471 queue_push(&solv->ruletojob, i);
3473 case SOLVER_INSTALL_SOLVABLE_NAME: /* install by capability */
3474 case SOLVER_INSTALL_SOLVABLE_PROVIDES:
3475 if (how == SOLVER_INSTALL_SOLVABLE_NAME)
3476 POOL_DEBUG(SAT_DEBUG_JOB, "job: install name %s\n", id2str(pool, what));
3477 if (how == SOLVER_INSTALL_SOLVABLE_PROVIDES)
3478 POOL_DEBUG(SAT_DEBUG_JOB, "job: install provides %s\n", dep2str(pool, what));
3480 FOR_PROVIDES(p, pp, what)
3482 /* if by name, ensure that the name matches */
3483 if (how == SOLVER_INSTALL_SOLVABLE_NAME && pool->solvables[p].name != what)
3489 /* no provider, make this an impossible rule */
3490 queue_push(&q, -SYSTEMSOLVABLE);
3493 p = queue_shift(&q); /* get first provider */
3495 d = 0; /* single provider ? -> make assertion */
3497 d = pool_queuetowhatprovides(pool, &q); /* get all providers */
3498 addrule(solv, p, d); /* add 'requires' rule */
3499 queue_push(&solv->ruletojob, i);
3501 case SOLVER_ERASE_SOLVABLE_NAME: /* remove by capability */
3502 case SOLVER_ERASE_SOLVABLE_PROVIDES:
3503 if (how == SOLVER_ERASE_SOLVABLE_NAME)
3504 POOL_DEBUG(SAT_DEBUG_JOB, "job: erase name %s\n", id2str(pool, what));
3505 if (how == SOLVER_ERASE_SOLVABLE_PROVIDES)
3506 POOL_DEBUG(SAT_DEBUG_JOB, "job: erase provides %s\n", dep2str(pool, what));
3507 FOR_PROVIDES(p, pp, what)
3509 /* if by name, ensure that the name matches */
3510 if (how == SOLVER_ERASE_SOLVABLE_NAME && pool->solvables[p].name != what)
3512 addrule(solv, -p, 0); /* add 'remove' rule */
3513 queue_push(&solv->ruletojob, i);
3516 case SOLVER_INSTALL_SOLVABLE_UPDATE: /* find update for solvable */
3517 s = pool->solvables + what;
3518 POOL_DEBUG(SAT_DEBUG_JOB, "job: update %s\n", solvable2str(pool, s));
3519 addupdaterule(solv, s, 0);
3520 queue_push(&solv->ruletojob, i);
3523 IF_POOLDEBUG (SAT_DEBUG_JOB)
3526 if (solv->nrules == oldnrules)
3527 POOL_DEBUG(SAT_DEBUG_JOB, " - no rule created");
3528 for (j = oldnrules; j < solv->nrules; j++)
3530 POOL_DEBUG(SAT_DEBUG_JOB, " - job ");
3531 printrule(solv, SAT_DEBUG_JOB, solv->rules + j);
3535 assert(solv->ruletojob.count == solv->nrules - solv->jobrules);
3538 * now add system rules
3542 POOL_DEBUG(SAT_DEBUG_SCHUBI, "*** Add system rules ***\n");
3545 solv->systemrules = solv->nrules;
3548 * create rules for updating installed solvables
3552 if (installed && !solv->allowuninstall)
3553 { /* loop over all installed solvables */
3554 /* we create all update rules, but disable some later on depending on the job */
3555 for (i = installed->start, s = pool->solvables + i; i < installed->end; i++, s++)
3556 if (s->repo == installed)
3557 addupdaterule(solv, s, 0); /* allowall = 0 */
3559 addupdaterule(solv, 0, 0); /* create dummy rule; allowall = 0 */
3560 /* consistency check: we added a rule for _every_ system solvable */
3561 assert(solv->nrules - solv->systemrules == installed->end - installed->start);
3564 /* create special weak system rules */
3565 /* those are used later on to keep a version of the installed packages in
3567 if (installed && installed->nsolvables)
3569 solv->weaksystemrules = sat_calloc(installed->end - installed->start, sizeof(Id));
3570 FOR_REPO_SOLVABLES(installed, p, s)
3572 policy_findupdatepackages(solv, s, &q, 1);
3574 solv->weaksystemrules[p - installed->start] = pool_queuetowhatprovides(pool, &q);
3578 /* free unneeded memory */
3579 map_free(&addedmap);
3582 solv->weakrules = solv->nrules;
3584 /* try real hard to keep packages installed */
3587 FOR_REPO_SOLVABLES(installed, p, s)
3589 /* FIXME: can't work with refine_suggestion! */
3590 /* need to always add the rule but disable it */
3591 if (MAPTST(&solv->noupdate, p - installed->start))
3593 d = solv->weaksystemrules[p - installed->start];
3594 addrule(solv, p, d);
3598 /* all new rules are learnt after this point */
3599 solv->learntrules = solv->nrules;
3601 /* disable system rules that conflict with our job */
3602 disableupdaterules(solv, job, -1);
3604 /* make decisions based on job/system assertions */
3605 makeruledecisions(solv);
3607 /* create watches chains */
3610 POOL_DEBUG(SAT_DEBUG_STATS, "problems so far: %d\n", solv->problems.count);
3613 run_solver(solv, 1, 1);
3615 /* find suggested packages */
3616 if (!solv->problems.count)
3618 Id sug, *sugp, p, *pp;
3620 /* create map of all suggests that are still open */
3621 solv->recommends_index = -1;
3622 MAPZERO(&solv->suggestsmap);
3623 for (i = 0; i < solv->decisionq.count; i++)
3625 p = solv->decisionq.elements[i];
3628 s = pool->solvables + p;
3631 sugp = s->repo->idarraydata + s->suggests;
3632 while ((sug = *sugp++) != 0)
3634 FOR_PROVIDES(p, pp, sug)
3635 if (solv->decisionmap[p] > 0)
3638 continue; /* already fulfilled */
3639 FOR_PROVIDES(p, pp, sug)
3640 MAPSET(&solv->suggestsmap, p);
3644 for (i = 1; i < pool->nsolvables; i++)
3646 if (solv->decisionmap[i] != 0)
3648 s = pool->solvables + i;
3649 if (!MAPTST(&solv->suggestsmap, i))
3653 if (!pool_installable(pool, s))
3655 if (!solver_is_enhancing(solv, s))
3658 queue_push(&solv->suggestions, i);
3660 policy_filter_unwanted(solv, &solv->suggestions, 0, POLICY_MODE_SUGGEST);
3663 if (solv->problems.count)
3664 problems_to_solutions(solv, job);