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
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 Upgrade to content of a specific repository.
244 * \note This is an ordinary solver request. You should simply
245 * \ref resolvePool to execute, and not \ref doUpgrade.
249 * Adding request to perform a dist upgrade restricted to this repository.
251 * This is what e.g. <tt>zypper dup --repo myrepo</tt> should perform.
252 * \see \ref doUpgrade
254 void addUpgradeRepo( Repository repo_r );
257 * Whether there is an \c UpgradeRepo request pending for this repo.
259 bool upgradingRepo( Repository repo_r ) const;
262 * Remove an upgrade request for this repo.
264 void removeUpgradeRepo( Repository repo_r );
267 * Remove all upgrade repo requests.
269 void removeUpgradeRepos();
273 * Adding additional requirement
276 void addRequire( const Capability & capability );
279 * Adding additional conflict
282 void addConflict( const Capability & capability );
285 * Remove the additional requirement set by \ref addRequire(Capability).
288 void removeRequire( const Capability & capability );
291 * Remove the additional conflict set by \ref addConflict(Capability).
294 void removeConflict( const Capability & capability );
297 * Get all the additional requirements set by \ref addRequire(Capability).
300 CapabilitySet getRequire() const;
303 * Get all the additional conflicts set by \ref addConflict(Capability).
306 CapabilitySet getConflict() const;
309 * Generates a solver Testcase of the current state
311 * \parame dumpPath destination directory of the created directory
312 * \return true if it was successful
314 bool createSolverTestcase( const std::string & dumpPath = "/var/log/YaST2/solverTestcase", bool runSolver = true );
317 * Gives information about WHO has pused an installation of an given item.
319 * \param item Evaluate additional information for this resolvable.
320 * \return A list of structures which contains:
321 * item Item which has triggered the installation of the given param item.
322 * initialInstallation This item has triggered the installation
323 * Not already fullfilled requierement only.
324 * cap Capability which has triggerd this installation
325 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
327 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
330 solver::detail::ItemCapKindList isInstalledBy( const PoolItem & item );
333 * Gives information about WHICH additional items will be installed due the installation of an item.
335 * \param item Evaluate additional information for this resolvable.
336 * \return A list of structures which contains:
337 * item Item which has triggered the installation of the given param item.
338 * initialInstallation This item has triggered the installation
339 * Not already fullfilled requierement only.
340 * cap Capability which has triggerd this installation
341 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
343 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
346 solver::detail::ItemCapKindList installs( const PoolItem & item );
349 * Gives information about WHICH installed items are requested by the installation of an item.
351 * \param item Evaluate additional information for this resolvable.
352 * \return A list of structures which contains:
353 * item Item which has triggered the installation of the given param item.
354 * initialInstallation This item has triggered the installation
355 * Not already fullfilled requierement only.
356 * cap Capability which has triggerd this installation
357 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
359 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
362 solver::detail::ItemCapKindList satifiedByInstalled( const PoolItem & item );
366 * Gives information about WHICH items require an already installed item.
368 * \param item Evaluate additional information for this resolvable.
369 * \return A list of structures which contains:
370 * item Item which has triggered the installation of the given param item.
371 * initialInstallation This item has triggered the installation
372 * Not already fullfilled requierement only.
373 * cap Capability which has triggerd this installation
374 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
376 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
379 solver::detail::ItemCapKindList installedSatisfied( const PoolItem & item );
383 friend std::ostream & operator<<( std::ostream & str, const Resolver & obj );
385 typedef solver::detail::Resolver Impl;
386 zypp::RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
388 ///////////////////////////////////////////////////////////////////
390 /** \relates Resolver Stream output */
391 std::ostream & operator<<( std::ostream & str, const Resolver & obj );
393 /////////////////////////////////////////////////////////////////
395 ///////////////////////////////////////////////////////////////////
396 #endif // ZYPP_RESOLVER_H