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
16 #include "pooltypes.h"
25 /* ----------------------------------------------
28 * providerN(B) == Package Id of package providing tag B
29 * N = 1, 2, 3, in case of multiple providers
31 * A requires B : !A | provider1(B) | provider2(B)
33 * A conflicts B : (!A | !provider1(B)) & (!A | !provider2(B)) ...
35 * 'not' is encoded as a negative Id
37 * Binary rule: p = first literal, d = 0, w2 = second literal, w1 = p
39 * There are a lot of rules, so the struct is kept as small as
40 * possible. Do not add new members unless there is no other way.
43 typedef struct s_Rule {
44 Id p; /* first literal in rule */
45 Id d; /* Id offset into 'list of providers terminated by 0' as used by whatprovides; pool->whatprovides + d */
46 /* in case of binary rules, d == 0, w1 == p, w2 == other literal */
47 /* in case of disabled rules: ~d, aka -d - 1 */
48 Id w1, w2; /* watches, literals not-yet-decided */
49 /* if !w2, assertion, not rule */
50 Id n1, n2; /* next rules in linked list, corresponding to w1, w2 */
55 SOLVER_RULE_UNKNOWN = 0,
56 SOLVER_RULE_PKG = 0x100,
57 SOLVER_RULE_PKG_NOT_INSTALLABLE,
58 SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP,
59 SOLVER_RULE_PKG_REQUIRES,
60 SOLVER_RULE_PKG_SELF_CONFLICT,
61 SOLVER_RULE_PKG_CONFLICTS,
62 SOLVER_RULE_PKG_SAME_NAME,
63 SOLVER_RULE_PKG_OBSOLETES,
64 SOLVER_RULE_PKG_IMPLICIT_OBSOLETES,
65 SOLVER_RULE_PKG_INSTALLED_OBSOLETES,
66 SOLVER_RULE_PKG_RECOMMENDS,
67 SOLVER_RULE_PKG_CONSTRAINS,
68 SOLVER_RULE_PKG_SUPPLEMENTS,
69 SOLVER_RULE_UPDATE = 0x200,
70 SOLVER_RULE_FEATURE = 0x300,
71 SOLVER_RULE_JOB = 0x400,
72 SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP,
73 SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM,
74 SOLVER_RULE_JOB_UNKNOWN_PACKAGE,
75 SOLVER_RULE_JOB_UNSUPPORTED,
76 SOLVER_RULE_DISTUPGRADE = 0x500,
77 SOLVER_RULE_INFARCH = 0x600,
78 SOLVER_RULE_CHOICE = 0x700,
79 SOLVER_RULE_LEARNT = 0x800,
80 SOLVER_RULE_BEST = 0x900,
81 SOLVER_RULE_YUMOBS = 0xa00,
82 SOLVER_RULE_RECOMMENDS = 0xb00,
83 SOLVER_RULE_BLACK = 0xc00,
84 SOLVER_RULE_STRICT_REPO_PRIORITY = 0xd00
87 #define SOLVER_RULE_TYPEMASK 0xff00
91 /*-------------------------------------------------------------------
96 solver_disablerule(struct s_Solver *solv, Rule *r)
102 /*-------------------------------------------------------------------
107 solver_enablerule(struct s_Solver *solv, Rule *r)
113 extern Rule *solver_addrule(struct s_Solver *solv, Id p, Id p2, Id d);
114 extern void solver_unifyrules(struct s_Solver *solv);
115 extern int solver_rulecmp(struct s_Solver *solv, Rule *r1, Rule *r2);
116 extern void solver_shrinkrules(struct s_Solver *solv, int nrules);
119 extern void solver_addpkgrulesforsolvable(struct s_Solver *solv, Solvable *s, Map *m);
120 extern void solver_addpkgrulesforweak(struct s_Solver *solv, Map *m);
121 extern void solver_addpkgrulesforlinked(struct s_Solver *solv, Map *m);
122 extern void solver_addpkgrulesforupdaters(struct s_Solver *solv, Solvable *s, Map *m, int allow_all);
124 /* update/feature rules */
125 extern void solver_addfeaturerule(struct s_Solver *solv, Solvable *s);
126 extern void solver_addupdaterule(struct s_Solver *solv, Solvable *s);
129 extern void solver_addinfarchrules(struct s_Solver *solv, Map *addedmap);
132 extern void solver_createdupmaps(struct s_Solver *solv);
133 extern void solver_freedupmaps(struct s_Solver *solv);
134 extern void solver_addduprules(struct s_Solver *solv, Map *addedmap);
137 extern void solver_addchoicerules(struct s_Solver *solv);
138 extern void solver_disablechoicerules(struct s_Solver *solv, Rule *r);
141 extern void solver_addbestrules(struct s_Solver *solv, int havebestinstalljobs, int haslockjob);
144 extern void solver_addyumobsrules(struct s_Solver *solv);
147 extern void solver_addblackrules(struct s_Solver *solv);
149 /* recommends rules */
150 extern void solver_addrecommendsrules(struct s_Solver *solv);
152 /* channel priority rules */
153 extern void solver_addstrictrepopriorules(struct s_Solver *solv, Map *addedmap);
155 /* policy rule disabling/reenabling */
156 extern void solver_disablepolicyrules(struct s_Solver *solv);
157 extern void solver_reenablepolicyrules(struct s_Solver *solv, int jobidx);
158 extern void solver_reenablepolicyrules_cleandeps(struct s_Solver *solv, Id pkg);
161 extern int solver_allruleinfos(struct s_Solver *solv, Id rid, Queue *rq);
162 extern SolverRuleinfo solver_ruleinfo(struct s_Solver *solv, Id rid, Id *fromp, Id *top, Id *depp);
163 extern SolverRuleinfo solver_ruleclass(struct s_Solver *solv, Id rid);
164 extern void solver_ruleliterals(struct s_Solver *solv, Id rid, Queue *q);
165 extern int solver_rule2jobidx(struct s_Solver *solv, Id rid);
166 extern Id solver_rule2job(struct s_Solver *solv, Id rid, Id *whatp);
167 extern Id solver_rule2solvable(struct s_Solver *solv, Id rid);
168 extern void solver_rule2rules(struct s_Solver *solv, Id rid, Queue *q, int recursive);
169 extern Id solver_rule2pkgrule(struct s_Solver *solv, Id rid);
170 extern const char *solver_ruleinfo2str(struct s_Solver *solv, SolverRuleinfo type, Id source, Id target, Id dep);
172 /* rule infos for weakdep decisions */
173 extern int solver_allweakdepinfos(struct s_Solver *solv, Id p, Queue *rq);
174 extern SolverRuleinfo solver_weakdepinfo(struct s_Solver *solv, Id p, Id *fromp, Id *top, Id *depp);
176 /* orphan handling */
177 extern void solver_breakorphans(struct s_Solver *solv);
178 extern void solver_check_brokenorphanrules(struct s_Solver *solv, Queue *dq);
182 #define SOLVER_RULE_RPM SOLVER_RULE_PKG
183 #define SOLVER_RULE_RPM_NOT_INSTALLABLE SOLVER_RULE_PKG_NOT_INSTALLABLE
184 #define SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP SOLVER_RULE_PKG_NOTHING_PROVIDES_DEP
185 #define SOLVER_RULE_RPM_PACKAGE_REQUIRES SOLVER_RULE_PKG_REQUIRES
186 #define SOLVER_RULE_RPM_SELF_CONFLICT SOLVER_RULE_PKG_SELF_CONFLICT
187 #define SOLVER_RULE_RPM_PACKAGE_CONFLICT SOLVER_RULE_PKG_CONFLICTS
188 #define SOLVER_RULE_RPM_SAME_NAME SOLVER_RULE_PKG_SAME_NAME
189 #define SOLVER_RULE_RPM_PACKAGE_OBSOLETES SOLVER_RULE_PKG_OBSOLETES
190 #define SOLVER_RULE_RPM_IMPLICIT_OBSOLETES SOLVER_RULE_PKG_IMPLICIT_OBSOLETES
191 #define SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES SOLVER_RULE_PKG_INSTALLED_OBSOLETES