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/base/SerialNumber.h"
36 #include "zypp/solver/detail/Types.h"
38 #include "zypp/ProblemTypes.h"
39 #include "zypp/ResolverProblem.h"
40 #include "zypp/ProblemSolution.h"
41 #include "zypp/UpgradeStatistics.h"
42 #include "zypp/Capabilities.h"
43 #include "zypp/Capability.h"
46 /////////////////////////////////////////////////////////////////////////
48 { ///////////////////////////////////////////////////////////////////////
49 ///////////////////////////////////////////////////////////////////////
51 { /////////////////////////////////////////////////////////////////////
52 /////////////////////////////////////////////////////////////////////
62 { ///////////////////////////////////////////////////////////////////
67 ///////////////////////////////////////////////////////////////////
69 // CLASS NAME : Resolver
71 class Resolver : public base::ReferenceCounted, private base::NonCopyable {
75 SATResolver *_satResolver;
76 SerialNumberWatcher _poolchanged;
79 // list of problematic items after doUpgrade()
80 PoolItemList _problem_items;
82 // list of not supported packages
83 PoolItemSet _unmaintained_items;
85 CapabilitySet _extra_requires;
86 CapabilitySet _extra_conflicts;
88 typedef std::multimap<PoolItem,Capability> IgnoreMap;
90 // These conflict should be ignored of the concering item
91 IgnoreMap _ignoreConflicts;
92 // These requires should be ignored of the concering item
93 IgnoreMap _ignoreRequires;
94 // These obsoletes should be ignored of the concering item
95 IgnoreMap _ignoreObsoletes;
96 // Ignore architecture of the item
97 PoolItemList _ignoreArchitecture;
98 // Ignore the status "installed" of the item
99 PoolItemList _ignoreInstalledItem;
100 // Ignore the architecture of the item
101 PoolItemList _ignoreArchitectureItem;
102 // Ignore the vendor of the item
103 PoolItemList _ignoreVendorItem;
106 bool _forceResolve; // remove items which are conflicts with others or
107 // have unfulfilled requirements.
108 // This behaviour is favourited by ZMD
109 bool _upgradeMode; // Resolver has been called with doUpgrade
110 bool _verifying; // The system will be checked
111 TriState _onlyRequires; // do install required resolvables only
112 // no recommended resolvables, language
113 // packages, hardware packages (modalias)
116 bool doesObsoleteCapability (PoolItem candidate, const Capability & cap);
117 bool doesObsoleteItem (PoolItem candidate, PoolItem installed);
119 // Unmaintained packages which does not fit to the updated system
120 // (broken dependencies) will be deleted.
121 void checkUnmaintainedItems ();
125 Resolver (const ResPool & pool);
128 // ---------------------------------- I/O
130 virtual std::ostream & dumpOn( std::ostream & str ) const;
131 friend std::ostream& operator<<(std::ostream& str, const Resolver & obj)
132 { return obj.dumpOn (str); }
134 // ---------------------------------- methods
136 ResPool pool (void) const;
137 void setPool (const ResPool & pool) { _pool = pool; }
139 void addExtraRequire (const Capability & capability);
140 void removeExtraRequire (const Capability & capability);
141 void addExtraConflict (const Capability & capability);
142 void removeExtraConflict (const Capability & capability);
144 const CapabilitySet extraRequires () { return _extra_requires; }
145 const CapabilitySet extraConflicts () { return _extra_conflicts; }
147 void addIgnoreConflict (const PoolItem item,
148 const Capability & capability);
149 void addIgnoreRequires (const PoolItem item,
150 const Capability & capability);
151 void addIgnoreObsoletes (const PoolItem item,
152 const Capability & capability);
153 void addIgnoreInstalledItem (const PoolItem item);
154 void addIgnoreArchitectureItem (const PoolItem item);
155 void addIgnoreVendorItem (const PoolItem item);
157 void setForceResolve (const bool force) { _forceResolve = force; }
158 bool forceResolve() { return _forceResolve; }
160 void setOnlyRequires (const TriState state)
161 { _onlyRequires = state; }
162 TriState onlyRequires () { return _onlyRequires; }
164 bool verifySystem ();
168 void doUpgrade( zypp::UpgradeStatistics & opt_stats_r );
169 PoolItemList problematicUpdateItems( void ) const { return _problem_items; }
171 ResolverProblemList problems () const;
172 void applySolutions (const ProblemSolutionList &solutions);
174 // reset all SOLVER transaction in pool
177 void reset (bool keepExtras = false );
179 bool testing(void) const { return _testing; }
180 void setTesting( bool testing ) { _testing = testing; }
184 ///////////////////////////////////////////////////////////////////
185 };// namespace detail
186 /////////////////////////////////////////////////////////////////////
187 /////////////////////////////////////////////////////////////////////
188 };// namespace solver
189 ///////////////////////////////////////////////////////////////////////
190 ///////////////////////////////////////////////////////////////////////
192 /////////////////////////////////////////////////////////////////////////
194 #endif // ZYPP_SOLVER_DETAIL_RESOLVER_H