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.
43 * Do not use this method after \ref verifySystem(), \ref doUpdate(), or
46 class Resolver : public base::ReferenceCounted, private base::NonCopyable
51 Resolver( const ResPool & pool );
56 * Resolve package dependencies:
58 * Verify consistency of system
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 * Adding additional requirement
192 void addRequire (const Capability & capability);
195 * Adding additional conflict
198 void addConflict (const Capability & capability);
201 * Remove the additional requirement set by \ref addRequire(Capability).
204 void removeRequire (const Capability & capability);
207 * Remove the additional conflict set by \ref addConflict(Capability).
210 void removeConflict (const Capability & capability);
213 * Get all the additional requirements set by \ref addRequire(Capability).
216 const CapabilitySet getRequire ();
219 * Get all the additional conflicts set by \ref addConflict(Capability).
222 const CapabilitySet getConflict();
225 * Generates a solver Testcase of the current state
227 * \parame dumpPath destination directory of the created directory
228 * \return true if it was successful
230 bool createSolverTestcase (const std::string & dumpPath = "/var/log/YaST2/solverTestcase");
233 * Gives information about WHO has pused an installation of an given item.
235 * \param item Evaluate additional information for this resolvable.
236 * \return A list of structures which contains:
237 * item Item which has triggered the installation of the given param item.
238 * initialInstallation This item has triggered the installation
239 * Not already fullfilled requierement only.
240 * cap Capability which has triggerd this installation
241 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
243 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
246 const solver::detail::ItemCapKindList isInstalledBy (const PoolItem item);
249 * Gives information about WHICH additional items will be installed due the installation of an item.
251 * \param item Evaluate additional information for this resolvable.
252 * \return A list of structures which contains:
253 * item Item which has triggered the installation of the given param item.
254 * initialInstallation This item has triggered the installation
255 * Not already fullfilled requierement only.
256 * cap Capability which has triggerd this installation
257 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
259 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
262 const solver::detail::ItemCapKindList installs (const PoolItem item);
265 * Gives information about WHICH installed items are requested by the installation of an item.
267 * \param item Evaluate additional information for this resolvable.
268 * \return A list of structures which contains:
269 * item Item which has triggered the installation of the given param item.
270 * initialInstallation This item has triggered the installation
271 * Not already fullfilled requierement only.
272 * cap Capability which has triggerd this installation
273 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
275 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
278 const solver::detail::ItemCapKindList satifiedByInstalled(const PoolItem item);
282 * Gives information about WHICH items require an already installed item.
284 * \param item Evaluate additional information for this resolvable.
285 * \return A list of structures which contains:
286 * item Item which has triggered the installation of the given param item.
287 * initialInstallation This item has triggered the installation
288 * Not already fullfilled requierement only.
289 * cap Capability which has triggerd this installation
290 * capKind Kind of that capability (e.g. Dep::REQUIRES,Dep::RECOMMENDS,... )
292 * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
295 const solver::detail::ItemCapKindList installedSatisfied(const PoolItem item);
300 solver::detail::Resolver_Ptr _pimpl;
302 ///////////////////////////////////////////////////////////////////
304 /////////////////////////////////////////////////////////////////
306 ///////////////////////////////////////////////////////////////////
307 #endif // ZYPP_RESOLVER_H