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 { /////////////////////////////////////////////////////////////////
35 ///////////////////////////////////////////////////////////////////
37 // CLASS NAME : Resolver
40 * Dependency resolver interface.
42 * To resolve dependencies after making changes to the \ref ResPool (using
43 * \ref addRequire(), \ref addConflict(), \ref applySolutions(), or by making
44 * the changes directly on the \ref PoolItem status objects,
45 * call the \ref resolvePool() method.
47 class Resolver : public base::ReferenceCounted, private base::NonCopyable
52 Resolver( const ResPool & pool );
57 * Resolve package dependencies:
59 * Enter \ref systemVerification mode to monitor and repair dependencies
60 * of already installed packages, and solve immediately.
62 * Call \ref setSystemVerification to turn of this mode.
68 * Resolve package dependencies:
70 * Try to execute all pending transactions (there may be more than
72 * The solver collects all transactions (install/delete resolvables)
73 * from the pool, generates task, solving it and writes the
74 * results back to pool
76 * Returns "true" on success (i.e., if there were no problems that
77 * need user interaction) and "false" if there were problems. In
78 * the latter case, use problems() and later applySolutions()
85 * Resolve package dependencies:
87 * The solver works off the given queue and writes back the solution
90 * Returns "true" on success (i.e., if there were no problems that
91 * need user interaction) and "false" if there were problems. In
92 * the latter case, use problems() and later applySolutions()
94 * The solution could be that the solver remove/add some entries
95 * in the task queue. So make a new call of resolveQueue after you
96 * have applied any solution AND check the parameter "queue" if
97 * there has been any changes by the solver and adapt these changes
98 * to e.g. the selectables.
101 bool resolveQueue( solver::detail::SolverQueueItemList & queue );
104 * Undo solver changes done in resolvePool()
105 * Throwing away all ignored dependencies.
110 * Resets solver information and verify option.
116 * Do an distribution upgrade (DUP)
118 * Perform a distribution upgrade. This performs an update of
119 * all packages with a special resolver algorithm which takes
120 * care of package splits, pattern and product updates,
122 * This call also turns the solver into \ref upgradeMode, so
123 * consecutive calls to \ref resolvePool performed in this
124 * mode too. Call \ref setUpgradeMode to turn this mode off.
126 * \see \ref addUpgradeRepo
131 * Update to newest package
133 * Install the newest version of your installed packages as
134 * far as possible. This means a newer package will NOT be
135 * installed if it generates dependency problems.
136 * So the user will not get an error message.
142 * Unmaintained packages which does not fit to
143 * the updated system (broken dependencies) will be
145 * Return the list of deleted items.
146 * Note : This list is valid after the call doUpgrade() only.
148 std::list<PoolItem> problematicUpdateItems() const;
151 * Return the dependency problems found by the last call to
152 * resolveDependencies(). If there were no problems, the returned
153 * list will be empty.
155 ResolverProblemList problems();
159 * Apply problem solutions. No more than one solution per problem
162 void applySolutions( const ProblemSolutionList & solutions );
165 * Return the \ref Transaction computed by the last solver run.
167 sat::Transaction getTransaction();
170 * Remove resolvables which are conflicts with others or
171 * have unfulfilled requirements.
172 * This behaviour is favourited by ZMD.
174 void setForceResolve( bool force );
175 bool forceResolve() const;
178 * Ignore recommended packages that were already recommended by
179 * the installed packages
181 void setIgnoreAlreadyRecommended( bool yesno_r );
182 bool ignoreAlreadyRecommended() const;
185 * Setting whether required packages are installed ONLY
186 * So recommended packages, language packages and packages which depend
187 * on hardware (modalias) will not be regarded.
189 void setOnlyRequires( bool yesno_r );
190 void resetOnlyRequires(); // set back to default (described in zypp.conf)
191 bool onlyRequires() const;
194 * Setting whether the solver should perform in 'upgrade' mode or
196 * \see \ref doUpgrade.
198 void setUpgradeMode( bool yesno_r );
199 bool upgradeMode() const;
202 * Setting whether the solver should allow or disallow vendor changes.
204 * If OFF (the default) the solver will replace packages with packages
205 * of the same (or equivalent) vendor ony.
207 * \see \ref VendorAttr for definition of vendor equivalence.
209 void setAllowVendorChange( bool yesno_r );
210 void setDefaultAllowVendorChange(); // set back to default (in zypp.conf)
211 bool allowVendorChange() const;
214 * System verification mode also monitors and repairs dependencies
215 * of already installed packages.
216 * \see \ref verifySystem
218 void setSystemVerification( bool yesno_r );
219 void setDefaultSystemVerification();
220 bool systemVerification() const;
223 * Set whether to solve source packages build dependencies per default.
224 * Usually turned off and if, enabled per source package.
225 * \NOTE This affects only source packges selected in the \ref ResPool. No solver rule
226 * will be generated for them. Source packages requested via e.g. \ref addRequire will
228 * \NOTE Be carefull. The older the source package is, the stranger may be the
229 * result of solving it's build dependencies.
231 void setSolveSrcPackages( bool yesno_r );
232 void setDefaultSolveSrcPackages();
233 bool solveSrcPackages() const;
236 * Cleanup when deleting packages. Whether the solver should per default
237 * try to remove packages exclusively required by the ones he's asked to delete.
239 void setCleandepsOnRemove( bool yesno_r );
240 void setDefaultCleandepsOnRemove(); // set back to default (in zypp.conf)
241 bool cleandepsOnRemove() const;
243 /** \name Solver flags for DUP mode.
244 * DUP mode default settings differ from 'ordinary' ones. Default for
245 * all DUP flags is \c true.
248 /** dup mode: allow to downgrade installed solvable */
249 void dupSetAllowDowngrade( bool yesno_r );
250 void dupSetDefaultAllowDowngrade(); // Set back to default
251 bool dupAllowDowngrade() const;
253 /** dup mode: allow to change name of installed solvable */
254 void dupSetAllowNameChange( bool yesno_r );
255 void dupSetDefaultAllowNameChange(); // Set back to default
256 bool dupAllowNameChange() const;
258 /** dup mode: allow to change architecture of installed solvables */
259 void dupSetAllowArchChange( bool yesno_r );
260 void dupSetDefaultAllowArchChange(); // Set back to default
261 bool dupAllowArchChange() const;
263 /** dup mode: allow to change vendor of installed solvables*/
264 void dupSetAllowVendorChange( bool yesno_r );
265 void dupSetDefaultAllowVendorChange(); // Set back to default
266 bool dupAllowVendorChange() const;
269 /** \name Upgrade to content of a specific repository.
270 * \note This is an ordinary solver request. You should simply
271 * \ref resolvePool to execute, and not \ref doUpgrade.
275 * Adding request to perform a dist upgrade restricted to this repository.
277 * This is what e.g. <tt>zypper dup --repo myrepo</tt> should perform.
278 * \see \ref doUpgrade
280 void addUpgradeRepo( Repository repo_r );
283 * Whether there is at least one \c UpgradeRepo request pending
285 bool upgradingRepos() const;
288 * Whether there is an \c UpgradeRepo request pending for this repo.
290 bool upgradingRepo( Repository repo_r ) const;
293 * Remove an upgrade request for this repo.
295 void removeUpgradeRepo( Repository repo_r );
298 * Remove all upgrade repo requests.
300 void removeUpgradeRepos();
304 * Adding additional requirement
307 void addRequire( const Capability & capability );
310 * Adding additional conflict
313 void addConflict( const Capability & capability );
316 * Remove the additional requirement set by \ref addRequire(Capability).
319 void removeRequire( const Capability & capability );
322 * Remove the additional conflict set by \ref addConflict(Capability).
325 void removeConflict( const Capability & capability );
328 * Get all the additional requirements set by \ref addRequire(Capability).
331 CapabilitySet getRequire() const;
334 * Get all the additional conflicts set by \ref addConflict(Capability).
337 CapabilitySet getConflict() const;
340 * Generates a solver Testcase of the current state
342 * \parame dumpPath destination directory of the created directory
343 * \return true if it was successful
345 bool createSolverTestcase( const std::string & dumpPath = "/var/log/YaST2/solverTestcase", bool runSolver = true );
348 * Gives information about WHO has pused an installation of an given item.
350 * \param item Evaluate additional information for this resolvable.
351 * \return A list of structures which contains:
352 * item Item which has triggered the installation of the given param item.
353 * initialInstallation This item has triggered the installation
354 * Not already fullfilled requierement only.
355 * cap Capability which has triggerd this installation
356 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
358 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
361 solver::detail::ItemCapKindList isInstalledBy( const PoolItem & item );
364 * Gives information about WHICH additional items will be installed due the installation of an item.
366 * \param item Evaluate additional information for this resolvable.
367 * \return A list of structures which contains:
368 * item Item which has triggered the installation of the given param item.
369 * initialInstallation This item has triggered the installation
370 * Not already fullfilled requierement only.
371 * cap Capability which has triggerd this installation
372 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
374 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
377 solver::detail::ItemCapKindList installs( const PoolItem & item );
380 * Gives information about WHICH installed items are requested by the installation of an item.
382 * \param item Evaluate additional information for this resolvable.
383 * \return A list of structures which contains:
384 * item Item which has triggered the installation of the given param item.
385 * initialInstallation This item has triggered the installation
386 * Not already fullfilled requierement only.
387 * cap Capability which has triggerd this installation
388 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
390 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
393 solver::detail::ItemCapKindList satifiedByInstalled( const PoolItem & item );
397 * Gives information about WHICH items require an already installed item.
399 * \param item Evaluate additional information for this resolvable.
400 * \return A list of structures which contains:
401 * item Item which has triggered the installation of the given param item.
402 * initialInstallation This item has triggered the installation
403 * Not already fullfilled requierement only.
404 * cap Capability which has triggerd this installation
405 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
407 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
410 solver::detail::ItemCapKindList installedSatisfied( const PoolItem & item );
414 friend std::ostream & operator<<( std::ostream & str, const Resolver & obj );
416 typedef solver::detail::Resolver Impl;
417 zypp::RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
419 ///////////////////////////////////////////////////////////////////
421 /** \relates Resolver Stream output */
422 std::ostream & operator<<( std::ostream & str, const Resolver & obj );
424 /////////////////////////////////////////////////////////////////
426 ///////////////////////////////////////////////////////////////////
427 #endif // ZYPP_RESOLVER_H