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"
39 #include "zypp/ProblemTypes.h"
40 #include "zypp/ResolverProblem.h"
41 #include "zypp/ProblemSolution.h"
42 #include "zypp/UpgradeStatistics.h"
43 #include "zypp/Capabilities.h"
44 #include "zypp/Capability.h"
47 /////////////////////////////////////////////////////////////////////////
49 { ///////////////////////////////////////////////////////////////////////
50 ///////////////////////////////////////////////////////////////////////
52 { /////////////////////////////////////////////////////////////////////
53 /////////////////////////////////////////////////////////////////////
55 { ///////////////////////////////////////////////////////////////////
60 ///////////////////////////////////////////////////////////////////
62 // CLASS NAME : Resolver
64 class Resolver : public base::ReferenceCounted, private base::NonCopyable {
68 SATResolver *_satResolver;
69 SerialNumberWatcher _poolchanged;
72 // list of problematic items after doUpgrade()
73 PoolItemList _problem_items;
75 // list of not supported packages
76 PoolItemSet _unmaintained_items;
78 CapabilitySet _extra_requires;
79 CapabilitySet _extra_conflicts;
81 typedef std::multimap<PoolItem,Capability> IgnoreMap;
83 // These conflict should be ignored of the concering item
84 IgnoreMap _ignoreConflicts;
85 // These requires should be ignored of the concering item
86 IgnoreMap _ignoreRequires;
87 // These obsoletes should be ignored of the concering item
88 IgnoreMap _ignoreObsoletes;
89 // Ignore architecture of the item
90 PoolItemList _ignoreArchitecture;
91 // Ignore the status "installed" of the item
92 PoolItemList _ignoreInstalledItem;
93 // Ignore the architecture of the item
94 PoolItemList _ignoreArchitectureItem;
95 // Ignore the vendor of the item
96 PoolItemList _ignoreVendorItem;
99 bool _forceResolve; // remove items which are conflicts with others or
100 // have unfulfilled requirements.
101 // This behaviour is favourited by ZMD
102 bool _upgradeMode; // Resolver has been called with doUpgrade
103 bool _verifying; // The system will be checked
104 TriBool _onlyRequires; // do install required resolvables only
105 // no recommended resolvables, language
106 // packages, hardware packages (modalias)
109 bool doesObsoleteCapability (PoolItem candidate, const Capability & cap);
110 bool doesObsoleteItem (PoolItem candidate, PoolItem installed);
112 // Unmaintained packages which does not fit to the updated system
113 // (broken dependencies) will be deleted.
114 void checkUnmaintainedItems ();
118 Resolver (const ResPool & pool);
121 // ---------------------------------- I/O
123 virtual std::ostream & dumpOn( std::ostream & str ) const;
124 friend std::ostream& operator<<(std::ostream& str, const Resolver & obj)
125 { return obj.dumpOn (str); }
127 // ---------------------------------- methods
129 ResPool pool (void) const;
130 void setPool (const ResPool & pool) { _pool = pool; }
132 void addExtraRequire (const Capability & capability);
133 void removeExtraRequire (const Capability & capability);
134 void addExtraConflict (const Capability & capability);
135 void removeExtraConflict (const Capability & capability);
137 const CapabilitySet extraRequires () { return _extra_requires; }
138 const CapabilitySet extraConflicts () { return _extra_conflicts; }
140 void addIgnoreConflict (const PoolItem item,
141 const Capability & capability);
142 void addIgnoreRequires (const PoolItem item,
143 const Capability & capability);
144 void addIgnoreObsoletes (const PoolItem item,
145 const Capability & capability);
146 void addIgnoreInstalledItem (const PoolItem item);
147 void addIgnoreArchitectureItem (const PoolItem item);
148 void addIgnoreVendorItem (const PoolItem item);
150 void setForceResolve (const bool force) { _forceResolve = force; }
151 bool forceResolve() { return _forceResolve; }
153 void setOnlyRequires (const TriBool state)
154 { _onlyRequires = state; }
155 TriBool onlyRequires () { return _onlyRequires; }
157 bool verifySystem ();
161 void doUpgrade( zypp::UpgradeStatistics & opt_stats_r );
162 PoolItemList problematicUpdateItems( void ) const { return _problem_items; }
164 ResolverProblemList problems () const;
165 void applySolutions (const ProblemSolutionList &solutions);
167 // reset all SOLVER transaction in pool
170 void reset (bool keepExtras = false );
172 bool testing(void) const { return _testing; }
173 void setTesting( bool testing ) { _testing = testing; }
177 ///////////////////////////////////////////////////////////////////
178 };// namespace detail
179 /////////////////////////////////////////////////////////////////////
180 /////////////////////////////////////////////////////////////////////
181 };// namespace solver
182 ///////////////////////////////////////////////////////////////////////
183 ///////////////////////////////////////////////////////////////////////
185 /////////////////////////////////////////////////////////////////////////
187 #endif // ZYPP_SOLVER_DETAIL_RESOLVER_H