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
25 #include "solverdebug.h"
27 #define RULES_BLOCK 63
29 static void addrpmruleinfo(Solver *solv, Id p, Id d, int type, Id dep);
31 /*-------------------------------------------------------------------
32 * Check if dependency is possible
34 * this mirrors solver_dep_fulfilled
35 * 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);
168 IF_POOLDEBUG (SAT_DEBUG_STATS)
175 for (i = 1; i < solv->nrules; i++)
182 dp = solv->pool->whatprovidesdata + r->d;
187 POOL_DEBUG(SAT_DEBUG_STATS, " binary: %d\n", binr);
188 POOL_DEBUG(SAT_DEBUG_STATS, " normal: %d, %d literals\n", solv->nrules - 1 - binr, lits);
190 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- unifyrules end -----\n");
200 hashrule(Solver *solv, Id p, Id d, int n)
202 unsigned int x = (unsigned int)p;
206 return (x * 37) ^ (unsigned int)d;
207 dp = solv->pool->whatprovidesdata + d;
209 x = (x * 37) ^ (unsigned int)*dp++;
215 /*-------------------------------------------------------------------
221 * p = direct literal; always < 0 for installed rpm rules
222 * d, if < 0 direct literal, if > 0 offset into whatprovides, if == 0 rule is assertion (look at p only)
225 * A requires b, b provided by B1,B2,B3 => (-A|B1|B2|B3)
227 * p < 0 : pkg id of A
228 * d > 0 : Offset in whatprovidesdata (list of providers of b)
230 * A conflicts b, b provided by B1,B2,B3 => (-A|-B1), (-A|-B2), (-A|-B3)
231 * p < 0 : pkg id of A
232 * d < 0 : Id of solvable (e.g. B1)
234 * d == 0: unary rule, assertion => (A) or (-A)
236 * Install: p > 0, d = 0 (A) user requested install
237 * Remove: p < 0, d = 0 (-A) user requested remove (also: uninstallable)
238 * Requires: p < 0, d > 0 (-A|B1|B2|...) d: <list of providers for requirement of p>
239 * Updates: p > 0, d > 0 (A|B1|B2|...) d: <list of updates for solvable p>
240 * Conflicts: p < 0, d < 0 (-A|-B) either p (conflict issuer) or d (conflict provider) (binary rule)
241 * also used for obsoletes
242 * ?: p > 0, d < 0 (A|-B)
243 * No-op ?: p = 0, d = 0 (null) (used as policy rule placeholder)
247 * Direct assertion (no watch needed)( if d <0 ) --> d = 0, w1 = p, w2 = 0
248 * Binary rule: p = first literal, d = 0, w2 = second literal, w1 = p
249 * every other : w1 = p, w2 = whatprovidesdata[d];
250 * Disabled rule: w1 = 0
252 * always returns a rule for non-rpm rules
256 solver_addrule(Solver *solv, Id p, Id d)
258 Pool *pool = solv->pool;
262 int n = 0; /* number of literals in rule - 1
263 0 = direct assertion (single literal)
268 /* it often happenes that requires lead to adding the same rpm rule
269 * multiple times, so we prune those duplicates right away to make
270 * the work for unifyrules a bit easier */
272 if (solv->nrules /* we already have rules */
273 && !solv->rpmrules_end) /* but are not done with rpm rules */
275 r = solv->rules + solv->nrules - 1; /* get the last added rule */
276 if (r->p == p && r->d == d && d != 0) /* identical and not user requested */
281 * compute number of literals (n) in rule
286 /* always a binary rule */
288 return 0; /* ignore self conflict */
293 for (dp = pool->whatprovidesdata + d; *dp; dp++, n++)
295 return 0; /* rule is self-fulfilling */
297 if (n == 1) /* have single provider */
298 d = dp[-1]; /* take single literal */
301 if (n == 1 && p > d && !solv->rpmrules_end)
303 /* smallest literal first so we can find dups */
304 n = p; p = d; d = n; /* p <-> d */
305 n = 1; /* re-set n, was used as temp var */
309 * check for duplicate
312 /* check if the last added rule (r) is exactly the same as what we're looking for. */
313 if (r && n == 1 && !r->d && r->p == p && r->w2 == d)
314 return r; /* binary rule */
316 /* have n-ary rule with same first literal, check other literals */
317 if (r && n > 1 && r->d && r->p == p)
319 /* Rule where d is an offset in whatprovidesdata */
323 dp2 = pool->whatprovidesdata + r->d;
324 for (dp = pool->whatprovidesdata + d; *dp; dp++, dp2++)
335 /* extend rule buffer */
336 solv->rules = sat_extend(solv->rules, solv->nrules, 1, sizeof(Rule), RULES_BLOCK);
337 r = solv->rules + solv->nrules++; /* point to rule space */
346 /* direct assertion, no watch needed */
362 r->w2 = pool->whatprovidesdata[d];
367 IF_POOLDEBUG (SAT_DEBUG_RULE_CREATION)
369 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, " Add rule: ");
370 solver_printrule(solv, SAT_DEBUG_RULE_CREATION, r);
376 /*-------------------------------------------------------------------
381 disablerule(Solver *solv, Rule *r)
387 /*-------------------------------------------------------------------
392 enablerule(Solver *solv, Rule *r)
399 * special multiversion patch conflict handling:
400 * a patch conflict is also satisfied, if some other
401 * version with the same name/arch that doesn't conflict
402 * get's installed. The generated rule is thus:
403 * -patch|-cpack|opack1|opack2|...
406 makemultiversionconflict(Solver *solv, Id n, Id con)
408 Pool *pool = solv->pool;
413 sn = pool->solvables + n;
414 queue_init_buffer(&q, qbuf, sizeof(qbuf)/sizeof(*qbuf));
416 FOR_PROVIDES(p, pp, sn->name)
418 s = pool->solvables + p;
419 if (s->name != sn->name || s->arch != sn->arch)
421 if (!MAPTST(&solv->noobsoletes, p))
423 if (pool_match_nevr(pool, pool->solvables + p, con))
425 /* here we have a multiversion solvable that doesn't conflict */
426 /* thus we're not in conflict if it is installed */
430 return -n; /* no other package found, generate normal conflict */
431 return pool_queuetowhatprovides(pool, &q);
435 addrpmrule(Solver *solv, Id p, Id d, int type, Id dep)
437 if (!solv->ruleinfoq)
438 solver_addrule(solv, p, d);
440 addrpmruleinfo(solv, p, d, type, dep);
443 /*-------------------------------------------------------------------
445 * add (install) rules for solvable
447 * s: Solvable for which to add rules
448 * m: m[s] = 1 for solvables which have rules, prevent rule duplication
450 * Algorithm: 'visit all nodes of a graph'. The graph nodes are
451 * solvables, the edges their dependencies.
452 * Starting from an installed solvable, this will create all rules
453 * representing the graph created by the solvables dependencies.
455 * for unfulfilled requirements, conflicts, obsoletes,....
456 * add a negative assertion for solvables that are not installable
458 * It will also create rules for all solvables referenced by 's'
459 * i.e. descend to all providers of requirements of 's'
464 solver_addrpmrulesforsolvable(Solver *solv, Solvable *s, Map *m)
466 Pool *pool = solv->pool;
467 Repo *installed = solv->installed;
469 /* 'work' queue. keeps Ids of solvables we still have to work on.
470 And buffer for it. */
475 /* if to add rules for broken deps ('rpm -V' functionality)
479 /* Id var and pointer for each dependency
480 * (not used in parallel)
487 Id p, pp; /* whatprovides loops */
488 Id *dp; /* ptr to 'whatprovides' */
489 Id n; /* Id for current solvable 's' */
491 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforsolvable -----\n");
493 queue_init_buffer(&workq, workqbuf, sizeof(workqbuf)/sizeof(*workqbuf));
494 queue_push(&workq, s - pool->solvables); /* push solvable Id to work queue */
496 /* loop until there's no more work left */
501 * s: Pointer to solvable
504 n = queue_shift(&workq); /* 'pop' next solvable to work on from queue */
507 if (MAPTST(m, n)) /* continue if already visited */
509 MAPSET(m, n); /* mark as visited */
512 s = pool->solvables + n; /* s = Solvable in question */
515 if (installed /* Installed system available */
516 && !solv->fixsystem /* NOT repair errors in rpm dependency graph */
517 && s->repo == installed) /* solvable is installed? */
519 dontfix = 1; /* dont care about broken rpm deps */
523 && s->arch != ARCH_SRC
524 && s->arch != ARCH_NOSRC
525 && !pool_installable(pool, s))
527 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, "package %s [%d] is not installable\n", solvable2str(pool, s), (Id)(s - pool->solvables));
528 addrpmrule(solv, -n, 0, SOLVER_RULE_RPM_NOT_INSTALLABLE, 0);
531 /* yet another SUSE hack, sigh */
532 if (pool->nscallback && !strncmp("product:", id2str(pool, s->name), 8))
534 Id buddy = pool->nscallback(pool, pool->nscallbackdata, NAMESPACE_PRODUCTBUDDY, n);
535 if (buddy > 0 && buddy != SYSTEMSOLVABLE && buddy != n && buddy < pool->nsolvables)
537 addrpmrule(solv, n, -buddy, SOLVER_RULE_RPM_PACKAGE_REQUIRES, solvable_selfprovidedep(pool->solvables + n));
538 addrpmrule(solv, buddy, -n, SOLVER_RULE_RPM_PACKAGE_REQUIRES, solvable_selfprovidedep(pool->solvables + buddy));
539 if (m && !MAPTST(m, buddy))
540 queue_push(&workq, buddy);
544 /*-----------------------------------------
545 * check requires of s
550 reqp = s->repo->idarraydata + s->requires;
551 while ((req = *reqp++) != 0) /* go through all requires */
553 if (req == SOLVABLE_PREREQMARKER) /* skip the marker */
556 /* find list of solvables providing 'req' */
557 dp = pool_whatprovides_ptr(pool, req);
559 if (*dp == SYSTEMSOLVABLE) /* always installed */
564 /* the strategy here is to not insist on dependencies
565 * that are already broken. so if we find one provider
566 * that was already installed, we know that the
567 * dependency was not broken before so we enforce it */
569 /* check if any of the providers for 'req' is installed */
570 for (i = 0; (p = dp[i]) != 0; i++)
572 if (pool->solvables[p].repo == installed)
573 break; /* provider was installed */
575 /* didn't find an installed provider: previously broken dependency */
578 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, "ignoring broken requires %s of installed package %s\n", dep2str(pool, req), solvable2str(pool, s));
585 /* nothing provides req! */
586 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, "package %s [%d] is not installable (%s)\n", solvable2str(pool, s), (Id)(s - pool->solvables), dep2str(pool, req));
587 addrpmrule(solv, -n, 0, SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP, req);
591 IF_POOLDEBUG (SAT_DEBUG_RULE_CREATION)
593 POOL_DEBUG(SAT_DEBUG_RULE_CREATION," %s requires %s\n", solvable2str(pool, s), dep2str(pool, req));
594 for (i = 0; dp[i]; i++)
595 POOL_DEBUG(SAT_DEBUG_RULE_CREATION, " provided by %s\n", solvid2str(pool, dp[i]));
598 /* add 'requires' dependency */
599 /* rule: (-requestor|provider1|provider2|...|providerN) */
600 addrpmrule(solv, -n, dp - pool->whatprovidesdata, SOLVER_RULE_RPM_PACKAGE_REQUIRES, req);
602 /* descend the dependency tree
603 push all non-visited providers on the work queue */
609 queue_push(&workq, *dp);
613 } /* while, requirements of n */
615 } /* if, requirements */
617 /* that's all we check for src packages */
618 if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
621 /*-----------------------------------------
622 * check conflicts of s
629 /* we treat conflicts in patches a bit differen:
631 * - multiversion handling
632 * XXX: we should really handle this different, looking
633 * at the name is a bad hack
635 if (!strncmp("patch:", id2str(pool, s->name), 6))
637 conp = s->repo->idarraydata + s->conflicts;
638 /* foreach conflicts of 's' */
639 while ((con = *conp++) != 0)
641 /* foreach providers of a conflict of 's' */
642 FOR_PROVIDES(p, pp, con)
644 if (ispatch && !pool_match_nevr(pool, pool->solvables + p, con))
646 /* dontfix: dont care about conflicts with already installed packs */
647 if (dontfix && pool->solvables[p].repo == installed)
649 /* p == n: self conflict */
650 if (p == n && !solv->allowselfconflicts)
654 Reldep *rd = GETRELDEP(pool, con);
655 if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_OTHERPROVIDERS)
658 p = 0; /* make it a negative assertion, aka 'uninstallable' */
660 if (p && ispatch && solv->noobsoletes.size && MAPTST(&solv->noobsoletes, p) && ISRELDEP(con))
662 /* our patch conflicts with a noobsoletes (aka multiversion) package */
663 p = -makemultiversionconflict(solv, p, con);
665 /* rule: -n|-p: either solvable _or_ provider of conflict */
666 addrpmrule(solv, -n, -p, p ? SOLVER_RULE_RPM_PACKAGE_CONFLICT : SOLVER_RULE_RPM_SELF_CONFLICT, con);
671 /*-----------------------------------------
672 * check obsoletes if not installed
673 * (only installation will trigger the obsoletes in rpm)
675 if (!installed || pool->solvables[n].repo != installed)
676 { /* not installed */
677 int noobs = solv->noobsoletes.size && MAPTST(&solv->noobsoletes, n);
678 if (s->obsoletes && !noobs)
680 obsp = s->repo->idarraydata + s->obsoletes;
681 /* foreach obsoletes */
682 while ((obs = *obsp++) != 0)
684 /* foreach provider of an obsoletes of 's' */
685 FOR_PROVIDES(p, pp, obs)
687 if (!solv->obsoleteusesprovides /* obsoletes are matched names, not provides */
688 && !pool_match_nevr(pool, pool->solvables + p, obs))
690 addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_PACKAGE_OBSOLETES, obs);
694 FOR_PROVIDES(p, pp, s->name)
696 Solvable *ps = pool->solvables + p;
697 /* we still obsolete packages with same nevra, like rpm does */
698 /* (actually, rpm mixes those packages. yuck...) */
699 if (noobs && (s->name != ps->name || s->evr != ps->evr || s->arch != ps->arch))
701 if (!solv->implicitobsoleteusesprovides && s->name != ps->name)
703 if (s->name == ps->name)
704 addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_SAME_NAME, 0);
706 addrpmrule(solv, -n, -p, SOLVER_RULE_RPM_IMPLICIT_OBSOLETES, s->name);
710 /*-----------------------------------------
711 * add recommends to the work queue
713 if (s->recommends && m)
715 recp = s->repo->idarraydata + s->recommends;
716 while ((rec = *recp++) != 0)
718 FOR_PROVIDES(p, pp, rec)
720 queue_push(&workq, p);
723 if (s->suggests && m)
725 sugp = s->repo->idarraydata + s->suggests;
726 while ((sug = *sugp++) != 0)
728 FOR_PROVIDES(p, pp, sug)
730 queue_push(&workq, p);
735 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforsolvable end -----\n");
739 /*-------------------------------------------------------------------
741 * Add package rules for weak rules
743 * m: visited solvables
747 solver_addrpmrulesforweak(Solver *solv, Map *m)
749 Pool *pool = solv->pool;
754 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforweak -----\n");
755 /* foreach solvable in pool */
756 for (i = n = 1; n < pool->nsolvables; i++, n++)
758 if (i == pool->nsolvables) /* wrap i */
760 if (MAPTST(m, i)) /* been there */
763 s = pool->solvables + i;
764 if (!pool_installable(pool, s)) /* only look at installable ones */
770 /* find possible supplements */
771 supp = s->repo->idarraydata + s->supplements;
772 while ((sup = *supp++) != ID_NULL)
773 if (dep_possible(solv, sup, m))
777 /* if nothing found, check for enhances */
778 if (!sup && s->enhances)
780 supp = s->repo->idarraydata + s->enhances;
781 while ((sup = *supp++) != ID_NULL)
782 if (dep_possible(solv, sup, m))
785 /* if nothing found, goto next solvables */
788 solver_addrpmrulesforsolvable(solv, s, m);
789 n = 0; /* check all solvables again */
791 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforweak end -----\n");
795 /*-------------------------------------------------------------------
797 * add package rules for possible updates
800 * m: map of already visited solvables
801 * allow_all: 0 = dont allow downgrades, 1 = allow all candidates
805 solver_addrpmrulesforupdaters(Solver *solv, Solvable *s, Map *m, int allow_all)
807 Pool *pool = solv->pool;
809 /* queue and buffer for it */
813 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforupdaters -----\n");
815 queue_init_buffer(&qs, qsbuf, sizeof(qsbuf)/sizeof(*qsbuf));
816 /* find update candidates for 's' */
817 policy_findupdatepackages(solv, s, &qs, allow_all);
818 /* add rule for 's' if not already done */
819 if (!MAPTST(m, s - pool->solvables))
820 solver_addrpmrulesforsolvable(solv, s, m);
821 /* foreach update candidate, add rule if not already done */
822 for (i = 0; i < qs.count; i++)
823 if (!MAPTST(m, qs.elements[i]))
824 solver_addrpmrulesforsolvable(solv, pool->solvables + qs.elements[i], m);
827 POOL_DEBUG(SAT_DEBUG_SCHUBI, "----- addrpmrulesforupdaters -----\n");
833 addrpmruleinfo(Solver *solv, Id p, Id d, int type, Id dep)
835 Pool *pool = solv->pool;
839 /* check if this creates the rule we're searching for */
840 r = solv->rules + solv->ruleinfoq->elements[0];
842 od = r->d < 0 ? -r->d - 1 : r->d;
847 if (p < 0 && d > 0 && (!pool->whatprovidesdata[d] || !pool->whatprovidesdata[d + 1]))
849 w2 = pool->whatprovidesdata[d];
853 if (p > 0 && d < 0) /* this hack is used for buddy deps */
865 Id *dp = pool->whatprovidesdata + d;
866 Id *odp = pool->whatprovidesdata + od;
874 /* handle multiversion conflict rules */
875 if (p < 0 && pool->whatprovidesdata[d] < 0)
877 w2 = pool->whatprovidesdata[d];
878 /* XXX: free memory */
888 if (w2 != op || p != ow2)
893 if (p != op || w2 != ow2)
897 /* yep, rule matches. record info */
898 queue_push(solv->ruleinfoq, type);
899 if (type == SOLVER_RULE_RPM_SAME_NAME)
901 /* we normalize same name order */
902 queue_push(solv->ruleinfoq, op < 0 ? -op : 0);
903 queue_push(solv->ruleinfoq, ow2 < 0 ? -ow2 : 0);
907 queue_push(solv->ruleinfoq, p < 0 ? -p : 0);
908 queue_push(solv->ruleinfoq, w2 < 0 ? -w2 : 0);
910 queue_push(solv->ruleinfoq, dep);
914 solver_allruleinfos_cmp(const void *ap, const void *bp, void *dp)
916 const Id *a = ap, *b = bp;
935 solver_allruleinfos(Solver *solv, Id rid, Queue *rq)
937 Pool *pool = solv->pool;
938 Rule *r = solv->rules + rid;
942 if (rid <= 0 || rid >= solv->rpmrules_end)
944 Id type, from, to, dep;
945 type = solver_ruleinfo(solv, rid, &from, &to, &dep);
946 queue_push(rq, type);
947 queue_push(rq, from);
955 solv->ruleinfoq = rq;
956 solver_addrpmrulesforsolvable(solv, pool->solvables - r->p, 0);
957 /* also try reverse direction for conflicts */
958 if ((r->d == 0 || r->d == -1) && r->w2 < 0)
959 solver_addrpmrulesforsolvable(solv, pool->solvables - r->w2, 0);
962 /* now sort & unify em */
965 sat_sort(rq->elements, rq->count / 4, 4 * sizeof(Id), solver_allruleinfos_cmp, 0);
966 /* throw out identical entries */
967 for (i = j = 0; i < rq->count; i += 4)
971 if (rq->elements[i] == rq->elements[j - 4] &&
972 rq->elements[i + 1] == rq->elements[j - 3] &&
973 rq->elements[i + 2] == rq->elements[j - 2] &&
974 rq->elements[i + 3] == rq->elements[j - 1])
977 rq->elements[j++] = rq->elements[i];
978 rq->elements[j++] = rq->elements[i + 1];
979 rq->elements[j++] = rq->elements[i + 2];
980 rq->elements[j++] = rq->elements[i + 3];
987 solver_ruleinfo(Solver *solv, Id rid, Id *fromp, Id *top, Id *depp)
989 Pool *pool = solv->pool;
990 Rule *r = solv->rules + rid;
991 SolverRuleinfo type = SOLVER_RULE_UNKNOWN;
999 if (rid > 0 && rid < solv->rpmrules_end)
1005 return SOLVER_RULE_RPM;
1009 queue_push(&rq, rid);
1010 solv->ruleinfoq = &rq;
1011 solver_addrpmrulesforsolvable(solv, pool->solvables - r->p, 0);
1012 /* also try reverse direction for conflicts */
1013 if ((r->d == 0 || r->d == -1) && r->w2 < 0)
1014 solver_addrpmrulesforsolvable(solv, pool->solvables - r->w2, 0);
1015 solv->ruleinfoq = 0;
1016 type = SOLVER_RULE_RPM;
1017 for (i = 1; i < rq.count; i += 4)
1020 qt = rq.elements[i];
1021 qp = rq.elements[i + 1];
1022 qo = rq.elements[i + 2];
1023 qd = rq.elements[i + 3];
1024 if (type == SOLVER_RULE_RPM || type > qt)
1038 if (rid >= solv->jobrules && rid < solv->jobrules_end)
1040 Id jidx = solv->ruletojob.elements[rid - solv->jobrules];
1044 *top = solv->job.elements[jidx];
1046 *depp = solv->job.elements[jidx + 1];
1047 if ((r->d == 0 || r->d == -1) && r->w2 == 0 && r->p == -SYSTEMSOLVABLE && (solv->job.elements[jidx] & SOLVER_SELECTMASK) != SOLVER_SOLVABLE_ONE_OF)
1048 return SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
1049 return SOLVER_RULE_JOB;
1051 if (rid >= solv->updaterules && rid < solv->updaterules_end)
1054 *fromp = solv->installed->start + (rid - solv->updaterules);
1055 return SOLVER_RULE_UPDATE;
1057 if (rid >= solv->featurerules && rid < solv->featurerules_end)
1060 *fromp = solv->installed->start + (rid - solv->featurerules);
1061 return SOLVER_RULE_FEATURE;
1063 if (rid >= solv->duprules && rid < solv->duprules_end)
1068 *depp = pool->solvables[-r->p].name;
1069 return SOLVER_RULE_DISTUPGRADE;
1071 if (rid >= solv->infarchrules && rid < solv->infarchrules_end)
1076 *depp = pool->solvables[-r->p].name;
1077 return SOLVER_RULE_INFARCH;
1079 if (rid >= solv->learntrules)
1081 return SOLVER_RULE_LEARNT;
1083 return SOLVER_RULE_UNKNOWN;