1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/Resolver.h
12 #ifndef ZYPP_RESOLVER_H
13 #define ZYPP_RESOLVER_H
18 #include "zypp/base/ReferenceCounted.h"
19 #include "zypp/base/PtrTypes.h"
21 #include "zypp/ResPool.h"
22 #include "zypp/solver/detail/Resolver.h"
23 #include "zypp/solver/detail/SolverQueueItem.h"
24 #include "zypp/ProblemTypes.h"
26 ///////////////////////////////////////////////////////////////////
28 { /////////////////////////////////////////////////////////////////
31 ///////////////////////////////////////////////////////////////////
33 // CLASS NAME : Resolver
36 * Dependency resolver interface.
38 * To resolve dependencies after making changes to the \ref ResPool (using
39 * \ref addRequire(), \ref addConflict(), \ref applySolutions(), or by making
40 * the changes directly on the \ref PoolItem status objects,
41 * call the \ref resolvePool() method.
43 class Resolver : public base::ReferenceCounted, private base::NonCopyable
48 Resolver( const ResPool & pool );
53 * Resolve package dependencies:
55 * Enter \ref systemVerification mode to monitor and repair dependencies
56 * of already installed packages, and solve immediately.
58 * Call \ref setSystemVerification to turn of this mode.
64 * Resolve package dependencies:
66 * Try to execute all pending transactions (there may be more than
68 * The solver collects all transactions (install/delete resolvables)
69 * from the pool, generates task, solving it and writes the
70 * results back to pool
72 * Returns "true" on success (i.e., if there were no problems that
73 * need user interaction) and "false" if there were problems. In
74 * the latter case, use problems() and later applySolutions()
81 * Resolve package dependencies:
83 * The solver works off the given queue and writes back the solution
86 * Returns "true" on success (i.e., if there were no problems that
87 * need user interaction) and "false" if there were problems. In
88 * the latter case, use problems() and later applySolutions()
90 * The solution could be that the solver remove/add some entries
91 * in the task queue. So make a new call of resolveQueue after you
92 * have applied any solution AND check the parameter "queue" if
93 * there has been any changes by the solver and adapt these changes
94 * to e.g. the selectables.
97 bool resolveQueue( solver::detail::SolverQueueItemList & queue );
100 * Undo solver changes done in resolvePool()
101 * Throwing away all ignored dependencies.
106 * Resets solver information and verify option.
112 * Do an distribution upgrade
114 * Perform a distribution upgrade. This performs an update of
115 * all packages with a special resolver algorithm which takes
116 * care of package splits, pattern and product updates,
122 * Update to newest package
124 * Install the newest version of your installed packages as
125 * far as possible. This means a newer package will NOT be
126 * installed if it generates dependency problems.
127 * So the user will not get an error message.
134 * Unmaintained packages which does not fit to
135 * the updated system (broken dependencies) will be
137 * Return the list of deleted items.
138 * Note : This list is valid after the call doUpgrade() only.
140 std::list<PoolItem> problematicUpdateItems() const;
143 * Return the dependency problems found by the last call to
144 * resolveDependencies(). If there were no problems, the returned
145 * list will be empty.
147 ResolverProblemList problems();
151 * Apply problem solutions. No more than one solution per problem
154 void applySolutions( const ProblemSolutionList & solutions );
158 * Remove resolvables which are conflicts with others or
159 * have unfulfilled requirements.
160 * This behaviour is favourited by ZMD.
162 void setForceResolve( bool force );
166 * Ignore recommended packages that were already recommended by
167 * the installed packages
169 void setIgnoreAlreadyRecommended( bool yesno_r );
170 bool ignoreAlreadyRecommended();
173 * Setting whether required packages are installed ONLY
174 * So recommended packages, language packages and packages which depend
175 * on hardware (modalias) will not be regarded.
177 void setOnlyRequires( bool yesno_r );
178 void resetOnlyRequires(); // set back to default (described in zypp.conf)
182 * Setting whether the solver should allow or disallow vendor changes.
184 * If OFF (the default) the solver will replace packages with packages
185 * of the same (or equivalent) vendor ony.
187 * \see \ref VendorAttr for definition of vendor equivalence.
189 void setAllowVendorChange( bool yesno_r );
190 void setDefaultAllowVendorChange(); // set back to default (in zypp.conf)
191 bool allowVendorChange() const;
194 * System verification mode also monitors and repairs dependencies
195 * of already installed packages.
196 * \see \ref verifySystem
198 void setSystemVerification( bool yesno_r );
199 void setDefaultSystemVerification();
200 bool systemVerification() const;
203 * Set whether to solve source packages build dependencies per default.
204 * Usually turned off and if, enabled per source package.
205 * \NOTE This affects only source packges selected in the \ref ResPool. No solver rule
206 * will be generated for them. Source packages requested via e.g. \ref addRequire will
208 * \NOTE Be carefull. The older the source package is, the stranger may be the
209 * result of solving it's build dependencies.
211 void setSolveSrcPackages( bool yesno_r );
212 void setDefaultSolveSrcPackages();
213 bool solveSrcPackages() const;
216 * Adding additional requirement
219 void addRequire( const Capability & capability );
222 * Adding additional conflict
225 void addConflict( const Capability & capability );
228 * Remove the additional requirement set by \ref addRequire(Capability).
231 void removeRequire( const Capability & capability );
234 * Remove the additional conflict set by \ref addConflict(Capability).
237 void removeConflict( const Capability & capability );
240 * Get all the additional requirements set by \ref addRequire(Capability).
243 CapabilitySet getRequire();
246 * Get all the additional conflicts set by \ref addConflict(Capability).
249 CapabilitySet getConflict();
252 * Generates a solver Testcase of the current state
254 * \parame dumpPath destination directory of the created directory
255 * \return true if it was successful
257 bool createSolverTestcase( const std::string & dumpPath = "/var/log/YaST2/solverTestcase" );
260 * Gives information about WHO has pused an installation of an given item.
262 * \param item Evaluate additional information for this resolvable.
263 * \return A list of structures which contains:
264 * item Item which has triggered the installation of the given param item.
265 * initialInstallation This item has triggered the installation
266 * Not already fullfilled requierement only.
267 * cap Capability which has triggerd this installation
268 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
270 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
273 solver::detail::ItemCapKindList isInstalledBy( const PoolItem & item );
276 * Gives information about WHICH additional items will be installed due the installation of an item.
278 * \param item Evaluate additional information for this resolvable.
279 * \return A list of structures which contains:
280 * item Item which has triggered the installation of the given param item.
281 * initialInstallation This item has triggered the installation
282 * Not already fullfilled requierement only.
283 * cap Capability which has triggerd this installation
284 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
286 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
289 solver::detail::ItemCapKindList installs( const PoolItem & item );
292 * Gives information about WHICH installed items are requested by the installation of an item.
294 * \param item Evaluate additional information for this resolvable.
295 * \return A list of structures which contains:
296 * item Item which has triggered the installation of the given param item.
297 * initialInstallation This item has triggered the installation
298 * Not already fullfilled requierement only.
299 * cap Capability which has triggerd this installation
300 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
302 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
305 solver::detail::ItemCapKindList satifiedByInstalled( const PoolItem & item );
309 * Gives information about WHICH items require an already installed item.
311 * \param item Evaluate additional information for this resolvable.
312 * \return A list of structures which contains:
313 * item Item which has triggered the installation of the given param item.
314 * initialInstallation This item has triggered the installation
315 * Not already fullfilled requierement only.
316 * cap Capability which has triggerd this installation
317 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
319 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
322 solver::detail::ItemCapKindList installedSatisfied( const PoolItem & item );
327 solver::detail::Resolver_Ptr _pimpl;
329 ///////////////////////////////////////////////////////////////////
331 /////////////////////////////////////////////////////////////////
333 ///////////////////////////////////////////////////////////////////
334 #endif // ZYPP_RESOLVER_H