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/UpgradeStatistics.h"
23 #include "zypp/solver/detail/Resolver.h"
24 #include "zypp/solver/detail/SolverQueueItem.h"
25 #include "zypp/ProblemTypes.h"
27 ///////////////////////////////////////////////////////////////////
29 { /////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////
34 // CLASS NAME : Resolver
37 * Dependency resolver interface.
39 * To resolve dependencies after making changes to the \ref ResPool (using
40 * \ref addRequire(), \ref addConflict(), \ref applySolutions(), or by making
41 * the changes directly on the \ref PoolItem status objects,
42 * call the \ref resolvePool() method.
44 class Resolver : public base::ReferenceCounted, private base::NonCopyable
49 Resolver( const ResPool & pool );
54 * Resolve package dependencies:
56 * Enter \ref systemVerification mode to monitor and repair dependencies
57 * of already installed packages, and solve immediately.
59 * Call \ref setSystemVerification to turn of this mode.
65 * Resolve package dependencies:
67 * Try to execute all pending transactions (there may be more than
69 * The solver collects all transactions (install/delete resolvables)
70 * from the pool, generates task, solving it and writes the
71 * results back to pool
73 * Returns "true" on success (i.e., if there were no problems that
74 * need user interaction) and "false" if there were problems. In
75 * the latter case, use problems() and later applySolutions()
82 * Resolve package dependencies:
84 * The solver works off the given queue and writes back the solution
87 * Returns "true" on success (i.e., if there were no problems that
88 * need user interaction) and "false" if there were problems. In
89 * the latter case, use problems() and later applySolutions()
91 * The solution could be that the solver remove/add some entries
92 * in the task queue. So make a new call of resolveQueue after you
93 * have applied any solution AND check the parameter "queue" if
94 * there has been any changes by the solver and adapt these changes
95 * to e.g. the selectables.
98 bool resolveQueue( solver::detail::SolverQueueItemList & queue );
101 * Undo solver changes done in resolvePool()
102 * Throwing away all ignored dependencies.
107 * Resets solver information and verify option.
113 * Do an distribution upgrade
115 * Perform a distribution upgrade. This performs an update of
116 * all packages with a special resolver algorithm which takes
117 * care of package splits, pattern and product updates,
121 /** \deprecated The UpgradeStatistics argument is a meanwhile useless relict of pre-satsolver days. */
122 ZYPP_DEPRECATED bool doUpgrade( UpgradeStatistics & )
123 { return doUpgrade(); }
126 * Update to newest package
128 * Install the newest version of your installed packages as
129 * far as possible. This means a newer package will NOT be
130 * installed if it generates dependency problems.
131 * So the user will not get an error message.
138 * Unmaintained packages which does not fit to
139 * the updated system (broken dependencies) will be
141 * Return the list of deleted items.
142 * Note : This list is valid after the call doUpgrade() only.
144 std::list<PoolItem> problematicUpdateItems() const;
147 * Return the dependency problems found by the last call to
148 * resolveDependencies(). If there were no problems, the returned
149 * list will be empty.
151 ResolverProblemList problems();
155 * Apply problem solutions. No more than one solution per problem
158 void applySolutions( const ProblemSolutionList & solutions );
162 * Remove resolvables which are conflicts with others or
163 * have unfulfilled requirements.
164 * This behaviour is favourited by ZMD.
166 void setForceResolve( bool force );
170 * Ignore recommended packages that were already recommended by
171 * the installed packages
173 void setIgnoreAlreadyRecommended( bool yesno_r );
174 bool ignoreAlreadyRecommended();
177 * Setting whether required packages are installed ONLY
178 * So recommended packages, language packages and packages which depend
179 * on hardware (modalias) will not be regarded.
181 void setOnlyRequires( bool yesno_r );
182 void resetOnlyRequires(); // set back to default (described in zypp.conf)
186 * Setting whether the solver should allow or disallow vendor changes.
188 * If OFF (the default) the solver will replace packages with packages
189 * of the same (or equivalent) vendor ony.
191 * \see \ref VendorAttr for definition of vendor equivalence.
193 void setAllowVendorChange( bool yesno_r );
194 void setDefaultAllowVendorChange(); // set back to default (in zypp.conf)
195 bool allowVendorChange() const;
198 * System verification mode also monitors and repairs dependencies
199 * of already installed packages.
200 * \see \ref verifySystem
202 void setSystemVerification( bool yesno_r );
203 void setDefaultSystemVerification();
204 bool systemVerification() const;
207 * Set whether to solve source packages build dependencies per default.
208 * Usually turned off and if, enabled per source package.
209 * \NOTE This affects only source packges selected in the \ref ResPool. No solver rule
210 * will be generated for them. Source packages requested via e.g. \ref addRequire will
212 * \NOTE Be carefull. The older the source package is, the stranger may be the
213 * result of solving it's build dependencies.
215 void setSolveSrcPackages( bool yesno_r );
216 void setDefaultSolveSrcPackages();
217 bool solveSrcPackages() const;
220 * Adding additional requirement
223 void addRequire( const Capability & capability );
226 * Adding additional conflict
229 void addConflict( const Capability & capability );
232 * Remove the additional requirement set by \ref addRequire(Capability).
235 void removeRequire( const Capability & capability );
238 * Remove the additional conflict set by \ref addConflict(Capability).
241 void removeConflict( const Capability & capability );
244 * Get all the additional requirements set by \ref addRequire(Capability).
247 CapabilitySet getRequire();
250 * Get all the additional conflicts set by \ref addConflict(Capability).
253 CapabilitySet getConflict();
256 * Generates a solver Testcase of the current state
258 * \parame dumpPath destination directory of the created directory
259 * \return true if it was successful
261 bool createSolverTestcase( const std::string & dumpPath = "/var/log/YaST2/solverTestcase" );
264 * Gives information about WHO has pused an installation of an given item.
266 * \param item Evaluate additional information for this resolvable.
267 * \return A list of structures which contains:
268 * item Item which has triggered the installation of the given param item.
269 * initialInstallation This item has triggered the installation
270 * Not already fullfilled requierement only.
271 * cap Capability which has triggerd this installation
272 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
274 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
277 solver::detail::ItemCapKindList isInstalledBy( const PoolItem & item );
280 * Gives information about WHICH additional items will be installed due the installation of an item.
282 * \param item Evaluate additional information for this resolvable.
283 * \return A list of structures which contains:
284 * item Item which has triggered the installation of the given param item.
285 * initialInstallation This item has triggered the installation
286 * Not already fullfilled requierement only.
287 * cap Capability which has triggerd this installation
288 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
290 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
293 solver::detail::ItemCapKindList installs( const PoolItem & item );
296 * Gives information about WHICH installed items are requested by the installation of an item.
298 * \param item Evaluate additional information for this resolvable.
299 * \return A list of structures which contains:
300 * item Item which has triggered the installation of the given param item.
301 * initialInstallation This item has triggered the installation
302 * Not already fullfilled requierement only.
303 * cap Capability which has triggerd this installation
304 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
306 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
309 solver::detail::ItemCapKindList satifiedByInstalled( const PoolItem & item );
313 * Gives information about WHICH items require an already installed item.
315 * \param item Evaluate additional information for this resolvable.
316 * \return A list of structures which contains:
317 * item Item which has triggered the installation of the given param item.
318 * initialInstallation This item has triggered the installation
319 * Not already fullfilled requierement only.
320 * cap Capability which has triggerd this installation
321 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
323 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
326 solver::detail::ItemCapKindList installedSatisfied( const PoolItem & item );
331 solver::detail::Resolver_Ptr _pimpl;
333 ///////////////////////////////////////////////////////////////////
335 /////////////////////////////////////////////////////////////////
337 ///////////////////////////////////////////////////////////////////
338 #endif // ZYPP_RESOLVER_H