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 * Weak form of \ref ignoreAlreadyRecommended \c =false.
193 * Try to re-evaluate recommendations for specific namespaces only.
194 * \note May not support all namespaces.
196 void setInr( ResolverNamespaces namespaces_r );
198 ResolverNamespaces inr() const;
201 * Setting whether required packages are installed ONLY
202 * So recommended packages, language packages and packages which depend
203 * on hardware (modalias) will not be regarded.
205 void setOnlyRequires( bool yesno_r );
206 void resetOnlyRequires(); // set back to default (described in zypp.conf)
207 bool onlyRequires() const;
210 * Setting whether the solver should perform in 'upgrade' mode or
212 * \see \ref doUpgrade.
214 void setUpgradeMode( bool yesno_r );
215 bool upgradeMode() const;
218 * Setting whether the solver should perform in 'update' mode or
219 * not. If on, it will add a resolver job to update all packages.
220 * \see \ref doUpdate.
222 void setUpdateMode( bool yesno_r );
223 bool updateMode() const;
226 /** \name Solver flags (non DUP modes)
227 * Default for all flags is \c false unless overwritten by zypp.conf.
230 /** Whether to allow to downgrade installed solvable */
231 void setAllowDowngrade( bool yesno_r );
232 void setDefaultAllowDowngrade(); // Set back to default
233 bool allowDowngrade() const;
235 /** Whether to allow to change name of installed solvable */
236 void setAllowNameChange( bool yesno_r );
237 void setDefaultAllowNameChange(); // Set back to default
238 bool allowNameChange() const;
240 /** Whether to allow to change architecture of installed solvables */
241 void setAllowArchChange( bool yesno_r );
242 void setDefaultAllowArchChange(); // Set back to default
243 bool allowArchChange() const;
245 /** Whether to allow to change vendor of installed solvables
246 * \see \ref VendorAttr for definition of vendor equivalence.
248 void setAllowVendorChange( bool yesno_r );
249 void setDefaultAllowVendorChange(); // Set back to default
250 bool allowVendorChange() const;
254 * System verification mode also monitors and repairs dependencies
255 * of already installed packages.
256 * \see \ref verifySystem
258 void setSystemVerification( bool yesno_r );
259 void setDefaultSystemVerification();
260 bool systemVerification() const;
263 * Set whether to solve source packages build dependencies per default.
264 * Usually turned off and if, enabled per source package.
265 * \NOTE This affects only source packges selected in the \ref ResPool. No solver rule
266 * will be generated for them. Source packages requested via e.g. \ref addRequire will
268 * \NOTE Be carefull. The older the source package is, the stranger may be the
269 * result of solving it's build dependencies.
271 void setSolveSrcPackages( bool yesno_r );
272 void setDefaultSolveSrcPackages();
273 bool solveSrcPackages() const;
276 * Cleanup when deleting packages. Whether the solver should per default
277 * try to remove packages exclusively required by the ones he's asked to delete.
279 void setCleandepsOnRemove( bool yesno_r );
280 void setDefaultCleandepsOnRemove(); // set back to default (in zypp.conf)
281 bool cleandepsOnRemove() const;
283 /** \name Solver flags for DUP mode.
284 * DUP mode default settings differ from 'ordinary' ones. Default for
285 * all DUP flags is \c true unless overwritten by zypp.conf.
288 /** dup mode: allow to downgrade installed solvable */
289 void dupSetAllowDowngrade( bool yesno_r );
290 void dupSetDefaultAllowDowngrade(); // Set back to default (in zypp.conf)
291 bool dupAllowDowngrade() const;
293 /** dup mode: allow to change name of installed solvable */
294 void dupSetAllowNameChange( bool yesno_r );
295 void dupSetDefaultAllowNameChange(); // Set back to default (in zypp.conf)
296 bool dupAllowNameChange() const;
298 /** dup mode: allow to change architecture of installed solvables */
299 void dupSetAllowArchChange( bool yesno_r );
300 void dupSetDefaultAllowArchChange(); // Set back to default (in zypp.conf)
301 bool dupAllowArchChange() const;
303 /** dup mode: allow to change vendor of installed solvables*/
304 void dupSetAllowVendorChange( bool yesno_r );
305 void dupSetDefaultAllowVendorChange(); // Set back to default (in zypp.conf)
306 bool dupAllowVendorChange() const;
309 /** \name Upgrade to content of a specific repository.
310 * \note This is an ordinary solver request. You should simply
311 * \ref resolvePool to execute, and not \ref doUpgrade.
315 * Adding request to perform a dist upgrade restricted to this repository.
317 * This is what e.g. <tt>zypper dup --repo myrepo</tt> should perform.
318 * \see \ref doUpgrade
320 void addUpgradeRepo( Repository repo_r );
323 * Whether there is at least one \c UpgradeRepo request pending
325 bool upgradingRepos() const;
328 * Whether there is an \c UpgradeRepo request pending for this repo.
330 bool upgradingRepo( Repository repo_r ) const;
333 * Remove an upgrade request for this repo.
335 void removeUpgradeRepo( Repository repo_r );
338 * Remove all upgrade repo requests.
340 void removeUpgradeRepos();
344 * Adding additional requirement
347 void addRequire( const Capability & capability );
350 * Adding additional conflict
353 void addConflict( const Capability & capability );
356 * Remove the additional requirement set by \ref addRequire(Capability).
359 void removeRequire( const Capability & capability );
362 * Remove the additional conflict set by \ref addConflict(Capability).
365 void removeConflict( const Capability & capability );
368 * Get all the additional requirements set by \ref addRequire(Capability).
371 CapabilitySet getRequire() const;
374 * Get all the additional conflicts set by \ref addConflict(Capability).
377 CapabilitySet getConflict() const;
380 * Generates a solver Testcase of the current state
382 * \parame dumpPath destination directory of the created directory
383 * \return true if it was successful
385 bool createSolverTestcase( const std::string & dumpPath = "/var/log/YaST2/solverTestcase", bool runSolver = true );
388 * Gives information about WHO has pused an installation of an given item.
390 * \param item Evaluate additional information for this resolvable.
391 * \return A list of structures which contains:
392 * item Item which has triggered the installation of the given param item.
393 * initialInstallation This item has triggered the installation
394 * Not already fullfilled requierement only.
395 * cap Capability which has triggerd this installation
396 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
398 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
401 solver::detail::ItemCapKindList isInstalledBy( const PoolItem & item );
404 * Gives information about WHICH additional items will be installed due the installation of an item.
406 * \param item Evaluate additional information for this resolvable.
407 * \return A list of structures which contains:
408 * item Item which has triggered the installation of the given param item.
409 * initialInstallation This item has triggered the installation
410 * Not already fullfilled requierement only.
411 * cap Capability which has triggerd this installation
412 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
414 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
417 solver::detail::ItemCapKindList installs( const PoolItem & item );
420 * Gives information about WHICH installed items are requested by the installation of an item.
422 * \param item Evaluate additional information for this resolvable.
423 * \return A list of structures which contains:
424 * item Item which has triggered the installation of the given param item.
425 * initialInstallation This item has triggered the installation
426 * Not already fullfilled requierement only.
427 * cap Capability which has triggerd this installation
428 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
430 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
433 solver::detail::ItemCapKindList satifiedByInstalled( const PoolItem & item );
437 * Gives information about WHICH items require an already installed item.
439 * \param item Evaluate additional information for this resolvable.
440 * \return A list of structures which contains:
441 * item Item which has triggered the installation of the given param item.
442 * initialInstallation This item has triggered the installation
443 * Not already fullfilled requierement only.
444 * cap Capability which has triggerd this installation
445 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
447 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
450 solver::detail::ItemCapKindList installedSatisfied( const PoolItem & item );
454 friend std::ostream & operator<<( std::ostream & str, const Resolver & obj );
455 zypp::RW_pointer<solver::detail::ResolverInternal> _pimpl;
457 ///////////////////////////////////////////////////////////////////
459 /** \relates Resolver Stream output */
460 std::ostream & operator<<( std::ostream & str, const Resolver & obj );
462 /////////////////////////////////////////////////////////////////
464 ///////////////////////////////////////////////////////////////////
465 #endif // ZYPP_RESOLVER_H