2 * Copyright (c) 2007-2009, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
13 #ifndef LIBSOLV_RULES_H
14 #define LIBSOLV_RULES_H
20 /* ----------------------------------------------
23 * providerN(B) == Package Id of package providing tag B
24 * N = 1, 2, 3, in case of multiple providers
26 * A requires B : !A | provider1(B) | provider2(B)
28 * A conflicts B : (!A | !provider1(B)) & (!A | !provider2(B)) ...
30 * 'not' is encoded as a negative Id
32 * Binary rule: p = first literal, d = 0, w2 = second literal, w1 = p
34 * There are a lot of rules, so the struct is kept as small as
35 * possible. Do not add new members unless there is no other way.
38 typedef struct _Rule {
39 Id p; /* first literal in rule */
40 Id d; /* Id offset into 'list of providers terminated by 0' as used by whatprovides; pool->whatprovides + d */
41 /* in case of binary rules, d == 0, w1 == p, w2 == other literal */
42 /* in case of disabled rules: ~d, aka -d - 1 */
43 Id w1, w2; /* watches, literals not-yet-decided */
44 /* if !w2, assertion, not rule */
45 Id n1, n2; /* next rules in linked list, corresponding to w1, w2 */
50 SOLVER_RULE_UNKNOWN = 0,
51 SOLVER_RULE_RPM = 0x100,
52 SOLVER_RULE_RPM_NOT_INSTALLABLE,
53 SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP,
54 SOLVER_RULE_RPM_PACKAGE_REQUIRES,
55 SOLVER_RULE_RPM_SELF_CONFLICT,
56 SOLVER_RULE_RPM_PACKAGE_CONFLICT,
57 SOLVER_RULE_RPM_SAME_NAME,
58 SOLVER_RULE_RPM_PACKAGE_OBSOLETES,
59 SOLVER_RULE_RPM_IMPLICIT_OBSOLETES,
60 SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES,
61 SOLVER_RULE_UPDATE = 0x200,
62 SOLVER_RULE_FEATURE = 0x300,
63 SOLVER_RULE_JOB = 0x400,
64 SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP,
65 SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM,
66 SOLVER_RULE_JOB_UNKNOWN_PACKAGE,
67 SOLVER_RULE_JOB_UNSUPPORTED,
68 SOLVER_RULE_DISTUPGRADE = 0x500,
69 SOLVER_RULE_INFARCH = 0x600,
70 SOLVER_RULE_CHOICE = 0x700,
71 SOLVER_RULE_LEARNT = 0x800,
72 SOLVER_RULE_BEST = 0x900
75 #define SOLVER_RULE_TYPEMASK 0xff00
79 /*-------------------------------------------------------------------
84 solver_disablerule(struct _Solver *solv, Rule *r)
90 /*-------------------------------------------------------------------
95 solver_enablerule(struct _Solver *solv, Rule *r)
101 extern Rule *solver_addrule(struct _Solver *solv, Id p, Id d);
102 extern void solver_unifyrules(struct _Solver *solv);
103 extern int solver_rulecmp(struct _Solver *solv, Rule *r1, Rule *r2);
104 extern void solver_shrinkrules(struct _Solver *solv, int nrules);
107 extern void solver_addrpmrulesforsolvable(struct _Solver *solv, Solvable *s, Map *m);
108 extern void solver_addrpmrulesforweak(struct _Solver *solv, Map *m);
109 extern void solver_addrpmrulesforupdaters(struct _Solver *solv, Solvable *s, Map *m, int allow_all);
111 /* update/feature rules */
112 extern void solver_addupdaterule(struct _Solver *solv, Solvable *s, int allow_all);
115 extern void solver_addinfarchrules(struct _Solver *solv, Map *addedmap);
118 extern void solver_createdupmaps(struct _Solver *solv);
119 extern void solver_freedupmaps(struct _Solver *solv);
120 extern void solver_addduprules(struct _Solver *solv, Map *addedmap);
123 extern void solver_addchoicerules(struct _Solver *solv);
124 extern void solver_disablechoicerules(struct _Solver *solv, Rule *r);
127 extern void solver_addbestrules(struct _Solver *solv, int havebestinstalljobs);
129 /* policy rule disabling/reenabling */
130 extern void solver_disablepolicyrules(struct _Solver *solv);
131 extern void solver_reenablepolicyrules(struct _Solver *solv, int jobidx);
132 extern void solver_reenablepolicyrules_cleandeps(struct _Solver *solv, Id pkg);
135 extern int solver_allruleinfos(struct _Solver *solv, Id rid, Queue *rq);
136 extern SolverRuleinfo solver_ruleinfo(struct _Solver *solv, Id rid, Id *fromp, Id *top, Id *depp);
137 extern SolverRuleinfo solver_ruleclass(struct _Solver *solv, Id rid);
138 extern void solver_ruleliterals(struct _Solver *solv, Id rid, Queue *q);
139 extern int solver_rule2jobidx(struct _Solver *solv, Id rid);
140 extern Id solver_rule2job(struct _Solver *solv, Id rid, Id *whatp);
141 extern Id solver_rule2solvable(struct _Solver *solv, Id rid);
142 extern void solver_rule2rules(struct _Solver *solv, Id rid, Queue *q, int recursive);