1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * Copyright (C) 2000-2002 Ximian, Inc.
5 * Copyright (C) 2005 SUSE Linux Products GmbH
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 #ifndef ZYPP_SOLVER_DETAIL_RESOLVER_H
23 #define ZYPP_SOLVER_DETAIL_RESOLVER_H
30 #include "zypp/base/ReferenceCounted.h"
31 #include "zypp/base/PtrTypes.h"
33 #include "zypp/ResPool.h"
34 #include "zypp/TriBool.h"
35 #include "zypp/base/SerialNumber.h"
37 #include "zypp/solver/detail/Types.h"
38 #include "zypp/solver/detail/SolverQueueItem.h"
40 #include "zypp/ProblemTypes.h"
41 #include "zypp/ResolverProblem.h"
42 #include "zypp/ProblemSolution.h"
43 #include "zypp/UpgradeStatistics.h"
44 #include "zypp/Capabilities.h"
45 #include "zypp/Capability.h"
48 /////////////////////////////////////////////////////////////////////////
50 { ///////////////////////////////////////////////////////////////////////
51 ///////////////////////////////////////////////////////////////////////
53 { /////////////////////////////////////////////////////////////////////
54 /////////////////////////////////////////////////////////////////////
56 { ///////////////////////////////////////////////////////////////////
61 ///////////////////////////////////////////////////////////////////
63 // CLASS NAME : Resolver
65 class Resolver : public base::ReferenceCounted, private base::NonCopyable {
69 SATResolver *_satResolver;
70 SerialNumberWatcher _poolchanged;
73 // list of problematic items after doUpgrade()
74 PoolItemList _problem_items;
76 // list of not supported packages
77 PoolItemSet _unmaintained_items;
79 CapabilitySet _extra_requires;
80 CapabilitySet _extra_conflicts;
82 typedef std::multimap<PoolItem,Capability> IgnoreMap;
84 // These conflict should be ignored of the concering item
85 IgnoreMap _ignoreConflicts;
86 // These requires should be ignored of the concering item
87 IgnoreMap _ignoreRequires;
88 // These obsoletes should be ignored of the concering item
89 IgnoreMap _ignoreObsoletes;
90 // Ignore architecture of the item
91 PoolItemList _ignoreArchitecture;
92 // Ignore the status "installed" of the item
93 PoolItemList _ignoreInstalledItem;
94 // Ignore the architecture of the item
95 PoolItemList _ignoreArchitectureItem;
96 // Ignore the vendor of the item
97 PoolItemList _ignoreVendorItem;
100 bool _forceResolve; // remove items which are conflicts with others or
101 // have unfulfilled requirements.
102 // This behaviour is favourited by ZMD
103 bool _upgradeMode; // Resolver has been called with doUpgrade
104 bool _verifying; // The system will be checked
105 TriBool _onlyRequires; // do install required resolvables only
106 // no recommended resolvables, language
107 // packages, hardware packages (modalias)
110 bool doesObsoleteCapability (PoolItem candidate, const Capability & cap);
111 bool doesObsoleteItem (PoolItem candidate, PoolItem installed);
113 // Unmaintained packages which does not fit to the updated system
114 // (broken dependencies) will be deleted.
115 void checkUnmaintainedItems ();
121 Resolver (const ResPool & pool);
124 // ---------------------------------- I/O
126 virtual std::ostream & dumpOn( std::ostream & str ) const;
127 friend std::ostream& operator<<(std::ostream& str, const Resolver & obj)
128 { return obj.dumpOn (str); }
130 // ---------------------------------- methods
132 ResPool pool (void) const;
133 void setPool (const ResPool & pool) { _pool = pool; }
135 void addExtraRequire (const Capability & capability);
136 void removeExtraRequire (const Capability & capability);
137 void addExtraConflict (const Capability & capability);
138 void removeExtraConflict (const Capability & capability);
140 const CapabilitySet extraRequires () { return _extra_requires; }
141 const CapabilitySet extraConflicts () { return _extra_conflicts; }
143 void addIgnoreConflict (const PoolItem item,
144 const Capability & capability);
145 void addIgnoreRequires (const PoolItem item,
146 const Capability & capability);
147 void addIgnoreObsoletes (const PoolItem item,
148 const Capability & capability);
149 void addIgnoreInstalledItem (const PoolItem item);
150 void addIgnoreArchitectureItem (const PoolItem item);
151 void addIgnoreVendorItem (const PoolItem item);
153 void setForceResolve (const bool force) { _forceResolve = force; }
154 bool forceResolve() { return _forceResolve; }
156 void setOnlyRequires (const TriBool state)
157 { _onlyRequires = state; }
158 TriBool onlyRequires () { return _onlyRequires; }
160 bool verifySystem ();
162 bool resolveQueue(solver::detail::SolverQueueItemList & queue);
165 void doUpgrade( zypp::UpgradeStatistics & opt_stats_r );
166 PoolItemList problematicUpdateItems( void ) const { return _problem_items; }
168 ResolverProblemList problems () const;
169 void applySolutions (const ProblemSolutionList &solutions);
171 // reset all SOLVER transaction in pool
174 void reset (bool keepExtras = false );
176 bool testing(void) const { return _testing; }
177 void setTesting( bool testing ) { _testing = testing; }
181 ///////////////////////////////////////////////////////////////////
182 };// namespace detail
183 /////////////////////////////////////////////////////////////////////
184 /////////////////////////////////////////////////////////////////////
185 };// namespace solver
186 ///////////////////////////////////////////////////////////////////////
187 ///////////////////////////////////////////////////////////////////////
189 /////////////////////////////////////////////////////////////////////////
191 #endif // ZYPP_SOLVER_DETAIL_RESOLVER_H