2 * Copyright (c) 2007-2009, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
11 * SAT based dependency solver
26 #include "solverdebug.h"
28 #define RULES_BLOCK 63
30 static void addrpmruleinfo(Solver *solv, Id p, Id d, int type, Id dep);
32 /*-------------------------------------------------------------------
33 * Check if dependency is possible
35 * mirrors solver_dep_fulfilled but uses map m instead of the decisionmap
39 dep_possible(Solver *solv, Id dep, Map *m)
41 Pool *pool = solv->pool;
46 Reldep *rd = GETRELDEP(pool, dep);
47 if (rd->flags == REL_AND)
49 if (!dep_possible(solv, rd->name, m))
51 return dep_possible(solv, rd->evr, m);
53 if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
54 return solver_splitprovides(solv, rd->evr);
55 if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_INSTALLED)
56 return solver_dep_installed(solv, rd->evr);
58 FOR_PROVIDES(p, pp, dep)
66 /********************************************************************
70 * - unify rules, remove duplicates
73 /*-------------------------------------------------------------------
75 * compare rules for unification sort
80 unifyrules_sortcmp(const void *ap, const void *bp, void *dp)
90 return x; /* p differs */
93 if (a->d == 0 && b->d == 0)
94 return a->w2 - b->w2; /* assertion: return w2 diff */
96 if (a->d == 0) /* a is assertion, b not */
98 x = a->w2 - pool->whatprovidesdata[b->d];
102 if (b->d == 0) /* b is assertion, a not */
104 x = pool->whatprovidesdata[a->d] - b->w2;
108 /* compare whatprovidesdata */
109 ad = pool->whatprovidesdata + a->d;
110 bd = pool->whatprovidesdata + b->d;
112 if ((x = *ad++ - *bd++) != 0)
118 solver_samerule(Solver *solv, Rule *r1, Rule *r2)
120 return unifyrules_sortcmp(r1, r2, solv->pool);
124 /*-------------------------------------------------------------------
127 * go over all rules and remove duplicates
131 solver_unifyrules(Solver *solv)
133 Pool *pool = solv->pool;
137 if (solv->nrules <= 1) /* nothing to unify */
140 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- unifyrules -----\n");
142 /* sort rules first */
143 sat_sort(solv->rules + 1, solv->nrules - 1, sizeof(Rule), unifyrules_sortcmp, solv->pool);
150 for (i = j = 1, ir = solv->rules + i; i < solv->nrules; i++, ir++)
152 if (jr && !unifyrules_sortcmp(ir, jr, pool))
153 continue; /* prune! */
154 jr = solv->rules + j++; /* keep! */
159 /* reduced count from nrules to j rules */
160 POOL_DEBUG(SAT_DEBUG_STATS, "pruned rules from %d to %d\n", solv->nrules, j);
162 /* adapt rule buffer */
164 solv->rules = sat_extend_resize(solv->rules, solv->nrules, sizeof(Rule), RULES_BLOCK);
167 * debug: log rule statistics
169 IF_POOLDEBUG (SAT_DEBUG_STATS)
176 for (i = 1; i < solv->nrules; i++)
183 dp = solv->pool->whatprovidesdata + r->d;
188 POOL_DEBUG(SAT_DEBUG_STATS, " binary: %d\n", binr);
189 POOL_DEBUG(SAT_DEBUG_STATS, " normal: %d, %d literals\n", solv->nrules - 1 - binr, lits);
191 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- unifyrules end -----\n");
201 hashrule(Solver *solv, Id p, Id d, int n)
203 unsigned int x = (unsigned int)p;
207 return (x * 37) ^ (unsigned int)d;
208 dp = solv->pool->whatprovidesdata + d;
210 x = (x * 37) ^ (unsigned int)*dp++;
216 /*-------------------------------------------------------------------
222 * p = direct literal; always < 0 for installed rpm rules
223 * d, if < 0 direct literal, if > 0 offset into whatprovides, if == 0 rule is assertion (look at p only)
226 * A requires b, b provided by B1,B2,B3 => (-A|B1|B2|B3)
228 * p < 0 : pkg id of A
229 * d > 0 : Offset in whatprovidesdata (list of providers of b)
231 * A conflicts b, b provided by B1,B2,B3 => (-A|-B1), (-A|-B2), (-A|-B3)
232 * p < 0 : pkg id of A
233 * d < 0 : Id of solvable (e.g. B1)
235 * d == 0: unary rule, assertion => (A) or (-A)
237 * Install: p > 0, d = 0 (A) user requested install
238 * Remove: p < 0, d = 0 (-A) user requested remove (also: uninstallable)
239 * Requires: p < 0, d > 0 (-A|B1|B2|...) d: <list of providers for requirement of p>
240 * Updates: p > 0, d > 0 (A|B1|B2|...) d: <list of updates for solvable p>
241 * Conflicts: p < 0, d < 0 (-A|-B) either p (conflict issuer) or d (conflict provider) (binary rule)
242 * also used for obsoletes
243 * ?: p > 0, d < 0 (A|-B)
244 * No-op ?: p = 0, d = 0 (null) (used as policy rule placeholder)
248 * Direct assertion (no watch needed)( if d <0 ) --> d = 0, w1 = p, w2 = 0
249 * Binary rule: p = first literal, d = 0, w2 = second literal, w1 = p
250 * every other : w1 = p, w2 = whatprovidesdata[d];
251 * Disabled rule: w1 = 0
253 * always returns a rule for non-rpm rules
257 solver_addrule(Solver *solv, Id p, Id d)
259 Pool *pool = solv->pool;
263 int n = 0; /* number of literals in rule - 1
264 0 = direct assertion (single literal)
269 /* it often happenes that requires lead to adding the same rpm rule
270 * multiple times, so we prune those duplicates right away to make
271 * the work for unifyrules a bit easier */
273 if (solv->nrules /* we already have rules */
274 && !solv->rpmrules_end) /* but are not done with rpm rules */
276 r = solv->rules + solv->nrules - 1; /* get the last added rule */
277 if (r->p == p && r->d == d && d != 0) /* identical and not user requested */
282 * compute number of literals (n) in rule
287 /* always a binary rule */
289 return 0; /* ignore self conflict */
294 for (dp = pool->whatprovidesdata + d; *dp; dp++, n++)
296 return 0; /* rule is self-fulfilling */
298 if (n == 1) /* have single provider */
299 d = dp[-1]; /* take single literal */
302 if (n == 1 && p > d && !solv->rpmrules_end)
304 /* smallest literal first so we can find dups */
305 n = p; p = d; d = n; /* p <-> d */
306 n = 1; /* re-set n, was used as temp var */
310 * check for duplicate
313 /* check if the last added rule (r) is exactly the same as what we're looking for. */
314 if (r && n == 1 && !r->d && r->p == p && r->w2 == d)
315 return r; /* binary rule */
317 /* have n-ary rule with same first literal, check other literals */
318 if (r && n > 1 && r->d && r->p == p)
320 /* Rule where d is an offset in whatprovidesdata */
324 dp2 = pool->whatprovidesdata + r->d;
325 for (dp = pool->whatprovidesdata + d; *dp; dp++, dp2++)
336 /* extend rule buffer */
337 solv->rules = sat_extend(solv->rules, solv->nrules, 1, sizeof(Rule), RULES_BLOCK);
338 r = solv->rules + solv->nrules++; /* point to rule space */
347 /* direct assertion, no watch needed */
363 r->w2 = pool->whatprovidesdata[d];
368 IF_POOLDEBUG (SAT_DEBUG_RULE_CREATION)
370 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, " Add rule: ");
371 solver_printrule(solv, SAT_DEBUG_RULE_CREATION, r);
378 /******************************************************************************
380 *** rpm rule part: create rules representing the package dependencies
385 * special multiversion patch conflict handling:
386 * a patch conflict is also satisfied, if some other
387 * version with the same name/arch that doesn't conflict
388 * get's installed. The generated rule is thus:
389 * -patch|-cpack|opack1|opack2|...
392 makemultiversionconflict(Solver *solv, Id n, Id con)
394 Pool *pool = solv->pool;
399 sn = pool->solvables + n;
400 queue_init_buffer(&q, qbuf, sizeof(qbuf)/sizeof(*qbuf));
402 FOR_PROVIDES(p, pp, sn->name)
404 s = pool->solvables + p;
405 if (s->name != sn->name || s->arch != sn->arch)
407 if (!MAPTST(&solv->noobsoletes, p))
409 if (pool_match_nevr(pool, pool->solvables + p, con))
411 /* here we have a multiversion solvable that doesn't conflict */
412 /* thus we're not in conflict if it is installed */
416 return -n; /* no other package found, generate normal conflict */
417 return pool_queuetowhatprovides(pool, &q);
421 addrpmrule(Solver *solv, Id p, Id d, int type, Id dep)
423 if (!solv->ruleinfoq)
424 solver_addrule(solv, p, d);
426 addrpmruleinfo(solv, p, d, type, dep);
429 /*-------------------------------------------------------------------
431 * add (install) rules for solvable
433 * s: Solvable for which to add rules
434 * m: m[s] = 1 for solvables which have rules, prevent rule duplication
436 * Algorithm: 'visit all nodes of a graph'. The graph nodes are
437 * solvables, the edges their dependencies.
438 * Starting from an installed solvable, this will create all rules
439 * representing the graph created by the solvables dependencies.
441 * for unfulfilled requirements, conflicts, obsoletes,....
442 * add a negative assertion for solvables that are not installable
444 * It will also create rules for all solvables referenced by 's'
445 * i.e. descend to all providers of requirements of 's'
450 solver_addrpmrulesforsolvable(Solver *solv, Solvable *s, Map *m)
452 Pool *pool = solv->pool;
453 Repo *installed = solv->installed;
455 /* 'work' queue. keeps Ids of solvables we still have to work on.
456 And buffer for it. */
461 /* if to add rules for broken deps ('rpm -V' functionality)
465 /* Id var and pointer for each dependency
466 * (not used in parallel)
473 Id p, pp; /* whatprovides loops */
474 Id *dp; /* ptr to 'whatprovides' */
475 Id n; /* Id for current solvable 's' */
477 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforsolvable -----\n");
479 queue_init_buffer(&workq, workqbuf, sizeof(workqbuf)/sizeof(*workqbuf));
480 queue_push(&workq, s - pool->solvables); /* push solvable Id to work queue */
482 /* loop until there's no more work left */
487 * s: Pointer to solvable
490 n = queue_shift(&workq); /* 'pop' next solvable to work on from queue */
493 if (MAPTST(m, n)) /* continue if already visited */
495 MAPSET(m, n); /* mark as visited */
498 s = pool->solvables + n; /* s = Solvable in question */
501 if (installed /* Installed system available */
502 && !solv->fixsystem /* NOT repair errors in rpm dependency graph */
503 && s->repo == installed /* solvable is installed */
504 && (!solv->fixmap.size || !MAPTST(&solv->fixmap, n - installed->start)))
506 dontfix = 1; /* dont care about broken rpm deps */
510 && s->arch != ARCH_SRC
511 && s->arch != ARCH_NOSRC
512 && !pool_installable(pool, s))
514 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, "package %s [%d] is not installable\n", solvable2str(pool, s), (Id)(s - pool->solvables));
515 addrpmrule(solv, -n, 0, SOLVER_RULE_RPM_NOT_INSTALLABLE, 0);
518 /* yet another SUSE hack, sigh */
519 if (pool->nscallback && !strncmp("product:", id2str(pool, s->name), 8))
521 Id buddy = pool->nscallback(pool, pool->nscallbackdata, NAMESPACE_PRODUCTBUDDY, n);
522 if (buddy > 0 && buddy != SYSTEMSOLVABLE && buddy != n && buddy < pool->nsolvables)
524 addrpmrule(solv, n, -buddy, SOLVER_RULE_RPM_PACKAGE_REQUIRES, solvable_selfprovidedep(pool->solvables + n));
525 addrpmrule(solv, buddy, -n, SOLVER_RULE_RPM_PACKAGE_REQUIRES, solvable_selfprovidedep(pool->solvables + buddy));
526 if (m && !MAPTST(m, buddy))
527 queue_push(&workq, buddy);
531 /*-----------------------------------------
532 * check requires of s
537 reqp = s->repo->idarraydata + s->requires;
538 while ((req = *reqp++) != 0) /* go through all requires */
540 if (req == SOLVABLE_PREREQMARKER) /* skip the marker */
543 /* find list of solvables providing 'req' */
544 dp = pool_whatprovides_ptr(pool, req);
546 if (*dp == SYSTEMSOLVABLE) /* always installed */
551 /* the strategy here is to not insist on dependencies
552 * that are already broken. so if we find one provider
553 * that was already installed, we know that the
554 * dependency was not broken before so we enforce it */
556 /* check if any of the providers for 'req' is installed */
557 for (i = 0; (p = dp[i]) != 0; i++)
559 if (pool->solvables[p].repo == installed)
560 break; /* provider was installed */
562 /* didn't find an installed provider: previously broken dependency */
565 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, "ignoring broken requires %s of installed package %s\n", dep2str(pool, req), solvable2str(pool, s));
572 /* nothing provides req! */
573 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, "package %s [%d] is not installable (%s)\n", solvable2str(pool, s), (Id)(s - pool->solvables), dep2str(pool, req));
574 addrpmrule(solv, -n, 0, SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP, req);
578 IF_POOLDEBUG (SAT_DEBUG_RULE_CREATION)
580 POOL_DEBUG(SAT_DEBUG_RULE_CREATION," %s requires %s\n", solvable2str(pool, s), dep2str(pool, req));
581 for (i = 0; dp[i]; i++)
582 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, " provided by %s\n", solvid2str(pool, dp[i]));
585 /* add 'requires' dependency */
586 /* rule: (-requestor|provider1|provider2|...|providerN) */
587 addrpmrule(solv, -n, dp - pool->whatprovidesdata, SOLVER_RULE_RPM_PACKAGE_REQUIRES, req);
589 /* descend the dependency tree
590 push all non-visited providers on the work queue */
596 queue_push(&workq, *dp);
600 } /* while, requirements of n */
602 } /* if, requirements */
604 /* that's all we check for src packages */
605 if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
608 /*-----------------------------------------
609 * check conflicts of s
616 /* we treat conflicts in patches a bit differen:
618 * - multiversion handling
619 * XXX: we should really handle this different, looking
620 * at the name is a bad hack
622 if (!strncmp("patch:", id2str(pool, s->name), 6))
624 conp = s->repo->idarraydata + s->conflicts;
625 /* foreach conflicts of 's' */
626 while ((con = *conp++) != 0)
628 /* foreach providers of a conflict of 's' */
629 FOR_PROVIDES(p, pp, con)
631 if (ispatch && !pool_match_nevr(pool, pool->solvables + p, con))
633 /* dontfix: dont care about conflicts with already installed packs */
634 if (dontfix && pool->solvables[p].repo == installed)
636 /* p == n: self conflict */
637 if (p == n && !pool->allowselfconflicts)
641 Reldep *rd = GETRELDEP(pool, con);
642 if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_OTHERPROVIDERS)
645 p = 0; /* make it a negative assertion, aka 'uninstallable' */
647 if (p && ispatch && solv->noobsoletes.size && MAPTST(&solv->noobsoletes, p) && ISRELDEP(con))
649 /* our patch conflicts with a noobsoletes (aka multiversion) package */
650 p = -makemultiversionconflict(solv, p, con);
652 /* rule: -n|-p: either solvable _or_ provider of conflict */
653 addrpmrule(solv, -n, -p, p ? SOLVER_RULE_RPM_PACKAGE_CONFLICT : SOLVER_RULE_RPM_SELF_CONFLICT, con);
658 /*-----------------------------------------
659 * check obsoletes if not installed
660 * (only installation will trigger the obsoletes in rpm)
662 if (!installed || pool->solvables[n].repo != installed)
663 { /* not installed */
664 int noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, n);
665 if (s->obsoletes && !noobs)
667 obsp = s->repo->idarraydata + s->obsoletes;
668 /* foreach obsoletes */
669 while ((obs = *obsp++) != 0)
671 /* foreach provider of an obsoletes of 's' */
672 FOR_PROVIDES(p, pp, obs)
674 Solvable *ps = pool->solvables + p;
675 if (!pool->obsoleteusesprovides /* obsoletes are matched names, not provides */
676 && !pool_match_nevr(pool, ps, obs))
678 if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
680 addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_PACKAGE_OBSOLETES, obs);
684 FOR_PROVIDES(p, pp, s->name)
686 Solvable *ps = pool->solvables + p;
687 /* we still obsolete packages with same nevra, like rpm does */
688 /* (actually, rpm mixes those packages. yuck...) */
689 if (noobs && (s->name != ps->name || s->evr != ps->evr || s->arch != ps->arch))
691 if (!pool->implicitobsoleteusesprovides && s->name != ps->name)
693 if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
695 if (s->name == ps->name)
696 addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_SAME_NAME, 0);
698 addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_IMPLICIT_OBSOLETES, s->name);
702 /*-----------------------------------------
703 * add recommends to the work queue
705 if (s->recommends && m)
707 recp = s->repo->idarraydata + s->recommends;
708 while ((rec = *recp++) != 0)
710 FOR_PROVIDES(p, pp, rec)
712 queue_push(&workq, p);
715 if (s->suggests && m)
717 sugp = s->repo->idarraydata + s->suggests;
718 while ((sug = *sugp++) != 0)
720 FOR_PROVIDES(p, pp, sug)
722 queue_push(&workq, p);
727 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforsolvable end -----\n");
731 /*-------------------------------------------------------------------
733 * Add package rules for weak rules
735 * m: visited solvables
739 solver_addrpmrulesforweak(Solver *solv, Map *m)
741 Pool *pool = solv->pool;
746 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforweak -----\n");
747 /* foreach solvable in pool */
748 for (i = n = 1; n < pool->nsolvables; i++, n++)
750 if (i == pool->nsolvables) /* wrap i */
752 if (MAPTST(m, i)) /* been there */
755 s = pool->solvables + i;
756 if (!pool_installable(pool, s)) /* only look at installable ones */
762 /* find possible supplements */
763 supp = s->repo->idarraydata + s->supplements;
764 while ((sup = *supp++) != ID_NULL)
765 if (dep_possible(solv, sup, m))
769 /* if nothing found, check for enhances */
770 if (!sup && s->enhances)
772 supp = s->repo->idarraydata + s->enhances;
773 while ((sup = *supp++) != ID_NULL)
774 if (dep_possible(solv, sup, m))
777 /* if nothing found, goto next solvables */
780 solver_addrpmrulesforsolvable(solv, s, m);
781 n = 0; /* check all solvables again */
783 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforweak end -----\n");
787 /*-------------------------------------------------------------------
789 * add package rules for possible updates
792 * m: map of already visited solvables
793 * allow_all: 0 = dont allow downgrades, 1 = allow all candidates
797 solver_addrpmrulesforupdaters(Solver *solv, Solvable *s, Map *m, int allow_all)
799 Pool *pool = solv->pool;
801 /* queue and buffer for it */
805 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforupdaters -----\n");
807 queue_init_buffer(&qs, qsbuf, sizeof(qsbuf)/sizeof(*qsbuf));
808 /* find update candidates for 's' */
809 policy_findupdatepackages(solv, s, &qs, allow_all);
810 /* add rule for 's' if not already done */
811 if (!MAPTST(m, s - pool->solvables))
812 solver_addrpmrulesforsolvable(solv, s, m);
813 /* foreach update candidate, add rule if not already done */
814 for (i = 0; i < qs.count; i++)
815 if (!MAPTST(m, qs.elements[i]))
816 solver_addrpmrulesforsolvable(solv, pool->solvables + qs.elements[i], m);
819 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforupdaters -----\n");
823 /***********************************************************************
825 *** Update/Feature rule part
827 *** Those rules make sure an installed package isn't silently deleted
832 finddistupgradepackages(Solver *solv, Solvable *s, Queue *qs, int allow_all)
834 Pool *pool = solv->pool;
837 policy_findupdatepackages(solv, s, qs, allow_all);
841 return 0; /* orphaned, don't create feature rule */
842 /* check if this is an orphaned package */
843 policy_findupdatepackages(solv, s, qs, 1);
845 return 0; /* orphaned, don't create update rule */
847 return -SYSTEMSOLVABLE; /* supported but not installable */
850 return s - pool->solvables;
851 /* check if it is ok to keep the installed package */
852 for (i = 0; i < qs->count; i++)
854 Solvable *ns = pool->solvables + qs->elements[i];
855 if (s->evr == ns->evr && solvable_identical(s, ns))
856 return s - pool->solvables;
858 /* nope, it must be some other package */
859 return -SYSTEMSOLVABLE;
862 /* add packages from the dup repositories to the update candidates
863 * this isn't needed for the global dup mode as all packages are
864 * from dup repos in that case */
866 addduppackages(Solver *solv, Solvable *s, Queue *qs)
871 int oldnoupdateprovide = solv->noupdateprovide;
873 queue_init_buffer(&dupqs, dupqsbuf, sizeof(dupqsbuf)/sizeof(*dupqsbuf));
874 solv->noupdateprovide = 1;
875 policy_findupdatepackages(solv, s, &dupqs, 2);
876 solv->noupdateprovide = oldnoupdateprovide;
877 for (i = 0; i < dupqs.count; i++)
879 p = dupqs.elements[i];
880 if (MAPTST(&solv->dupmap, p))
881 queue_pushunique(qs, p);
886 /*-------------------------------------------------------------------
888 * add rule for update
889 * (A|A1|A2|A3...) An = update candidates for A
891 * s = (installed) solvable
895 solver_addupdaterule(Solver *solv, Solvable *s, int allow_all)
897 /* installed packages get a special upgrade allowed rule */
898 Pool *pool = solv->pool;
903 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addupdaterule -----\n");
904 queue_init_buffer(&qs, qsbuf, sizeof(qsbuf)/sizeof(*qsbuf));
905 p = s - pool->solvables;
906 /* find update candidates for 's' */
907 if (solv->distupgrade)
908 p = finddistupgradepackages(solv, s, &qs, allow_all);
910 policy_findupdatepackages(solv, s, &qs, allow_all);
911 if (!allow_all && !solv->distupgrade && solv->dupinvolvedmap.size && MAPTST(&solv->dupinvolvedmap, p))
912 addduppackages(solv, s, &qs);
914 if (!allow_all && qs.count && solv->noobsoletes.size)
918 d = pool_queuetowhatprovides(pool, &qs);
919 /* filter out all noobsoletes packages as they don't update */
920 for (i = j = 0; i < qs.count; i++)
922 if (MAPTST(&solv->noobsoletes, qs.elements[i]))
924 /* it's ok if they have same nevra */
925 Solvable *ps = pool->solvables + qs.elements[i];
926 if (ps->name != s->name || ps->evr != s->evr || ps->arch != s->arch)
929 qs.elements[j++] = qs.elements[i];
931 if (j == 0 && p == -SYSTEMSOLVABLE && solv->distupgrade)
933 queue_push(&solv->orphaned, s - pool->solvables); /* treat as orphaned */
938 if (d && solv->updatesystem && solv->installed && s->repo == solv->installed)
940 if (!solv->multiversionupdaters)
941 solv->multiversionupdaters = sat_calloc(solv->installed->end - solv->installed->start, sizeof(Id));
942 solv->multiversionupdaters[s - pool->solvables - solv->installed->start] = d;
947 if (qs.count && p == -SYSTEMSOLVABLE)
948 p = queue_shift(&qs);
949 d = qs.count ? pool_queuetowhatprovides(pool, &qs) : 0;
951 solver_addrule(solv, p, d); /* allow update of s */
952 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addupdaterule end -----\n");
956 disableupdaterule(Solver *solv, Id p)
960 MAPSET(&solv->noupdate, p - solv->installed->start);
961 r = solv->rules + solv->updaterules + (p - solv->installed->start);
962 if (r->p && r->d >= 0)
963 solver_disablerule(solv, r);
964 r = solv->rules + solv->featurerules + (p - solv->installed->start);
965 if (r->p && r->d >= 0)
966 solver_disablerule(solv, r);
970 reenableupdaterule(Solver *solv, Id p)
972 Pool *pool = solv->pool;
975 MAPCLR(&solv->noupdate, p - solv->installed->start);
976 r = solv->rules + solv->updaterules + (p - solv->installed->start);
981 solver_enablerule(solv, r);
982 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
984 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "@@@ re-enabling ");
985 solver_printruleclass(solv, SAT_DEBUG_SOLUTIONS, r);
989 r = solv->rules + solv->featurerules + (p - solv->installed->start);
990 if (r->p && r->d < 0)
992 solver_enablerule(solv, r);
993 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
995 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "@@@ re-enabling ");
996 solver_printruleclass(solv, SAT_DEBUG_SOLUTIONS, r);
1002 /***********************************************************************
1004 *** Infarch rule part
1006 *** Infarch rules make sure the solver uses the best architecture of
1007 *** a package if multiple archetectures are available
1012 solver_addinfarchrules(Solver *solv, Map *addedmap)
1014 Pool *pool = solv->pool;
1016 Id p, pp, a, aa, bestarch;
1017 Solvable *s, *ps, *bests;
1018 Queue badq, allowedarchs;
1021 queue_init(&allowedarchs);
1022 solv->infarchrules = solv->nrules;
1023 for (i = 1; i < pool->nsolvables; i++)
1025 if (i == SYSTEMSOLVABLE || !MAPTST(addedmap, i))
1027 s = pool->solvables + i;
1031 queue_empty(&allowedarchs);
1032 FOR_PROVIDES(p, pp, s->name)
1034 ps = pool->solvables + p;
1035 if (ps->name != s->name || !MAPTST(addedmap, p))
1042 a = (a <= pool->lastarch) ? pool->id2arch[a] : 0;
1043 if (a != 1 && pool->installed && ps->repo == pool->installed)
1045 if (!solv->distupgrade)
1046 queue_pushunique(&allowedarchs, ps->arch); /* also ok to keep this architecture */
1047 continue; /* ignore installed solvables when calculating the best arch */
1049 if (a && a != 1 && (!bestarch || a < bestarch))
1057 /* speed up common case where installed package already has best arch */
1058 if (allowedarchs.count == 1 && bests && allowedarchs.elements[0] == bests->arch)
1059 allowedarchs.count--; /* installed arch is best */
1061 FOR_PROVIDES(p, pp, s->name)
1063 ps = pool->solvables + p;
1064 if (ps->name != s->name || !MAPTST(addedmap, p))
1067 a = (a <= pool->lastarch) ? pool->id2arch[a] : 0;
1068 if (a != 1 && bestarch && ((a ^ bestarch) & 0xffff0000) != 0)
1070 if (pool->installed && ps->repo == pool->installed)
1071 continue; /* always ok to keep an installed package */
1072 for (j = 0; j < allowedarchs.count; j++)
1074 aa = allowedarchs.elements[j];
1077 aa = (aa <= pool->lastarch) ? pool->id2arch[aa] : 0;
1078 if (aa && ((a ^ aa) & 0xffff0000) == 0)
1079 break; /* compatible */
1081 if (j == allowedarchs.count)
1082 queue_push(&badq, p);
1087 /* block all solvables in the badq! */
1088 for (j = 0; j < badq.count; j++)
1090 p = badq.elements[j];
1091 solver_addrule(solv, -p, 0);
1095 queue_free(&allowedarchs);
1096 solv->infarchrules_end = solv->nrules;
1100 disableinfarchrule(Solver *solv, Id name)
1102 Pool *pool = solv->pool;
1105 for (i = solv->infarchrules, r = solv->rules + i; i < solv->infarchrules_end; i++, r++)
1107 if (r->p < 0 && r->d >= 0 && pool->solvables[-r->p].name == name)
1108 solver_disablerule(solv, r);
1113 reenableinfarchrule(Solver *solv, Id name)
1115 Pool *pool = solv->pool;
1118 for (i = solv->infarchrules, r = solv->rules + i; i < solv->infarchrules_end; i++, r++)
1120 if (r->p < 0 && r->d < 0 && pool->solvables[-r->p].name == name)
1122 solver_enablerule(solv, r);
1123 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
1125 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "@@@ re-enabling ");
1126 solver_printruleclass(solv, SAT_DEBUG_SOLUTIONS, r);
1133 /***********************************************************************
1137 *** Dup rules make sure a package is selected from the specified dup
1138 *** repositories if an update candidate is included in one of them.
1143 solver_createdupmaps(Solver *solv)
1145 Queue *job = &solv->job;
1146 Pool *pool = solv->pool;
1148 Id how, what, p, pi, pp, obs, *obsp;
1152 map_init(&solv->dupmap, pool->nsolvables);
1153 map_init(&solv->dupinvolvedmap, pool->nsolvables);
1154 for (i = 0; i < job->count; i += 2)
1156 how = job->elements[i];
1157 what = job->elements[i + 1];
1158 switch (how & SOLVER_JOBMASK)
1160 case SOLVER_DISTUPGRADE:
1161 if ((how & SOLVER_SELECTMASK) != SOLVER_SOLVABLE_REPO)
1163 if (what <= 0 || what > pool->nrepos)
1165 repo = pool_id2repo(pool, what);
1166 FOR_REPO_SOLVABLES(repo, p, s)
1168 MAPSET(&solv->dupmap, p);
1169 FOR_PROVIDES(pi, pp, s->name)
1171 ps = pool->solvables + pi;
1172 if (ps->name != s->name)
1174 MAPSET(&solv->dupinvolvedmap, pi);
1178 /* FIXME: check obsoletes/provides combination */
1179 obsp = s->repo->idarraydata + s->obsoletes;
1180 while ((obs = *obsp++) != 0)
1182 FOR_PROVIDES(pi, pp, obs)
1184 Solvable *pis = pool->solvables + pi;
1185 if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, pis, obs))
1187 if (pool->obsoleteusescolors && !pool_colormatch(pool, s, pis))
1189 MAPSET(&solv->dupinvolvedmap, pi);
1199 MAPCLR(&solv->dupinvolvedmap, SYSTEMSOLVABLE);
1203 solver_freedupmaps(Solver *solv)
1205 map_free(&solv->dupmap);
1206 map_free(&solv->dupinvolvedmap);
1210 solver_addduprules(Solver *solv, Map *addedmap)
1212 Pool *pool = solv->pool;
1217 solv->duprules = solv->nrules;
1218 for (i = 1; i < pool->nsolvables; i++)
1220 if (i == SYSTEMSOLVABLE || !MAPTST(addedmap, i))
1222 s = pool->solvables + i;
1224 FOR_PROVIDES(p, pp, s->name)
1226 ps = pool->solvables + p;
1227 if (ps->name != s->name || !MAPTST(addedmap, p))
1233 if (!MAPTST(&solv->dupinvolvedmap, p))
1235 if (solv->installed && ps->repo == solv->installed)
1237 if (!solv->updatemap.size)
1238 map_grow(&solv->updatemap, solv->installed->end - solv->installed->start);
1239 MAPSET(&solv->updatemap, p - solv->installed->start);
1240 if (!MAPTST(&solv->dupmap, p))
1243 /* is installed identical to a good one? */
1244 FOR_PROVIDES(ip, ipp, s->name)
1246 Solvable *is = pool->solvables + ip;
1247 if (!MAPTST(&solv->dupmap, ip))
1249 if (is->evr == s->evr && solvable_identical(s, is))
1253 solver_addrule(solv, -p, 0); /* no match, sorry */
1256 else if (!MAPTST(&solv->dupmap, p))
1257 solver_addrule(solv, -p, 0);
1260 solv->duprules_end = solv->nrules;
1265 disableduprule(Solver *solv, Id name)
1267 Pool *pool = solv->pool;
1270 for (i = solv->duprules, r = solv->rules + i; i < solv->duprules_end; i++, r++)
1272 if (r->p < 0 && r->d >= 0 && pool->solvables[-r->p].name == name)
1273 solver_disablerule(solv, r);
1278 reenableduprule(Solver *solv, Id name)
1280 Pool *pool = solv->pool;
1283 for (i = solv->duprules, r = solv->rules + i; i < solv->duprules_end; i++, r++)
1285 if (r->p < 0 && r->d < 0 && pool->solvables[-r->p].name == name)
1287 solver_enablerule(solv, r);
1288 IF_POOLDEBUG (SAT_DEBUG_SOLUTIONS)
1290 POOL_DEBUG(SAT_DEBUG_SOLUTIONS, "@@@ re-enabling ");
1291 solver_printruleclass(solv, SAT_DEBUG_SOLUTIONS, r);
1298 /***********************************************************************
1300 *** Policy rule disabling/reenabling
1302 *** Disable all policy rules that conflict with our jobs. If a job
1303 *** gets disabled later on, reenable the involved policy rules again.
1307 #define DISABLE_UPDATE 1
1308 #define DISABLE_INFARCH 2
1309 #define DISABLE_DUP 3
1312 jobtodisablelist(Solver *solv, Id how, Id what, Queue *q)
1314 Pool *pool = solv->pool;
1320 installed = solv->installed;
1321 select = how & SOLVER_SELECTMASK;
1322 switch (how & SOLVER_JOBMASK)
1324 case SOLVER_INSTALL:
1325 if ((select == SOLVER_SOLVABLE_NAME || select == SOLVER_SOLVABLE_PROVIDES) && solv->infarchrules != solv->infarchrules_end && ISRELDEP(what))
1327 Reldep *rd = GETRELDEP(pool, what);
1328 if (rd->flags == REL_ARCH)
1330 int qcnt = q->count;
1331 FOR_JOB_SELECT(p, pp, select, what)
1333 s = pool->solvables + p;
1335 for (i = qcnt; i < q->count; i += 2)
1336 if (q->elements[i + 1] == s->name)
1340 queue_push(q, DISABLE_INFARCH);
1341 queue_push(q, s->name);
1345 if (select != SOLVER_SOLVABLE)
1347 s = pool->solvables + what;
1348 if (solv->infarchrules != solv->infarchrules_end)
1350 queue_push(q, DISABLE_INFARCH);
1351 queue_push(q, s->name);
1353 if (solv->duprules != solv->duprules_end)
1355 queue_push(q, DISABLE_DUP);
1356 queue_push(q, s->name);
1360 if (solv->noobsoletes.size && MAPTST(&solv->noobsoletes, what))
1362 if (s->repo == installed)
1364 queue_push(q, DISABLE_UPDATE);
1365 queue_push(q, what);
1371 obsp = s->repo->idarraydata + s->obsoletes;
1372 while ((obs = *obsp++) != 0)
1373 FOR_PROVIDES(p, pp, obs)
1375 Solvable *ps = pool->solvables + p;
1376 if (ps->repo != installed)
1378 if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs))
1380 if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
1382 queue_push(q, DISABLE_UPDATE);
1386 FOR_PROVIDES(p, pp, s->name)
1388 Solvable *ps = pool->solvables + p;
1389 if (ps->repo != installed)
1391 if (!pool->implicitobsoleteusesprovides && ps->name != s->name)
1393 if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
1395 queue_push(q, DISABLE_UPDATE);
1402 FOR_JOB_SELECT(p, pp, select, what)
1403 if (pool->solvables[p].repo == installed)
1405 queue_push(q, DISABLE_UPDATE);
1414 /* disable all policy rules that are in conflict with our job list */
1416 solver_disablepolicyrules(Solver *solv)
1418 Queue *job = &solv->job;
1425 queue_init_buffer(&allq, allqbuf, sizeof(allqbuf)/sizeof(*allqbuf));
1427 for (i = solv->jobrules; i < solv->jobrules_end; i++)
1429 r = solv->rules + i;
1430 if (r->d < 0) /* disabled? */
1432 j = solv->ruletojob.elements[i - solv->jobrules];
1436 jobtodisablelist(solv, job->elements[j], job->elements[j + 1], &allq);
1438 MAPZERO(&solv->noupdate);
1439 for (i = 0; i < allq.count; i += 2)
1441 Id type = allq.elements[i], arg = allq.elements[i + 1];
1444 case DISABLE_UPDATE:
1445 disableupdaterule(solv, arg);
1447 case DISABLE_INFARCH:
1448 disableinfarchrule(solv, arg);
1451 disableduprule(solv, arg);
1460 /* we just disabled job #jobidx, now reenable all policy rules that were
1461 * disabled because of this job */
1463 solver_reenablepolicyrules(Solver *solv, int jobidx)
1465 Queue *job = &solv->job;
1470 Id qbuf[32], allqbuf[128];
1472 queue_init_buffer(&q, qbuf, sizeof(qbuf)/sizeof(*qbuf));
1473 queue_init_buffer(&allq, allqbuf, sizeof(allqbuf)/sizeof(*allqbuf));
1474 jobtodisablelist(solv, job->elements[jobidx], job->elements[jobidx + 1], &q);
1477 for (i = solv->jobrules; i < solv->jobrules_end; i++)
1479 r = solv->rules + i;
1480 if (r->d < 0) /* disabled? */
1482 j = solv->ruletojob.elements[i - solv->jobrules];
1486 jobtodisablelist(solv, job->elements[j], job->elements[j + 1], &allq);
1488 for (j = 0; j < q.count; j += 2)
1490 Id type = q.elements[j], arg = q.elements[j + 1];
1491 for (i = 0; i < allq.count; i += 2)
1492 if (allq.elements[i] == type && allq.elements[i + 1] == arg)
1495 continue; /* still disabled */
1498 case DISABLE_UPDATE:
1499 reenableupdaterule(solv, arg);
1501 case DISABLE_INFARCH:
1502 reenableinfarchrule(solv, arg);
1505 reenableduprule(solv, arg);
1514 /***********************************************************************
1516 *** Rule info part, tell the user what the rule is about.
1521 addrpmruleinfo(Solver *solv, Id p, Id d, int type, Id dep)
1523 Pool *pool = solv->pool;
1527 /* check if this creates the rule we're searching for */
1528 r = solv->rules + solv->ruleinfoq->elements[0];
1530 od = r->d < 0 ? -r->d - 1 : r->d;
1535 if (p < 0 && d > 0 && (!pool->whatprovidesdata[d] || !pool->whatprovidesdata[d + 1]))
1537 w2 = pool->whatprovidesdata[d];
1541 if (p > 0 && d < 0) /* this hack is used for buddy deps */
1553 Id *dp = pool->whatprovidesdata + d;
1554 Id *odp = pool->whatprovidesdata + od;
1556 if (*dp++ != *odp++)
1562 /* handle multiversion conflict rules */
1563 if (p < 0 && pool->whatprovidesdata[d] < 0)
1565 w2 = pool->whatprovidesdata[d];
1566 /* XXX: free memory */
1576 if (w2 != op || p != ow2)
1581 if (p != op || w2 != ow2)
1585 /* yep, rule matches. record info */
1586 queue_push(solv->ruleinfoq, type);
1587 if (type == SOLVER_RULE_RPM_SAME_NAME)
1589 /* we normalize same name order */
1590 queue_push(solv->ruleinfoq, op < 0 ? -op : 0);
1591 queue_push(solv->ruleinfoq, ow2 < 0 ? -ow2 : 0);
1595 queue_push(solv->ruleinfoq, p < 0 ? -p : 0);
1596 queue_push(solv->ruleinfoq, w2 < 0 ? -w2 : 0);
1598 queue_push(solv->ruleinfoq, dep);
1602 solver_allruleinfos_cmp(const void *ap, const void *bp, void *dp)
1604 const Id *a = ap, *b = bp;
1623 solver_allruleinfos(Solver *solv, Id rid, Queue *rq)
1625 Pool *pool = solv->pool;
1626 Rule *r = solv->rules + rid;
1630 if (rid <= 0 || rid >= solv->rpmrules_end)
1632 Id type, from, to, dep;
1633 type = solver_ruleinfo(solv, rid, &from, &to, &dep);
1634 queue_push(rq, type);
1635 queue_push(rq, from);
1637 queue_push(rq, dep);
1642 queue_push(rq, rid);
1643 solv->ruleinfoq = rq;
1644 solver_addrpmrulesforsolvable(solv, pool->solvables - r->p, 0);
1645 /* also try reverse direction for conflicts */
1646 if ((r->d == 0 || r->d == -1) && r->w2 < 0)
1647 solver_addrpmrulesforsolvable(solv, pool->solvables - r->w2, 0);
1648 solv->ruleinfoq = 0;
1650 /* now sort & unify em */
1653 sat_sort(rq->elements, rq->count / 4, 4 * sizeof(Id), solver_allruleinfos_cmp, 0);
1654 /* throw out identical entries */
1655 for (i = j = 0; i < rq->count; i += 4)
1659 if (rq->elements[i] == rq->elements[j - 4] &&
1660 rq->elements[i + 1] == rq->elements[j - 3] &&
1661 rq->elements[i + 2] == rq->elements[j - 2] &&
1662 rq->elements[i + 3] == rq->elements[j - 1])
1665 rq->elements[j++] = rq->elements[i];
1666 rq->elements[j++] = rq->elements[i + 1];
1667 rq->elements[j++] = rq->elements[i + 2];
1668 rq->elements[j++] = rq->elements[i + 3];
1675 solver_ruleinfo(Solver *solv, Id rid, Id *fromp, Id *top, Id *depp)
1677 Pool *pool = solv->pool;
1678 Rule *r = solv->rules + rid;
1679 SolverRuleinfo type = SOLVER_RULE_UNKNOWN;
1687 if (rid > 0 && rid < solv->rpmrules_end)
1693 return SOLVER_RULE_RPM;
1697 queue_push(&rq, rid);
1698 solv->ruleinfoq = &rq;
1699 solver_addrpmrulesforsolvable(solv, pool->solvables - r->p, 0);
1700 /* also try reverse direction for conflicts */
1701 if ((r->d == 0 || r->d == -1) && r->w2 < 0)
1702 solver_addrpmrulesforsolvable(solv, pool->solvables - r->w2, 0);
1703 solv->ruleinfoq = 0;
1704 type = SOLVER_RULE_RPM;
1705 for (i = 1; i < rq.count; i += 4)
1708 qt = rq.elements[i];
1709 qp = rq.elements[i + 1];
1710 qo = rq.elements[i + 2];
1711 qd = rq.elements[i + 3];
1712 if (type == SOLVER_RULE_RPM || type > qt)
1726 if (rid >= solv->jobrules && rid < solv->jobrules_end)
1728 Id jidx = solv->ruletojob.elements[rid - solv->jobrules];
1732 *top = solv->job.elements[jidx];
1734 *depp = solv->job.elements[jidx + 1];
1735 if ((r->d == 0 || r->d == -1) && r->w2 == 0 && r->p == -SYSTEMSOLVABLE && (solv->job.elements[jidx] & SOLVER_SELECTMASK) != SOLVER_SOLVABLE_ONE_OF)
1736 return SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
1737 return SOLVER_RULE_JOB;
1739 if (rid >= solv->updaterules && rid < solv->updaterules_end)
1742 *fromp = solv->installed->start + (rid - solv->updaterules);
1743 return SOLVER_RULE_UPDATE;
1745 if (rid >= solv->featurerules && rid < solv->featurerules_end)
1748 *fromp = solv->installed->start + (rid - solv->featurerules);
1749 return SOLVER_RULE_FEATURE;
1751 if (rid >= solv->duprules && rid < solv->duprules_end)
1756 *depp = pool->solvables[-r->p].name;
1757 return SOLVER_RULE_DISTUPGRADE;
1759 if (rid >= solv->infarchrules && rid < solv->infarchrules_end)
1764 *depp = pool->solvables[-r->p].name;
1765 return SOLVER_RULE_INFARCH;
1767 if (rid >= solv->choicerules && rid < solv->choicerules_end)
1769 return SOLVER_RULE_CHOICE;
1771 if (rid >= solv->learntrules)
1773 return SOLVER_RULE_LEARNT;
1775 return SOLVER_RULE_UNKNOWN;
1779 addchoicerules(Solver *solv)
1781 Pool *pool = solv->pool;
1785 int i, j, rid, havechoice;
1790 solv->choicerules = solv->nrules;
1791 if (!pool->installed)
1793 solv->choicerules_end = solv->nrules;
1796 solv->choicerules_ref = sat_calloc(solv->rpmrules_end, sizeof(Id));
1799 map_init(&m, pool->nsolvables);
1800 for (rid = 1; rid < solv->rpmrules_end ; rid++)
1802 r = solv->rules + rid;
1803 if (r->p >= 0 || ((r->d == 0 || r->d == -1) && r->w2 < 0))
1804 continue; /* only look at requires rules */
1805 // solver_printrule(solv, SAT_DEBUG_RESULT, r);
1809 FOR_RULELITERALS(p, pp, r)
1813 s = pool->solvables + p;
1816 if (s->repo == pool->installed)
1821 /* check if this package is "blocked" by a installed package */
1823 FOR_PROVIDES(p2, pp2, s->name)
1825 s2 = pool->solvables + p2;
1826 if (s2->repo != pool->installed)
1828 if (!pool->implicitobsoleteusesprovides && s->name != s2->name)
1830 if (pool->obsoleteusescolors && !pool_colormatch(pool, s, s2))
1836 /* found installed package */
1837 if (!solv->allowarchchange && s->arch != s2->arch && policy_illegal_archchange(solv, s, s2))
1839 if (!solv->allowvendorchange && s->vendor != s2->vendor && policy_illegal_vendorchange(solv, s, s2))
1841 queue_push(&qi, p2);
1847 Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
1849 while ((obs = *obsp++) != 0)
1851 FOR_PROVIDES(p2, pp2, obs)
1853 s2 = pool->solvables + p2;
1854 if (s2->repo != pool->installed)
1856 if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, pool->solvables + p2, obs))
1858 if (pool->obsoleteusescolors && !pool_colormatch(pool, s, s2))
1868 if (!solv->allowarchchange && s->arch != s2->arch && policy_illegal_archchange(solv, s, s2))
1870 if (!solv->allowvendorchange && s->vendor != s2->vendor && policy_illegal_vendorchange(solv, s, s2))
1872 queue_push(&qi, p2);
1877 /* this package is independent if the installed ones */
1880 if (!havechoice || !q.count)
1881 continue; /* no choice */
1883 /* now check the update rules of the installed package.
1884 * if all packages of the update rules are contained in
1885 * the dependency rules, there's no need to set up the choice rule */
1887 FOR_RULELITERALS(p, pp, r)
1890 for (i = 0; i < qi.count; i++)
1892 if (!qi.elements[i])
1894 Rule *ur = solv->rules + solv->updaterules + (qi.elements[i] - pool->installed->start);
1896 ur = solv->rules + solv->featurerules + (qi.elements[i] - pool->installed->start);
1899 FOR_RULELITERALS(p, pp, ur)
1904 for (j = i + 1; j < qi.count; j++)
1905 if (qi.elements[i] == qi.elements[j])
1911 printf("skipping choice ");
1912 solver_printrule(solv, SAT_DEBUG_RESULT, solv->rules + rid);
1916 d = q.count ? pool_queuetowhatprovides(pool, &q) : 0;
1917 solver_addrule(solv, r->p, d);
1918 queue_push(&solv->weakruleq, solv->nrules - 1);
1919 solv->choicerules_ref[solv->nrules - 1 - solv->choicerules] = rid;
1922 solver_printrule(solv, SAT_DEBUG_RESULT, solv->rules + rid);
1923 printf("WEAK CHOICE ");
1924 solver_printrule(solv, SAT_DEBUG_RESULT, solv->rules + solv->nrules - 1);
1930 solv->choicerules_end = solv->nrules;
1933 /* called when a choice rule is disabled by analyze_unsolvable. We also
1934 * have to disable all other choice rules so that the best packages get
1938 disablechoicerules(Solver *solv, Rule *r)
1941 Pool *pool = solv->pool;
1945 or = solv->rules + solv->choicerules_ref[(r - solv->rules) - solv->choicerules];
1946 map_init(&m, pool->nsolvables);
1947 FOR_RULELITERALS(p, pp, or)
1950 FOR_RULELITERALS(p, pp, r)
1953 for (rid = solv->choicerules; rid < solv->choicerules_end; rid++)
1955 r = solv->rules + rid;
1958 or = solv->rules + solv->choicerules_ref[(r - solv->rules) - solv->choicerules];
1959 FOR_RULELITERALS(p, pp, or)
1960 if (p > 0 && MAPTST(&m, p))
1963 solver_disablerule(solv, r);