2 * Copyright (c) 2011, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
9 * solver_p.h - private functions
13 #ifndef LIBSOLV_SOLVER_P_H
14 #define LIBSOLV_SOLVER_P_H
18 Pool *pool; /* back pointer to pool */
19 Queue job; /* copy of the job we're solving */
21 Transaction trans; /* calculated transaction */
23 Repo *installed; /* copy of pool->installed */
25 /* list of rules, ordered
26 * rpm rules first, then features, updates, jobs, learnt
27 * see start/end offsets below
29 Rule *rules; /* all rules */
30 Id nrules; /* [Offset] index of the last rule */
32 Queue ruleassertions; /* Queue of all assertion rules */
34 /* start/end offset for rule 'areas' */
36 Id rpmrules_end; /* [Offset] rpm rules end */
38 Id featurerules; /* feature rules start/end */
41 Id updaterules; /* policy rules, e.g. keep packages installed or update. All literals > 0 */
44 Id jobrules; /* user rules */
47 Id infarchrules; /* inferior arch rules */
50 Id duprules; /* dist upgrade rules */
53 Id choicerules; /* choice rules (always weak) */
57 Id learntrules; /* learnt rules, (end == nrules) */
59 Map noupdate; /* don't try to update these
60 installed solvables */
61 Map noobsoletes; /* ignore obsoletes for these (multiinstall) */
63 Map updatemap; /* bring these installed packages to the newest version */
64 int updatemap_all; /* bring all packages to the newest version */
66 Map fixmap; /* fix these packages */
67 int fixmap_all; /* fix all packages */
69 Queue weakruleq; /* index into 'rules' for weak ones */
70 Map weakrulemap; /* map rule# to '1' for weak rules, 1..learntrules */
72 Id *watches; /* Array of rule offsets
73 * watches has nsolvables*2 entries and is addressed from the middle
74 * middle-solvable : decision to conflict, offset point to linked-list of rules
75 * middle+solvable : decision to install: offset point to linked-list of rules
78 Queue ruletojob; /* index into job queue: jobs for which a rule exits */
81 Queue decisionq; /* >0:install, <0:remove/conflict */
82 Queue decisionq_why; /* index of rule, Offset into rules */
84 Id *decisionmap; /* map for all available solvables,
86 * > 0: level of decision when installed,
87 * < 0: level of decision when conflict */
89 /* learnt rule history */
94 int (*solution_callback)(struct _Solver *solv, void *data);
95 void *solution_callback_data;
97 int propagate_index; /* index into decisionq for non-propagated decisions */
99 Queue problems; /* list of lists of conflicting rules, < 0 for job rules */
100 Queue solutions; /* refined problem storage space */
102 Queue recommendations; /* recommended packages */
103 Queue suggestions; /* suggested packages */
104 Queue orphaned; /* orphaned packages */
106 int stats_learned; /* statistic */
107 int stats_unsolvable; /* statistic */
109 Map recommendsmap; /* recommended packages from decisionmap */
110 Map suggestsmap; /* suggested packages from decisionmap */
111 int recommends_index; /* recommendsmap/suggestsmap is created up to this level */
113 Id *obsoletes; /* obsoletes for each installed solvable */
114 Id *obsoletes_data; /* data area for obsoletes */
115 Id *multiversionupdaters; /* updaters for multiversion packages in updatesystem mode */
117 /*-------------------------------------------------------------------------------------------------------------
118 * Solver configuration
119 *-------------------------------------------------------------------------------------------------------------*/
121 int fixsystem; /* repair errors in rpm dependency graph */
122 int allowdowngrade; /* allow to downgrade installed solvable */
123 int allowarchchange; /* allow to change architecture of installed solvables */
124 int allowvendorchange; /* allow to change vendor of installed solvables */
125 int allowuninstall; /* allow removal of installed solvables */
126 int updatesystem; /* update all packages to the newest version */
127 int noupdateprovide; /* true: update packages needs not to provide old package */
128 int dosplitprovides; /* true: consider legacy split provides */
129 int dontinstallrecommended; /* true: do not install recommended packages */
130 int ignorealreadyrecommended; /* true: ignore recommended packages that were already recommended by the installed packages */
131 int dontshowinstalledrecommended; /* true: do not show recommended packages that are already installed */
133 /* distupgrade also needs updatesystem and dosplitprovides */
135 int distupgrade_removeunsupported;
137 int noinfarchcheck; /* true: do not forbid inferior architectures */
139 /* Callbacks for defining the bahaviour of the SAT solver */
141 /* Finding best candidate
143 * Callback definition:
144 * void bestSolvable (Pool *pool, Queue *canditates)
145 * candidates : List of canditates which has to be sorted by the function call
146 * return candidates: Sorted list of the candidates(first is the best).
148 BestSolvableCb bestSolvableCb;
150 /* Checking if two solvables has compatible architectures
152 * Callback definition:
153 * int archCheck (Pool *pool, Solvable *solvable1, Solvable *solvable2);
155 * return 0 it the two solvables has compatible architectures
157 ArchCheckCb archCheckCb;
159 /* Checking if two solvables has compatible vendors
161 * Callback definition:
162 * int vendorCheck (Pool *pool, Solvable *solvable1, Solvable *solvable2);
164 * return 0 it the two solvables has compatible architectures
166 VendorCheckCb vendorCheckCb;
168 /* Evaluate update candidate
170 * Callback definition:
171 * void pdateCandidateCb (Pool *pool, Solvable *solvable, Queue *canditates)
172 * solvable : for which updates should be search
173 * candidates : List of candidates (This list depends on other
174 * restrictions like architecture and vendor policies too)
176 UpdateCandidateCb updateCandidateCb;
178 Map dupmap; /* dup these packages*/
179 int dupmap_all; /* dup all packages */
180 Map dupinvolvedmap; /* packages involved in dup process */
182 Map droporphanedmap; /* packages to drop in dup mode */
183 int droporphanedmap_all;
185 Map cleandepsmap; /* try to drop these packages as of cleandeps erases */
187 Queue *ruleinfoq; /* tmp space for solver_ruleinfo() */
191 extern void solver_run_sat(Solver *solv, int disablerules, int doweak);
192 extern void solver_reset(Solver *solv);
194 extern int solver_dep_installed(Solver *solv, Id dep);
195 extern int solver_splitprovides(Solver *solv, Id dep);
198 solver_dep_fulfilled(Solver *solv, Id dep)
200 Pool *pool = solv->pool;
205 Reldep *rd = GETRELDEP(pool, dep);
206 if (rd->flags == REL_AND)
208 if (!solver_dep_fulfilled(solv, rd->name))
210 return solver_dep_fulfilled(solv, rd->evr);
212 if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_SPLITPROVIDES)
213 return solver_splitprovides(solv, rd->evr);
214 if (rd->flags == REL_NAMESPACE && rd->name == NAMESPACE_INSTALLED)
215 return solver_dep_installed(solv, rd->evr);
217 FOR_PROVIDES(p, pp, dep)
219 if (solv->decisionmap[p] > 0)
226 solver_is_supplementing(Solver *solv, Solvable *s)
231 supp = s->repo->idarraydata + s->supplements;
232 while ((sup = *supp++) != 0)
233 if (solver_dep_fulfilled(solv, sup))
239 solver_is_enhancing(Solver *solv, Solvable *s)
244 enhp = s->repo->idarraydata + s->enhances;
245 while ((enh = *enhp++) != 0)
246 if (solver_dep_fulfilled(solv, enh))
251 #endif /* LIBSOLV_SOLVER_P_H */