1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/Resolver.h
12 #ifndef ZYPP_RESOLVER_H
13 #define ZYPP_RESOLVER_H
18 #include <zypp/base/ReferenceCounted.h>
20 #include <zypp/solver/Types.h>
21 #include <zypp/solver/detail/Types.h>
23 ///////////////////////////////////////////////////////////////////
25 { /////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////
34 // CLASS NAME : Resolver
37 * Dependency resolver interface.
39 * To resolve dependencies after making changes to the \ref ResPool (using
40 * \ref addRequire(), \ref addConflict(), \ref applySolutions(), or by making
41 * the changes directly on the \ref PoolItem status objects,
42 * call the \ref resolvePool() method.
44 class Resolver : public base::ReferenceCounted, private base::NonCopyable
49 Resolver( const ResPool & pool );
54 * Resolve package dependencies:
56 * Enter \ref systemVerification mode to monitor and repair dependencies
57 * of already installed packages, and solve immediately.
59 * Call \ref setSystemVerification to turn of this mode.
65 * Resolve package dependencies:
67 * Try to execute all pending transactions (there may be more than
69 * The solver collects all transactions (install/delete resolvables)
70 * from the pool, generates task, solving it and writes the
71 * results back to pool
73 * Returns "true" on success (i.e., if there were no problems that
74 * need user interaction) and "false" if there were problems. In
75 * the latter case, use problems() and later applySolutions()
82 * Resolve package dependencies:
84 * The solver works off the given queue and writes back the solution
87 * Returns "true" on success (i.e., if there were no problems that
88 * need user interaction) and "false" if there were problems. In
89 * the latter case, use problems() and later applySolutions()
91 * The solution could be that the solver remove/add some entries
92 * in the task queue. So make a new call of resolveQueue after you
93 * have applied any solution AND check the parameter "queue" if
94 * there has been any changes by the solver and adapt these changes
95 * to e.g. the selectables.
98 bool resolveQueue( solver::detail::SolverQueueItemList & queue );
101 * Undo solver changes done in resolvePool()
102 * Throwing away all ignored dependencies.
107 * Resets solver information and verify option.
113 * Do an distribution upgrade (DUP)
115 * Perform a distribution upgrade. This performs an update of
116 * all packages with a special resolver algorithm which takes
117 * care of package splits, pattern and product updates,
119 * This call also turns the solver into \ref upgradeMode, so
120 * consecutive calls to \ref resolvePool performed in this
121 * mode too. Call \ref setUpgradeMode to turn this mode off.
123 * \see \ref addUpgradeRepo
128 * Update to newest package
130 * Install the newest version of your installed packages as
131 * far as possible. This means a newer package will NOT be
132 * installed if it generates dependency problems.
133 * So the user will not get an error message.
139 * Unmaintained packages which does not fit to
140 * the updated system (broken dependencies) will be
142 * Return the list of deleted items.
143 * Note : This list is valid after the call doUpgrade() only.
145 std::list<PoolItem> problematicUpdateItems() const;
148 * Return the dependency problems found by the last call to
149 * resolveDependencies(). If there were no problems, the returned
150 * list will be empty.
152 ResolverProblemList problems();
156 * Apply problem solutions. No more than one solution per problem
159 void applySolutions( const ProblemSolutionList & solutions );
162 * Return the \ref Transaction computed by the last solver run.
164 sat::Transaction getTransaction();
167 * Define the resolvers general attitude when resolving jobs.
168 * \see \ref ResolverFocus
170 void setFocus( ResolverFocus focus_r );
171 ResolverFocus focus() const;
174 * Remove resolvables which are conflicts with others or
175 * have unfulfilled requirements.
176 * This behaviour is favourited by ZMD.
178 void setForceResolve( bool force );
179 bool forceResolve() const;
182 * Ignore recommended packages that were already recommended by
183 * the installed packages
185 void setIgnoreAlreadyRecommended( bool yesno_r );
186 bool ignoreAlreadyRecommended() const;
189 * Setting whether required packages are installed ONLY
190 * So recommended packages, language packages and packages which depend
191 * on hardware (modalias) will not be regarded.
193 void setOnlyRequires( bool yesno_r );
194 void resetOnlyRequires(); // set back to default (described in zypp.conf)
195 bool onlyRequires() const;
198 * Setting whether the solver should perform in 'upgrade' mode or
200 * \see \ref doUpgrade.
202 void setUpgradeMode( bool yesno_r );
203 bool upgradeMode() const;
206 * Setting whether the solver should perform in 'update' mode or
207 * not. If on, it will add a resolver job to update all packages.
208 * \see \ref doUpdate.
210 void setUpdateMode( bool yesno_r );
211 bool updateMode() const;
214 /** \name Solver flags (non DUP modes)
215 * Default for all flags is \c false unless overwritten by zypp.conf.
218 /** Whether to allow to downgrade installed solvable */
219 void setAllowDowngrade( bool yesno_r );
220 void setDefaultAllowDowngrade(); // Set back to default
221 bool allowDowngrade() const;
223 /** Whether to allow to change name of installed solvable */
224 void setAllowNameChange( bool yesno_r );
225 void setDefaultAllowNameChange(); // Set back to default
226 bool allowNameChange() const;
228 /** Whether to allow to change architecture of installed solvables */
229 void setAllowArchChange( bool yesno_r );
230 void setDefaultAllowArchChange(); // Set back to default
231 bool allowArchChange() const;
233 /** Whether to allow to change vendor of installed solvables
234 * \see \ref VendorAttr for definition of vendor equivalence.
236 void setAllowVendorChange( bool yesno_r );
237 void setDefaultAllowVendorChange(); // Set back to default
238 bool allowVendorChange() const;
242 * System verification mode also monitors and repairs dependencies
243 * of already installed packages.
244 * \see \ref verifySystem
246 void setSystemVerification( bool yesno_r );
247 void setDefaultSystemVerification();
248 bool systemVerification() const;
251 * Set whether to solve source packages build dependencies per default.
252 * Usually turned off and if, enabled per source package.
253 * \NOTE This affects only source packges selected in the \ref ResPool. No solver rule
254 * will be generated for them. Source packages requested via e.g. \ref addRequire will
256 * \NOTE Be carefull. The older the source package is, the stranger may be the
257 * result of solving it's build dependencies.
259 void setSolveSrcPackages( bool yesno_r );
260 void setDefaultSolveSrcPackages();
261 bool solveSrcPackages() const;
264 * Cleanup when deleting packages. Whether the solver should per default
265 * try to remove packages exclusively required by the ones he's asked to delete.
267 void setCleandepsOnRemove( bool yesno_r );
268 void setDefaultCleandepsOnRemove(); // set back to default (in zypp.conf)
269 bool cleandepsOnRemove() const;
271 /** \name Solver flags for DUP mode.
272 * DUP mode default settings differ from 'ordinary' ones. Default for
273 * all DUP flags is \c true unless overwritten by zypp.conf.
276 /** dup mode: allow to downgrade installed solvable */
277 void dupSetAllowDowngrade( bool yesno_r );
278 void dupSetDefaultAllowDowngrade(); // Set back to default (in zypp.conf)
279 bool dupAllowDowngrade() const;
281 /** dup mode: allow to change name of installed solvable */
282 void dupSetAllowNameChange( bool yesno_r );
283 void dupSetDefaultAllowNameChange(); // Set back to default (in zypp.conf)
284 bool dupAllowNameChange() const;
286 /** dup mode: allow to change architecture of installed solvables */
287 void dupSetAllowArchChange( bool yesno_r );
288 void dupSetDefaultAllowArchChange(); // Set back to default (in zypp.conf)
289 bool dupAllowArchChange() const;
291 /** dup mode: allow to change vendor of installed solvables*/
292 void dupSetAllowVendorChange( bool yesno_r );
293 void dupSetDefaultAllowVendorChange(); // Set back to default (in zypp.conf)
294 bool dupAllowVendorChange() const;
297 /** \name Upgrade to content of a specific repository.
298 * \note This is an ordinary solver request. You should simply
299 * \ref resolvePool to execute, and not \ref doUpgrade.
303 * Adding request to perform a dist upgrade restricted to this repository.
305 * This is what e.g. <tt>zypper dup --repo myrepo</tt> should perform.
306 * \see \ref doUpgrade
308 void addUpgradeRepo( Repository repo_r );
311 * Whether there is at least one \c UpgradeRepo request pending
313 bool upgradingRepos() const;
316 * Whether there is an \c UpgradeRepo request pending for this repo.
318 bool upgradingRepo( Repository repo_r ) const;
321 * Remove an upgrade request for this repo.
323 void removeUpgradeRepo( Repository repo_r );
326 * Remove all upgrade repo requests.
328 void removeUpgradeRepos();
332 * Adding additional requirement
335 void addRequire( const Capability & capability );
338 * Adding additional conflict
341 void addConflict( const Capability & capability );
344 * Remove the additional requirement set by \ref addRequire(Capability).
347 void removeRequire( const Capability & capability );
350 * Remove the additional conflict set by \ref addConflict(Capability).
353 void removeConflict( const Capability & capability );
356 * Get all the additional requirements set by \ref addRequire(Capability).
359 CapabilitySet getRequire() const;
362 * Get all the additional conflicts set by \ref addConflict(Capability).
365 CapabilitySet getConflict() const;
368 * Generates a solver Testcase of the current state
370 * \parame dumpPath destination directory of the created directory
371 * \return true if it was successful
373 bool createSolverTestcase( const std::string & dumpPath = "/var/log/YaST2/solverTestcase", bool runSolver = true );
376 * Gives information about WHO has pused an installation of an given item.
378 * \param item Evaluate additional information for this resolvable.
379 * \return A list of structures which contains:
380 * item Item which has triggered the installation of the given param item.
381 * initialInstallation This item has triggered the installation
382 * Not already fullfilled requierement only.
383 * cap Capability which has triggerd this installation
384 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
386 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
389 solver::detail::ItemCapKindList isInstalledBy( const PoolItem & item );
392 * Gives information about WHICH additional items will be installed due the installation of an item.
394 * \param item Evaluate additional information for this resolvable.
395 * \return A list of structures which contains:
396 * item Item which has triggered the installation of the given param item.
397 * initialInstallation This item has triggered the installation
398 * Not already fullfilled requierement only.
399 * cap Capability which has triggerd this installation
400 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
402 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
405 solver::detail::ItemCapKindList installs( const PoolItem & item );
408 * Gives information about WHICH installed items are requested by the installation of an item.
410 * \param item Evaluate additional information for this resolvable.
411 * \return A list of structures which contains:
412 * item Item which has triggered the installation of the given param item.
413 * initialInstallation This item has triggered the installation
414 * Not already fullfilled requierement only.
415 * cap Capability which has triggerd this installation
416 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
418 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
421 solver::detail::ItemCapKindList satifiedByInstalled( const PoolItem & item );
425 * Gives information about WHICH items require an already installed item.
427 * \param item Evaluate additional information for this resolvable.
428 * \return A list of structures which contains:
429 * item Item which has triggered the installation of the given param item.
430 * initialInstallation This item has triggered the installation
431 * Not already fullfilled requierement only.
432 * cap Capability which has triggerd this installation
433 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
435 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
438 solver::detail::ItemCapKindList installedSatisfied( const PoolItem & item );
442 friend std::ostream & operator<<( std::ostream & str, const Resolver & obj );
443 zypp::RW_pointer<solver::detail::ResolverInternal> _pimpl;
445 ///////////////////////////////////////////////////////////////////
447 /** \relates Resolver Stream output */
448 std::ostream & operator<<( std::ostream & str, const Resolver & obj );
450 /////////////////////////////////////////////////////////////////
452 ///////////////////////////////////////////////////////////////////
453 #endif // ZYPP_RESOLVER_H