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/PoolItem.h"
23 #include "zypp/Capabilities.h"
24 #include "zypp/Capability.h"
25 #include "zypp/ResolverNamespace.h"
27 #include "zypp/solver/detail/Types.h"
29 #include "zypp/ProblemTypes.h"
30 #include "zypp/ResolverProblem.h"
31 #include "zypp/ProblemSolution.h"
33 ///////////////////////////////////////////////////////////////////
35 { /////////////////////////////////////////////////////////////////
42 ///////////////////////////////////////////////////////////////////
44 // CLASS NAME : Resolver
47 * Dependency resolver interface.
49 * To resolve dependencies after making changes to the \ref ResPool (using
50 * \ref addRequire(), \ref addConflict(), \ref applySolutions(), or by making
51 * the changes directly on the \ref PoolItem status objects,
52 * call the \ref resolvePool() method.
54 class Resolver : public base::ReferenceCounted, private base::NonCopyable
59 Resolver( const ResPool & pool );
64 * Resolve package dependencies:
66 * Enter \ref systemVerification mode to monitor and repair dependencies
67 * of already installed packages, and solve immediately.
69 * Call \ref setSystemVerification to turn of this mode.
75 * Resolve package dependencies:
77 * Try to execute all pending transactions (there may be more than
79 * The solver collects all transactions (install/delete resolvables)
80 * from the pool, generates task, solving it and writes the
81 * results back to pool
83 * Returns "true" on success (i.e., if there were no problems that
84 * need user interaction) and "false" if there were problems. In
85 * the latter case, use problems() and later applySolutions()
92 * Resolve package dependencies:
94 * The solver works off the given queue and writes back the solution
97 * Returns "true" on success (i.e., if there were no problems that
98 * need user interaction) and "false" if there were problems. In
99 * the latter case, use problems() and later applySolutions()
101 * The solution could be that the solver remove/add some entries
102 * in the task queue. So make a new call of resolveQueue after you
103 * have applied any solution AND check the parameter "queue" if
104 * there has been any changes by the solver and adapt these changes
105 * to e.g. the selectables.
108 bool resolveQueue( solver::detail::SolverQueueItemList & queue );
111 * Undo solver changes done in resolvePool()
112 * Throwing away all ignored dependencies.
117 * Resets solver information and verify option.
123 * Do an distribution upgrade (DUP)
125 * Perform a distribution upgrade. This performs an update of
126 * all packages with a special resolver algorithm which takes
127 * care of package splits, pattern and product updates,
129 * This call also turns the solver into \ref upgradeMode, so
130 * consecutive calls to \ref resolvePool performed in this
131 * mode too. Call \ref setUpgradeMode to turn this mode off.
133 * \see \ref addUpgradeRepo
138 * Update to newest package
140 * Install the newest version of your installed packages as
141 * far as possible. This means a newer package will NOT be
142 * installed if it generates dependency problems.
143 * So the user will not get an error message.
149 * Unmaintained packages which does not fit to
150 * the updated system (broken dependencies) will be
152 * Return the list of deleted items.
153 * Note : This list is valid after the call doUpgrade() only.
155 std::list<PoolItem> problematicUpdateItems() const;
158 * Return the dependency problems found by the last call to
159 * resolveDependencies(). If there were no problems, the returned
160 * list will be empty.
162 ResolverProblemList problems();
166 * Apply problem solutions. No more than one solution per problem
169 void applySolutions( const ProblemSolutionList & solutions );
172 * Return the \ref Transaction computed by the last solver run.
174 sat::Transaction getTransaction();
177 * Remove resolvables which are conflicts with others or
178 * have unfulfilled requirements.
179 * This behaviour is favourited by ZMD.
181 void setForceResolve( bool force );
182 bool forceResolve() const;
185 * Ignore recommended packages that were already recommended by
186 * the installed packages
188 void setIgnoreAlreadyRecommended( bool yesno_r );
189 bool ignoreAlreadyRecommended() const;
192 * Setting whether required packages are installed ONLY
193 * So recommended packages, language packages and packages which depend
194 * on hardware (modalias) will not be regarded.
196 void setOnlyRequires( bool yesno_r );
197 void resetOnlyRequires(); // set back to default (described in zypp.conf)
198 bool onlyRequires() const;
201 * Setting whether the solver should perform in 'upgrade' mode or
203 * \see \ref doUpgrade.
205 void setUpgradeMode( bool yesno_r );
206 bool upgradeMode() const;
209 * Setting whether the solver should perform in 'update' mode or
210 * not. If on, it will add a resolver job to update all packages.
211 * \see \ref doUpdate.
213 void setUpdateMode( bool yesno_r );
214 bool updateMode() const;
217 /** \name Solver flags (non DUP modes)
218 * Default for all flags is \c false unless overwritten by zypp.conf.
221 /** Whether to allow to downgrade installed solvable */
222 void setAllowDowngrade( bool yesno_r );
223 void setDefaultAllowDowngrade(); // Set back to default
224 bool allowDowngrade() const;
226 /** Whether to allow to change name of installed solvable */
227 void setAllowNameChange( bool yesno_r );
228 void setDefaultAllowNameChange(); // Set back to default
229 bool allowNameChange() const;
231 /** Whether to allow to change architecture of installed solvables */
232 void setAllowArchChange( bool yesno_r );
233 void setDefaultAllowArchChange(); // Set back to default
234 bool allowArchChange() const;
236 /** Whether to allow to change vendor of installed solvables
237 * \see \ref VendorAttr for definition of vendor equivalence.
239 void setAllowVendorChange( bool yesno_r );
240 void setDefaultAllowVendorChange(); // Set back to default
241 bool allowVendorChange() const;
245 * System verification mode also monitors and repairs dependencies
246 * of already installed packages.
247 * \see \ref verifySystem
249 void setSystemVerification( bool yesno_r );
250 void setDefaultSystemVerification();
251 bool systemVerification() const;
254 * Set whether to solve source packages build dependencies per default.
255 * Usually turned off and if, enabled per source package.
256 * \NOTE This affects only source packges selected in the \ref ResPool. No solver rule
257 * will be generated for them. Source packages requested via e.g. \ref addRequire will
259 * \NOTE Be carefull. The older the source package is, the stranger may be the
260 * result of solving it's build dependencies.
262 void setSolveSrcPackages( bool yesno_r );
263 void setDefaultSolveSrcPackages();
264 bool solveSrcPackages() const;
267 * Cleanup when deleting packages. Whether the solver should per default
268 * try to remove packages exclusively required by the ones he's asked to delete.
270 void setCleandepsOnRemove( bool yesno_r );
271 void setDefaultCleandepsOnRemove(); // set back to default (in zypp.conf)
272 bool cleandepsOnRemove() const;
274 /** \name Solver flags for DUP mode.
275 * DUP mode default settings differ from 'ordinary' ones. Default for
276 * all DUP flags is \c true unless overwritten by zypp.conf.
279 /** dup mode: allow to downgrade installed solvable */
280 void dupSetAllowDowngrade( bool yesno_r );
281 void dupSetDefaultAllowDowngrade(); // Set back to default (in zypp.conf)
282 bool dupAllowDowngrade() const;
284 /** dup mode: allow to change name of installed solvable */
285 void dupSetAllowNameChange( bool yesno_r );
286 void dupSetDefaultAllowNameChange(); // Set back to default (in zypp.conf)
287 bool dupAllowNameChange() const;
289 /** dup mode: allow to change architecture of installed solvables */
290 void dupSetAllowArchChange( bool yesno_r );
291 void dupSetDefaultAllowArchChange(); // Set back to default (in zypp.conf)
292 bool dupAllowArchChange() const;
294 /** dup mode: allow to change vendor of installed solvables*/
295 void dupSetAllowVendorChange( bool yesno_r );
296 void dupSetDefaultAllowVendorChange(); // Set back to default (in zypp.conf)
297 bool dupAllowVendorChange() const;
300 /** \name Upgrade to content of a specific repository.
301 * \note This is an ordinary solver request. You should simply
302 * \ref resolvePool to execute, and not \ref doUpgrade.
306 * Adding request to perform a dist upgrade restricted to this repository.
308 * This is what e.g. <tt>zypper dup --repo myrepo</tt> should perform.
309 * \see \ref doUpgrade
311 void addUpgradeRepo( Repository repo_r );
314 * Whether there is at least one \c UpgradeRepo request pending
316 bool upgradingRepos() const;
319 * Whether there is an \c UpgradeRepo request pending for this repo.
321 bool upgradingRepo( Repository repo_r ) const;
324 * Remove an upgrade request for this repo.
326 void removeUpgradeRepo( Repository repo_r );
329 * Remove all upgrade repo requests.
331 void removeUpgradeRepos();
335 * Adding additional requirement
338 void addRequire( const Capability & capability );
341 * Adding additional conflict
344 void addConflict( const Capability & capability );
347 * Remove the additional requirement set by \ref addRequire(Capability).
350 void removeRequire( const Capability & capability );
353 * Remove the additional conflict set by \ref addConflict(Capability).
356 void removeConflict( const Capability & capability );
359 * Get all the additional requirements set by \ref addRequire(Capability).
362 CapabilitySet getRequire() const;
365 * Get all the additional conflicts set by \ref addConflict(Capability).
368 CapabilitySet getConflict() const;
371 * Generates a solver Testcase of the current state
373 * \parame dumpPath destination directory of the created directory
374 * \return true if it was successful
376 bool createSolverTestcase( const std::string & dumpPath = "/var/log/YaST2/solverTestcase", bool runSolver = true );
379 * Gives information about WHO has pused an installation of an given item.
381 * \param item Evaluate additional information for this resolvable.
382 * \return A list of structures which contains:
383 * item Item which has triggered the installation of the given param item.
384 * initialInstallation This item has triggered the installation
385 * Not already fullfilled requierement only.
386 * cap Capability which has triggerd this installation
387 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
389 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
392 solver::detail::ItemCapKindList isInstalledBy( const PoolItem & item );
395 * Gives information about WHICH additional items will be installed due the installation of an item.
397 * \param item Evaluate additional information for this resolvable.
398 * \return A list of structures which contains:
399 * item Item which has triggered the installation of the given param item.
400 * initialInstallation This item has triggered the installation
401 * Not already fullfilled requierement only.
402 * cap Capability which has triggerd this installation
403 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
405 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
408 solver::detail::ItemCapKindList installs( const PoolItem & item );
411 * Gives information about WHICH installed items are requested by the installation of an item.
413 * \param item Evaluate additional information for this resolvable.
414 * \return A list of structures which contains:
415 * item Item which has triggered the installation of the given param item.
416 * initialInstallation This item has triggered the installation
417 * Not already fullfilled requierement only.
418 * cap Capability which has triggerd this installation
419 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
421 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
424 solver::detail::ItemCapKindList satifiedByInstalled( const PoolItem & item );
428 * Gives information about WHICH items require an already installed item.
430 * \param item Evaluate additional information for this resolvable.
431 * \return A list of structures which contains:
432 * item Item which has triggered the installation of the given param item.
433 * initialInstallation This item has triggered the installation
434 * Not already fullfilled requierement only.
435 * cap Capability which has triggerd this installation
436 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
438 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
441 solver::detail::ItemCapKindList installedSatisfied( const PoolItem & item );
445 friend std::ostream & operator<<( std::ostream & str, const Resolver & obj );
446 zypp::RW_pointer<solver::detail::ResolverInternal> _pimpl;
448 ///////////////////////////////////////////////////////////////////
450 /** \relates Resolver Stream output */
451 std::ostream & operator<<( std::ostream & str, const Resolver & obj );
453 /////////////////////////////////////////////////////////////////
455 ///////////////////////////////////////////////////////////////////
456 #endif // ZYPP_RESOLVER_H