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/UpgradeStatistics.h"
23 #include "zypp/solver/detail/Resolver.h"
24 #include "zypp/solver/detail/SolverQueueItem.h"
25 #include "zypp/ProblemTypes.h"
27 ///////////////////////////////////////////////////////////////////
29 { /////////////////////////////////////////////////////////////////
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()
78 bool resolvePool (void);
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
115 * This will run a full upgrade on the pool, taking all upgrade
116 * dependencies (provide/obsolete for package renames, split-
117 * provides, etc.) into account and actually removing installed
118 * packages if no upgrade exists AND the package dependency is
121 * To be run with great caution. It basically brings your
122 * system 'back to start'.
123 * Quite helpful to get back to a 'sane state'. Quite disastrous
124 * since you'll loose all non-distribution packages
126 bool doUpgrade( UpgradeStatistics & opt_stats_r );
129 * Update to newest package
131 * Install the newest version of your installed packages as
132 * far as possible. This means a newer package will NOT be
133 * installed if it generates dependency problems.
134 * So the user will not get an error message.
141 * Unmaintained packages which does not fit to
142 * the updated system (broken dependencies) will be
144 * Return the list of deleted items.
145 * Note : This list is valid after the call doUpgrade() only.
147 std::list<PoolItem> problematicUpdateItems( void ) const;
150 * Return the dependency problems found by the last call to
151 * resolveDependencies(). If there were no problems, the returned
152 * list will be empty.
154 ResolverProblemList problems();
158 * Apply problem solutions. No more than one solution per problem
161 void applySolutions( const ProblemSolutionList & solutions );
165 * Remove resolvables which are conflicts with others or
166 * have unfulfilled requirements.
167 * This behaviour is favourited by ZMD.
169 void setForceResolve (const bool force);
173 * Ignore recommended packages that were already recommended by
174 * the installed packages
176 void setIgnoreAlreadyRecommended (const bool ignoreAlreadyRecommended);
177 bool ignoreAlreadyRecommended();
180 * Setting whether required packages are installed ONLY
181 * So recommended packages, language packages and packages which depend
182 * on hardware (modalias) will not be regarded.
184 void setOnlyRequires (const bool onlyRequires);
185 void resetOnlyRequires(); // set back to default (described in zypp.conf)
189 * System verification mode also monitors and repairs dependencies
190 * of already installed packages.
191 * \see \ref verifySystem
193 void setSystemVerification( bool yesno_r );
194 void setDefaultSystemVerification();
195 bool systemVerification() const;
198 * Set whether to solve source packages build dependencies per default.
199 * Usually turned off and if, enabled per source package.
200 * \NOTE This affects only source packges selected in the \ref ResPool. No solver rule
201 * will be generated for them. Source packages requested via e.g. \ref addRequire will
203 * \NOTE Be carefull. The older the source package is, the stranger may be the
204 * result of solving it's build dependencies.
206 void setSolveSrcPackages( bool yesno_r );
207 void setDefaultSolveSrcPackages();
208 bool solveSrcPackages() const;
211 * Adding additional requirement
214 void addRequire (const Capability & capability);
217 * Adding additional conflict
220 void addConflict (const Capability & capability);
223 * Remove the additional requirement set by \ref addRequire(Capability).
226 void removeRequire (const Capability & capability);
229 * Remove the additional conflict set by \ref addConflict(Capability).
232 void removeConflict (const Capability & capability);
235 * Get all the additional requirements set by \ref addRequire(Capability).
238 const CapabilitySet getRequire ();
241 * Get all the additional conflicts set by \ref addConflict(Capability).
244 const CapabilitySet getConflict();
247 * Generates a solver Testcase of the current state
249 * \parame dumpPath destination directory of the created directory
250 * \return true if it was successful
252 bool createSolverTestcase (const std::string & dumpPath = "/var/log/YaST2/solverTestcase");
255 * Gives information about WHO has pused an installation of an given item.
257 * \param item Evaluate additional information for this resolvable.
258 * \return A list of structures which contains:
259 * item Item which has triggered the installation of the given param item.
260 * cap Capability which has triggerd this installation
261 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
263 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
266 const solver::detail::ItemCapKindList isInstalledBy (const PoolItem item);
269 * Gives information about WHICH additional items will be installed due the installation of an item.
271 * \param item Evaluate additional information for this resolvable.
272 * \return A list of structures which contains:
273 * item Item which will be installed due to the installation of the given param item too.
274 * cap Capability which causes the installation
275 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
277 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
280 const solver::detail::ItemCapKindList installs (const PoolItem item);
283 * Gives information about WHICH installed items are requested by the installation of an item.
285 * \param item Evaluate additional information for this resolvable.
286 * \return A list of structures which contains:
287 * item installed Item which provide the requested capability.
288 * cap Capability which is needed
289 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
291 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
294 const solver::detail::ItemCapKindList satifiedByInstalled(const PoolItem item);
298 * Gives information about WHICH items require an already installed item.
300 * \param item Evaluate additional information for this resolvable.
301 * \return A list of structures which contains:
302 * item Item which requires this capability.
303 * cap Capability which is needed
304 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
306 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
309 const solver::detail::ItemCapKindList installedSatisfied(const PoolItem item);
314 solver::detail::Resolver_Ptr _pimpl;
316 ///////////////////////////////////////////////////////////////////
318 /////////////////////////////////////////////////////////////////
320 ///////////////////////////////////////////////////////////////////
321 #endif // ZYPP_RESOLVER_H