Add Resolver::setSolveSrcPackages to per default disable solving of source package...
[platform/upstream/libzypp.git] / zypp / Resolver.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/Resolver.h
10  *
11 */
12 #ifndef ZYPP_RESOLVER_H
13 #define ZYPP_RESOLVER_H
14
15 #include <iosfwd>
16 #include <functional>
17
18 #include "zypp/base/ReferenceCounted.h"
19 #include "zypp/base/PtrTypes.h"
20
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"
26
27 ///////////////////////////////////////////////////////////////////
28 namespace zypp
29 { /////////////////////////////////////////////////////////////////
30
31
32   ///////////////////////////////////////////////////////////////////
33   //
34   //    CLASS NAME : Resolver
35   //
36   /**
37    * Dependency resolver interface.
38    *
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    */
44   class Resolver : public base::ReferenceCounted, private base::NonCopyable
45   {
46   public:
47
48     /** Ctor */
49     Resolver( const ResPool & pool );
50     /** Dtor */
51     virtual ~Resolver();
52
53     /**
54      * Resolve package dependencies:
55      *
56      * Enter \ref systemVerification mode to monitor and repair dependencies
57      * of already installed packages, and solve immediately.
58      *
59      * Call \ref setSystemVerification to turn of this mode.
60      **/
61     bool verifySystem ();
62
63
64     /**
65      * Resolve package dependencies:
66      *
67      * Try to execute all pending transactions (there may be more than
68      * one!).
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
72      *
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()
76      * below.
77      **/
78     bool resolvePool (void);
79
80
81     /**
82      * Resolve package dependencies:
83      *
84      * The solver works off the given queue and writes back the solution
85      * to pool.
86      *
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()
90      * below.
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.
96      *
97      **/
98     bool resolveQueue (solver::detail::SolverQueueItemList & queue);
99
100     /*
101      * Undo solver changes done in resolvePool()
102      * Throwing away all ignored dependencies.
103      */
104     void undo( void );
105
106     /*
107      * Resets solver information and verify option.
108      */
109     void reset( void );
110
111
112     /**
113      * Do an distribution upgrade
114      *
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
119      * broken
120      *
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
125      **/
126     bool doUpgrade( UpgradeStatistics & opt_stats_r );
127
128     /**
129      * Update to newest package
130      *
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.
135      *
136      **/
137     void doUpdate( );
138
139
140     /**
141      * Unmaintained packages which does not fit to
142      * the updated system (broken dependencies) will be
143      * deleted.
144      * Return the list of deleted items.
145      * Note : This list is valid after the call doUpgrade() only.
146      **/
147     std::list<PoolItem> problematicUpdateItems( void ) const;
148
149     /**
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.
153      **/
154     ResolverProblemList problems();
155
156
157     /**
158      * Apply problem solutions. No more than one solution per problem
159      * can be applied.
160      **/
161     void applySolutions( const ProblemSolutionList & solutions );
162
163
164     /**
165      * Remove resolvables which are conflicts with others or
166      * have unfulfilled requirements.
167      * This behaviour is favourited by ZMD.
168      **/
169     void setForceResolve (const bool force);
170     bool forceResolve();
171
172     /**
173      * Ignore recommended packages that were already recommended by
174      * the installed packages
175      **/
176     void setIgnoreAlreadyRecommended (const bool ignoreAlreadyRecommended);
177     bool ignoreAlreadyRecommended();
178
179     /**
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.
183      **/
184     void setOnlyRequires (const bool onlyRequires);
185     void resetOnlyRequires(); // set back to default (described in zypp.conf)
186     bool onlyRequires();
187
188     /**
189      * System verification mode also monitors and repairs dependencies
190      * of already installed packages.
191      * \see \ref verifySystem
192      */
193     void setSystemVerification( bool yesno_r );
194     void setDefaultSystemVerification();
195     bool systemVerification() const;
196
197     /**
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
202      * always be solved.
203      * \NOTE Be carefull. The older the source package is, the stranger may be the
204      * result of solving it's build dependencies.
205      */
206     void setSolveSrcPackages( bool yesno_r );
207     void setDefaultSolveSrcPackages();
208     bool solveSrcPackages() const;
209
210     /**
211      * Adding additional requirement
212      *
213      */
214     void addRequire (const Capability & capability);
215
216     /**
217      * Adding additional conflict
218      *
219      */
220     void addConflict (const Capability & capability);
221
222     /**
223      * Remove the additional requirement set by \ref addRequire(Capability).
224      *
225      */
226     void removeRequire (const Capability & capability);
227
228     /**
229      * Remove the additional conflict set by \ref addConflict(Capability).
230      *
231      */
232     void removeConflict (const Capability & capability);
233
234     /**
235      * Get all the additional requirements set by \ref addRequire(Capability).
236      *
237      */
238     const CapabilitySet getRequire ();
239
240     /**
241      * Get all the additional conflicts set by \ref addConflict(Capability).
242      *
243      */
244     const CapabilitySet getConflict();
245
246     /**
247      * Generates a solver Testcase of the current state
248      *
249      * \parame dumpPath destination directory of the created directory
250      * \return true if it was successful
251      */
252     bool createSolverTestcase (const std::string & dumpPath = "/var/log/YaST2/solverTestcase");
253
254     /**
255      * Gives information about WHO has pused an installation of an given item.
256      *
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,... )
262      *
263      * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
264      *
265      */
266     const solver::detail::ItemCapKindList isInstalledBy (const PoolItem item);
267
268     /**
269      * Gives information about WHICH additional items will be installed due the installation of an item.
270      *
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,... )
276      *
277      * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
278      *
279      */
280     const solver::detail::ItemCapKindList installs (const PoolItem item);
281
282     /**
283      * Gives information about WHICH installed items are requested by the installation of an item.
284      *
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,... )
290      *
291      * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
292      *
293      */
294     const solver::detail::ItemCapKindList satifiedByInstalled(const PoolItem item);
295
296
297     /**
298      * Gives information about WHICH items require an already installed item.
299      *
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,... )
305      *
306      * Note: In order to have a result start a solver run before. Not matter if it is valid or invalid.
307      *
308      */
309     const solver::detail::ItemCapKindList installedSatisfied(const PoolItem item);
310
311
312
313   private:
314     solver::detail::Resolver_Ptr _pimpl;
315   };
316   ///////////////////////////////////////////////////////////////////
317
318   /////////////////////////////////////////////////////////////////
319 } // namespace zypp
320 ///////////////////////////////////////////////////////////////////
321 #endif // ZYPP_RESOLVER_H