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 s_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_PKG = 0x100,
52 SOLVER_RULE_PKG_NOT_INSTALLABLE,
53 SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP,
54 SOLVER_RULE_PKG_REQUIRES,
55 SOLVER_RULE_PKG_SELF_CONFLICT,
56 SOLVER_RULE_PKG_CONFLICTS,
57 SOLVER_RULE_PKG_SAME_NAME,
58 SOLVER_RULE_PKG_OBSOLETES,
59 SOLVER_RULE_PKG_IMPLICIT_OBSOLETES,
60 SOLVER_RULE_PKG_INSTALLED_OBSOLETES,
61 SOLVER_RULE_PKG_RECOMMENDS,
62 SOLVER_RULE_PKG_CONSTRAINS,
63 SOLVER_RULE_UPDATE = 0x200,
64 SOLVER_RULE_FEATURE = 0x300,
65 SOLVER_RULE_JOB = 0x400,
66 SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP,
67 SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM,
68 SOLVER_RULE_JOB_UNKNOWN_PACKAGE,
69 SOLVER_RULE_JOB_UNSUPPORTED,
70 SOLVER_RULE_DISTUPGRADE = 0x500,
71 SOLVER_RULE_INFARCH = 0x600,
72 SOLVER_RULE_CHOICE = 0x700,
73 SOLVER_RULE_LEARNT = 0x800,
74 SOLVER_RULE_BEST = 0x900,
75 SOLVER_RULE_YUMOBS = 0xa00,
76 SOLVER_RULE_RECOMMENDS = 0xb00,
77 SOLVER_RULE_BLACK = 0xc00
80 #define SOLVER_RULE_TYPEMASK 0xff00
84 /*-------------------------------------------------------------------
89 solver_disablerule(struct s_Solver *solv, Rule *r)
95 /*-------------------------------------------------------------------
100 solver_enablerule(struct s_Solver *solv, Rule *r)
106 extern Rule *solver_addrule(struct s_Solver *solv, Id p, Id p2, Id d);
107 extern void solver_unifyrules(struct s_Solver *solv);
108 extern int solver_rulecmp(struct s_Solver *solv, Rule *r1, Rule *r2);
109 extern void solver_shrinkrules(struct s_Solver *solv, int nrules);
112 extern void solver_addpkgrulesforsolvable(struct s_Solver *solv, Solvable *s, Map *m);
113 extern void solver_addpkgrulesforweak(struct s_Solver *solv, Map *m);
114 extern void solver_addpkgrulesforlinked(struct s_Solver *solv, Map *m);
115 extern void solver_addpkgrulesforupdaters(struct s_Solver *solv, Solvable *s, Map *m, int allow_all);
117 /* update/feature rules */
118 extern void solver_addfeaturerule(struct s_Solver *solv, Solvable *s);
119 extern void solver_addupdaterule(struct s_Solver *solv, Solvable *s);
122 extern void solver_addinfarchrules(struct s_Solver *solv, Map *addedmap);
125 extern void solver_createdupmaps(struct s_Solver *solv);
126 extern void solver_freedupmaps(struct s_Solver *solv);
127 extern void solver_addduprules(struct s_Solver *solv, Map *addedmap);
130 extern void solver_addchoicerules(struct s_Solver *solv);
131 extern void solver_disablechoicerules(struct s_Solver *solv, Rule *r);
134 extern void solver_addbestrules(struct s_Solver *solv, int havebestinstalljobs, int haslockjob);
137 extern void solver_addyumobsrules(struct s_Solver *solv);
140 extern void solver_addblackrules(struct s_Solver *solv);
142 /* recommends rules */
143 extern void solver_addrecommendsrules(struct s_Solver *solv);
145 /* policy rule disabling/reenabling */
146 extern void solver_disablepolicyrules(struct s_Solver *solv);
147 extern void solver_reenablepolicyrules(struct s_Solver *solv, int jobidx);
148 extern void solver_reenablepolicyrules_cleandeps(struct s_Solver *solv, Id pkg);
151 extern int solver_allruleinfos(struct s_Solver *solv, Id rid, Queue *rq);
152 extern SolverRuleinfo solver_ruleinfo(struct s_Solver *solv, Id rid, Id *fromp, Id *top, Id *depp);
153 extern SolverRuleinfo solver_ruleclass(struct s_Solver *solv, Id rid);
154 extern void solver_ruleliterals(struct s_Solver *solv, Id rid, Queue *q);
155 extern int solver_rule2jobidx(struct s_Solver *solv, Id rid);
156 extern Id solver_rule2job(struct s_Solver *solv, Id rid, Id *whatp);
157 extern Id solver_rule2solvable(struct s_Solver *solv, Id rid);
158 extern void solver_rule2rules(struct s_Solver *solv, Id rid, Queue *q, int recursive);
159 extern Id solver_rule2pkgrule(struct s_Solver *solv, Id rid);
161 /* orphan handling */
162 extern void solver_breakorphans(struct s_Solver *solv);
163 extern void solver_check_brokenorphanrules(struct s_Solver *solv, Queue *dq);
167 #define SOLVER_RULE_RPM SOLVER_RULE_PKG
168 #define SOLVER_RULE_RPM_NOT_INSTALLABLE SOLVER_RULE_PKG_NOT_INSTALLABLE
169 #define SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP
170 #define SOLVER_RULE_RPM_PACKAGE_REQUIRES SOLVER_RULE_PKG_REQUIRES
171 #define SOLVER_RULE_RPM_SELF_CONFLICT SOLVER_RULE_PKG_SELF_CONFLICT
172 #define SOLVER_RULE_RPM_PACKAGE_CONFLICT SOLVER_RULE_PKG_CONFLICTS
173 #define SOLVER_RULE_RPM_SAME_NAME SOLVER_RULE_PKG_SAME_NAME
174 #define SOLVER_RULE_RPM_PACKAGE_OBSOLETES SOLVER_RULE_PKG_OBSOLETES
175 #define SOLVER_RULE_RPM_IMPLICIT_OBSOLETES SOLVER_RULE_PKG_IMPLICIT_OBSOLETES
176 #define SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES SOLVER_RULE_PKG_INSTALLED_OBSOLETES