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"
26 #include "zypp/solver/detail/Types.h"
28 #include "zypp/ProblemTypes.h"
29 #include "zypp/ResolverProblem.h"
30 #include "zypp/ProblemSolution.h"
32 ///////////////////////////////////////////////////////////////////
34 { /////////////////////////////////////////////////////////////////
41 ///////////////////////////////////////////////////////////////////
43 // CLASS NAME : Resolver
46 * Dependency resolver interface.
48 * To resolve dependencies after making changes to the \ref ResPool (using
49 * \ref addRequire(), \ref addConflict(), \ref applySolutions(), or by making
50 * the changes directly on the \ref PoolItem status objects,
51 * call the \ref resolvePool() method.
53 class Resolver : public base::ReferenceCounted, private base::NonCopyable
58 Resolver( const ResPool & pool );
63 * Resolve package dependencies:
65 * Enter \ref systemVerification mode to monitor and repair dependencies
66 * of already installed packages, and solve immediately.
68 * Call \ref setSystemVerification to turn of this mode.
74 * Resolve package dependencies:
76 * Try to execute all pending transactions (there may be more than
78 * The solver collects all transactions (install/delete resolvables)
79 * from the pool, generates task, solving it and writes the
80 * results back to pool
82 * Returns "true" on success (i.e., if there were no problems that
83 * need user interaction) and "false" if there were problems. In
84 * the latter case, use problems() and later applySolutions()
91 * Resolve package dependencies:
93 * The solver works off the given queue and writes back the solution
96 * Returns "true" on success (i.e., if there were no problems that
97 * need user interaction) and "false" if there were problems. In
98 * the latter case, use problems() and later applySolutions()
100 * The solution could be that the solver remove/add some entries
101 * in the task queue. So make a new call of resolveQueue after you
102 * have applied any solution AND check the parameter "queue" if
103 * there has been any changes by the solver and adapt these changes
104 * to e.g. the selectables.
107 bool resolveQueue( solver::detail::SolverQueueItemList & queue );
110 * Undo solver changes done in resolvePool()
111 * Throwing away all ignored dependencies.
116 * Resets solver information and verify option.
122 * Do an distribution upgrade (DUP)
124 * Perform a distribution upgrade. This performs an update of
125 * all packages with a special resolver algorithm which takes
126 * care of package splits, pattern and product updates,
128 * This call also turns the solver into \ref upgradeMode, so
129 * consecutive calls to \ref resolvePool performed in this
130 * mode too. Call \ref setUpgradeMode to turn this mode off.
132 * \see \ref addUpgradeRepo
137 * Update to newest package
139 * Install the newest version of your installed packages as
140 * far as possible. This means a newer package will NOT be
141 * installed if it generates dependency problems.
142 * So the user will not get an error message.
148 * Unmaintained packages which does not fit to
149 * the updated system (broken dependencies) will be
151 * Return the list of deleted items.
152 * Note : This list is valid after the call doUpgrade() only.
154 std::list<PoolItem> problematicUpdateItems() const;
157 * Return the dependency problems found by the last call to
158 * resolveDependencies(). If there were no problems, the returned
159 * list will be empty.
161 ResolverProblemList problems();
165 * Apply problem solutions. No more than one solution per problem
168 void applySolutions( const ProblemSolutionList & solutions );
171 * Return the \ref Transaction computed by the last solver run.
173 sat::Transaction getTransaction();
176 * Remove resolvables which are conflicts with others or
177 * have unfulfilled requirements.
178 * This behaviour is favourited by ZMD.
180 void setForceResolve( bool force );
181 bool forceResolve() const;
184 * Ignore recommended packages that were already recommended by
185 * the installed packages
187 void setIgnoreAlreadyRecommended( bool yesno_r );
188 bool ignoreAlreadyRecommended() const;
191 * Setting whether required packages are installed ONLY
192 * So recommended packages, language packages and packages which depend
193 * on hardware (modalias) will not be regarded.
195 void setOnlyRequires( bool yesno_r );
196 void resetOnlyRequires(); // set back to default (described in zypp.conf)
197 bool onlyRequires() const;
200 * Setting whether the solver should perform in 'upgrade' mode or
202 * \see \ref doUpgrade.
204 void setUpgradeMode( bool yesno_r );
205 bool upgradeMode() const;
208 * Setting whether the solver should allow or disallow vendor changes.
210 * If OFF (the default) the solver will replace packages with packages
211 * of the same (or equivalent) vendor ony.
213 * \see \ref VendorAttr for definition of vendor equivalence.
215 void setAllowVendorChange( bool yesno_r );
216 void setDefaultAllowVendorChange(); // set back to default (in zypp.conf)
217 bool allowVendorChange() const;
220 * System verification mode also monitors and repairs dependencies
221 * of already installed packages.
222 * \see \ref verifySystem
224 void setSystemVerification( bool yesno_r );
225 void setDefaultSystemVerification();
226 bool systemVerification() const;
229 * Set whether to solve source packages build dependencies per default.
230 * Usually turned off and if, enabled per source package.
231 * \NOTE This affects only source packges selected in the \ref ResPool. No solver rule
232 * will be generated for them. Source packages requested via e.g. \ref addRequire will
234 * \NOTE Be carefull. The older the source package is, the stranger may be the
235 * result of solving it's build dependencies.
237 void setSolveSrcPackages( bool yesno_r );
238 void setDefaultSolveSrcPackages();
239 bool solveSrcPackages() const;
242 * Cleanup when deleting packages. Whether the solver should per default
243 * try to remove packages exclusively required by the ones he's asked to delete.
245 void setCleandepsOnRemove( bool yesno_r );
246 void setDefaultCleandepsOnRemove(); // set back to default (in zypp.conf)
247 bool cleandepsOnRemove() const;
249 /** \name Solver flags for DUP mode.
250 * DUP mode default settings differ from 'ordinary' ones. Default for
251 * all DUP flags is \c true.
254 /** dup mode: allow to downgrade installed solvable */
255 void dupSetAllowDowngrade( bool yesno_r );
256 void dupSetDefaultAllowDowngrade(); // Set back to default (in zypp.conf)
257 bool dupAllowDowngrade() const;
259 /** dup mode: allow to change name of installed solvable */
260 void dupSetAllowNameChange( bool yesno_r );
261 void dupSetDefaultAllowNameChange(); // Set back to default (in zypp.conf)
262 bool dupAllowNameChange() const;
264 /** dup mode: allow to change architecture of installed solvables */
265 void dupSetAllowArchChange( bool yesno_r );
266 void dupSetDefaultAllowArchChange(); // Set back to default (in zypp.conf)
267 bool dupAllowArchChange() const;
269 /** dup mode: allow to change vendor of installed solvables*/
270 void dupSetAllowVendorChange( bool yesno_r );
271 void dupSetDefaultAllowVendorChange(); // Set back to default (in zypp.conf)
272 bool dupAllowVendorChange() const;
275 /** \name Upgrade to content of a specific repository.
276 * \note This is an ordinary solver request. You should simply
277 * \ref resolvePool to execute, and not \ref doUpgrade.
281 * Adding request to perform a dist upgrade restricted to this repository.
283 * This is what e.g. <tt>zypper dup --repo myrepo</tt> should perform.
284 * \see \ref doUpgrade
286 void addUpgradeRepo( Repository repo_r );
289 * Whether there is at least one \c UpgradeRepo request pending
291 bool upgradingRepos() const;
294 * Whether there is an \c UpgradeRepo request pending for this repo.
296 bool upgradingRepo( Repository repo_r ) const;
299 * Remove an upgrade request for this repo.
301 void removeUpgradeRepo( Repository repo_r );
304 * Remove all upgrade repo requests.
306 void removeUpgradeRepos();
310 * Adding additional requirement
313 void addRequire( const Capability & capability );
316 * Adding additional conflict
319 void addConflict( const Capability & capability );
322 * Remove the additional requirement set by \ref addRequire(Capability).
325 void removeRequire( const Capability & capability );
328 * Remove the additional conflict set by \ref addConflict(Capability).
331 void removeConflict( const Capability & capability );
334 * Get all the additional requirements set by \ref addRequire(Capability).
337 CapabilitySet getRequire() const;
340 * Get all the additional conflicts set by \ref addConflict(Capability).
343 CapabilitySet getConflict() const;
346 * Generates a solver Testcase of the current state
348 * \parame dumpPath destination directory of the created directory
349 * \return true if it was successful
351 bool createSolverTestcase( const std::string & dumpPath = "/var/log/YaST2/solverTestcase", bool runSolver = true );
354 * Gives information about WHO has pused an installation of an given item.
356 * \param item Evaluate additional information for this resolvable.
357 * \return A list of structures which contains:
358 * item Item which has triggered the installation of the given param item.
359 * initialInstallation This item has triggered the installation
360 * Not already fullfilled requierement only.
361 * cap Capability which has triggerd this installation
362 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
364 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
367 solver::detail::ItemCapKindList isInstalledBy( const PoolItem & item );
370 * Gives information about WHICH additional items will be installed due the installation of an item.
372 * \param item Evaluate additional information for this resolvable.
373 * \return A list of structures which contains:
374 * item Item which has triggered the installation of the given param item.
375 * initialInstallation This item has triggered the installation
376 * Not already fullfilled requierement only.
377 * cap Capability which has triggerd this installation
378 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
380 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
383 solver::detail::ItemCapKindList installs( const PoolItem & item );
386 * Gives information about WHICH installed items are requested by the installation of an item.
388 * \param item Evaluate additional information for this resolvable.
389 * \return A list of structures which contains:
390 * item Item which has triggered the installation of the given param item.
391 * initialInstallation This item has triggered the installation
392 * Not already fullfilled requierement only.
393 * cap Capability which has triggerd this installation
394 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
396 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
399 solver::detail::ItemCapKindList satifiedByInstalled( const PoolItem & item );
403 * Gives information about WHICH items require an already installed item.
405 * \param item Evaluate additional information for this resolvable.
406 * \return A list of structures which contains:
407 * item Item which has triggered the installation of the given param item.
408 * initialInstallation This item has triggered the installation
409 * Not already fullfilled requierement only.
410 * cap Capability which has triggerd this installation
411 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
413 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
416 solver::detail::ItemCapKindList installedSatisfied( const PoolItem & item );
420 friend std::ostream & operator<<( std::ostream & str, const Resolver & obj );
421 zypp::RW_pointer<solver::detail::ResolverInternal> _pimpl;
423 ///////////////////////////////////////////////////////////////////
425 /** \relates Resolver Stream output */
426 std::ostream & operator<<( std::ostream & str, const Resolver & obj );
428 /////////////////////////////////////////////////////////////////
430 ///////////////////////////////////////////////////////////////////
431 #endif // ZYPP_RESOLVER_H