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/ResolverContext.h"
25 #include "zypp/ProblemTypes.h"
27 ///////////////////////////////////////////////////////////////////
29 { /////////////////////////////////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////
35 // CLASS NAME : Resolver
37 /** Resolver interface.
39 class Resolver : public base::ReferenceCounted, private base::NonCopyable
44 Resolver( const ResPool & pool );
49 * Resolve package dependencies:
51 * Verify consistency of system
57 * Resolve package dependencies:
59 * Verify consistency of system
60 * considerNewHardware = install packages which depends on
64 bool verifySystem (bool considerNewHardware);
67 * Establish state of 'higher level' Resolvables in Pool
69 * Must be called when dealing with non-package resolvables,
70 * like Patches, Patterns, and Products
72 * Must be called with a 'plain' pool, e.g. no additonal
75 * return true if it was successful
76 * return false if not (this will only happen if other
77 * transactions are in the pool which will lead to
80 bool establishPool (void);
83 * go through all package 'freshen' dependencies and
84 * schedule matches for installation.
86 * To be called at begin of installation and upgrade.
87 * Probably also useful after adding a new package
90 * return true if it was successful
91 * return false if not (this will only happen if other
92 * transactions are in the pool which will lead to
95 bool freshenPool (void);
98 * Resolve package dependencies:
100 * Try to execute all pending transactions (there may be more than
102 * The solver pays attention to the BEST packages only in order to
103 * come to a solution.
104 * If there has not been found a valid results all other branches
105 * (e.G. packages with older version numbers, worse architecture)
108 * Returns "true" on success (i.e., if there were no problems that
109 * need user interaction) and "false" if there were problems. In
110 * the latter case, use problems() and later applySolutions()
113 bool resolvePool (void);
116 * Resolve package dependencies:
118 * Try to execute all pending transactions (there may be more than
120 * If tryAllPossibilities is false, restrict searches for matching
121 * requirements to best architecture, highest version.
122 * If tryAllPossibilities is true, evaluate all possible matches
125 * Returns "true" on success (i.e., if there were no problems that
126 * need user interaction) and "false" if there were problems. In
127 * the latter case, use problems() and later applySolutions()
130 bool resolvePool (bool tryAllPossibilities, bool keepExtras = false );
132 bool resolveDependencies( void );
135 * Undo solver changes done in resolvePool()
136 * Throwing away all ignored dependencies.
141 * Get the most recent resolver context
143 * It will be NULL if resolvePool() or establishPool() was never called.
144 * Depending on the return code of the last resolvePool() call,
145 * it _either_ points to a valid or an invalid solution.
147 solver::detail::ResolverContext_Ptr context (void) const;
150 * Do an distribution upgrade
152 * This will run a full upgrade on the pool, taking all upgrade
153 * dependencies (provide/obsolete for package renames, split-
154 * provides, etc.) into account and actually removing installed
155 * packages if no upgrade exists.
157 * To be run with great caution. It basically brings your
158 * system 'back to start'.
159 * Quite helpful to get back to a 'sane state'. Quite disastrous
160 * since you'll loose all non-distribution packages
162 void doUpgrade( UpgradeStatistics & opt_stats_r );
165 * Return the list of problematic update items
166 * i.e. locked ones (due to foreign vendor)
168 std::list<PoolItem_Ref> problematicUpdateItems( void ) const;
171 * Return the dependency problems found by the last call to
172 * resolveDependencies(). If there were no problems, the returned
173 * list will be empty.
175 ResolverProblemList problems();
178 * Return more solver information if an error has happened.
181 std::list<std::string> problemDescription( void ) const;
184 * Apply problem solutions. No more than one solution per problem
187 void applySolutions( const ProblemSolutionList & solutions );
189 Arch architecture() const;
190 void setArchitecture( const Arch & arch);
193 * Remove resolvables which are conflicts with others or
194 * have unfulfilled requirements.
195 * This behaviour is favourited by ZMD.
197 void setForceResolve (const bool force);
198 const bool forceResolve();
201 * Prefer the result with the newest version if there are more solver
204 void setPreferHighestVersion (const bool highestVersion);
205 const bool preferHighestVersion();
208 * transact a single ResObject
210 * Installs (install == true) or removes (install == false) all required
211 * and recommended packages(!) of \c robj
212 * (More or less a 'single step' resolver call)
214 * returns false if requirements are not all fulfillable
217 bool transactResObject( ResObject::constPtr robj, bool install = true);
220 * transact all objects of this kind
222 * Look through the pool and runs transactResObject, first for removes
224 * (More or less a 'single step' resolver call)
226 * returns false if any transactResObject() call returned false.
229 bool transactResKind( Resolvable::Kind kind );
232 * reset any transact states
234 * Look through the pool and clear transact state.
235 * It will only reset states which have an equal or
239 void transactReset( ResStatus::TransactByValue causer );
242 * Adding additional requirement
245 void addRequire (const Capability & capability);
248 * Adding additional conflict
251 void addConflict (const Capability & capability);
254 * Setting solver timeout
256 * Stop solving after a given timeframe (seconds)
257 * seconds = 0 : No timeout
260 void setTimeout( int seconds );
263 * Getting solver timeout in seconds
269 * Restricting solver passes
271 * Stop solving after a given amount of passes
272 * count = 0 : No restriction
275 void setMaxSolverPasses (int count);
278 * Count of max solver passes
281 int maxSolverPasses ();
284 * Generates a solver Testcase of the current state
286 * \parame dumpPath destination directory of the created directory
287 * \return true if it was successful
289 bool createSolverTestcase (const std::string & dumpPath = "/var/log/YaST2/solverTestcase");
293 * Gives information about WHO has pused an installation of an given item.
295 * \param item Evaluate additional information for this resolvable.
296 * \return A list of structures which contains:
297 * item Item which has triggered the installation of the given param item.
298 * cap Capability which has triggerd this installation
299 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
301 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
304 const solver::detail::ItemCapKindList isInstalledBy (const PoolItem_Ref item);
307 * Gives information about WHICH additional items will be installed due the installation of an item.
309 * \param item Evaluate additional information for this resolvable.
310 * \return A list of structures which contains:
311 * item Item which will be installed due to the installation of the given param item too.
312 * cap Capability which causes the installation
313 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
315 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
318 const solver::detail::ItemCapKindList installs (const PoolItem_Ref item);
324 solver::detail::Resolver_Ptr _pimpl;
326 ///////////////////////////////////////////////////////////////////
328 /////////////////////////////////////////////////////////////////
330 ///////////////////////////////////////////////////////////////////
331 #endif // ZYPP_RESOLVER_H