libzypp: zypp/solver/detail/SATResolver.h Source File

libzypp 17.38.6

SATResolver.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/* SATResolver.h
3 *
4 * Copyright (C) 2000-2002 Ximian, Inc.
5 * Copyright (C) 2005 SUSE Linux Products GmbH
6 *
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.
10 *
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.
15 *
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
19 * 02111-1307, USA.
20 */
21
22#ifndef ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H
23#define ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H
24#ifndef ZYPP_USE_RESOLVER_INTERNALS
25#error Do not directly include this file!
26#else
27extern "C"
28{
29#include <solv/solver.h>
30#include <solv/pool.h>
31}
32
33#include <iosfwd>
34#include <list>
35#include <map>
36#include <string>
37
38#include <zypp/solver/Types.h>
39
41namespace zypp
42{
43
44 namespace sat
45 {
46 class Transaction;
47 }
48
50 namespace solver
51 {
53 namespace detail
54 {
55
56
58//
59// CLASS NAME : SATResolver
65class SATResolver : public base::ReferenceCounted, private base::NonCopyable, private sat::detail::PoolMember
66{
67
68 private:
69 ResPool _pool;
70 sat::detail::CPool *_satPool;
71 sat::detail::CSolver *_satSolver;
72 sat::detail::CQueue _jobQueue;
73
74 // list of problematic items (orphaned)
75 PoolItemList _problem_items;
76
77 // list populated by calls to addPoolItemTo*()
78 PoolItemList _items_to_install;
79 PoolItemList _items_to_remove;
80 PoolItemList _items_to_lock;
81 PoolItemList _items_to_keep;
82
83 // solve results
84 PoolItemList _result_items_to_install;
85 PoolItemList _result_items_to_remove;
86
87 public:
88 ResolverFocus _focus; // The resolver's general attitude
89
90 bool _fixsystem:1; // repair errors in rpm dependency graph
91 bool _allowdowngrade:1; // allow one to downgrade installed solvable
92 bool _allownamechange:1; // allow one to change name of installed solvable
93 bool _allowarchchange:1; // allow one to change architecture of installed solvables
94 bool _allowvendorchange:1; // allow one to change vendor of installed solvables
95 bool _allowuninstall:1; // allow removal of installed solvables
96 bool _updatesystem:1; // update
97 bool _noupdateprovide:1; // true: update packages needs not to provide old package
98 bool _dosplitprovides:1; // true: consider legacy split provides
99 bool _onlyRequires:1; // true: consider required packages only (but recommended namespaces)
100 bool _ignorealreadyrecommended:1; // true: ignore recommended packages that were already recommended by the installed packages
101 bool _distupgrade:1;
102 bool _removeOrphaned:1;
103 bool _removeUnneeded:1;
104 bool _dup_allowdowngrade:1; // dup mode: allow one to downgrade installed solvable
105 bool _dup_allownamechange:1; // dup mode: allow one to change name of installed solvable
106 bool _dup_allowarchchange:1; // dup mode: allow one to change architecture of installed solvables
107 bool _dup_allowvendorchange:1; // dup mode: allow one to change vendor of installed solvables
108 bool _solveSrcPackages:1; // false: generate no job rule for source packages selected in the pool
109 bool _cleandepsOnRemove:1; // whether removing a package should also remove no longer needed requirements
110
111 private:
112 bool _protectPTFs:1; // protect from accidental removal of PTFs if only @System is present (bsc#1203248)
113
114 // ---------------------------------- methods
115 std::string SATprobleminfoString (Id problem, std::string &detail, Id &ignoreId);
116 std::string SATproblemRuleInfoString (Id rule, std::string &detail, Id &ignoreId);
117 std::vector<std::string> SATgetCompleteProblemInfoStrings ( Id problem );
118 void resetItemTransaction (PoolItem item);
119
120 // Create a SAT solver and
121 void solverInit(const PoolItemList & weakItems);
122 void solverInitSetLocks();
123 void solverInitSetSystemRequirements();
124 void solverInitSetModeJobsAndFlags();
125
126 void solverAddJobsFromPool();
127 void solverAddJobsFromExtraQueues( const CapabilitySet & requires_caps, const CapabilitySet & conflict_caps );
128
129 // common solver run with the _jobQueue; Save results back to pool
130 bool solving(const CapabilitySet & requires_caps = CapabilitySet(),
131 const CapabilitySet & conflict_caps = CapabilitySet());
132 // cleanup solver
133 void solverEnd();
134
135 // Checking if this solvable/item has a buddy which reflect the real
136 // user visible description of an item
137 // e.g. The release package has a buddy to the concerning product item.
138 // This user want's the message "Product foo conflicts with product bar" and
139 // NOT "package release-foo conflicts with package release-bar"
140 // So these functions return the concerning buddy (e.g. product item)
141 sat::Solvable mapSolvable (const Id &id);
142 PoolItem mapItem (const PoolItem &item);
143
144 public:
145
146 SATResolver (ResPool pool, sat::detail::CPool *satPool);
147 virtual ~SATResolver();
148
149 // ---------------------------------- I/O
150
151 virtual std::ostream & dumpOn( std::ostream & str ) const;
152 friend std::ostream& operator<<(std::ostream& str, const SATResolver & obj)
153 { return obj.dumpOn (str); }
154
155 ResPool pool (void) const;
156 void setPool (const ResPool & pool) { _pool = pool; }
157
158 // solver run with pool selected items
159 bool resolvePool(const CapabilitySet & requires_caps,
160 const CapabilitySet & conflict_caps,
161 const PoolItemList & weakItems,
162 const std::set<Repository> & upgradeRepos
163 );
164 // solver run with the given request queue
165 bool resolveQueue(const SolverQueueItemList &requestQueue,
166 const PoolItemList & weakItems
167 );
168 // searching for new packages
169 void doUpdate();
170
171 ResolverProblemList problems ();
172 void applySolutions (const ProblemSolutionList &solutions);
173
174 bool fixsystem () const {return _fixsystem;}
175 void setFixsystem ( const bool fixsystem) { _fixsystem = fixsystem;}
176
177 bool ignorealreadyrecommended () const {return _ignorealreadyrecommended;}
178 void setIgnorealreadyrecommended ( const bool ignorealreadyrecommended) { _ignorealreadyrecommended = ignorealreadyrecommended;}
179
180 bool distupgrade () const {return _distupgrade;}
181 void setDistupgrade ( const bool distupgrade) { _distupgrade = distupgrade;}
182
183 bool removeOrphaned () const {return _removeOrphaned;}
184 void setRemoveOrphaned ( const bool removeOrphaned) { _removeOrphaned = removeOrphaned;}
185
186 bool allowdowngrade () const {return _allowdowngrade;}
187 void setAllowdowngrade ( const bool allowdowngrade) { _allowdowngrade = allowdowngrade;}
188
189 bool allowarchchange () const {return _allowarchchange;}
190 void setAllowarchchange ( const bool allowarchchange) { _allowarchchange = allowarchchange;}
191
192 bool allowvendorchange () const {return _allowvendorchange;}
193 void setAllowvendorchange ( const bool allowvendorchange) { _allowvendorchange = allowvendorchange;}
194
195 bool allowuninstall () const {return _allowuninstall;}
196 void setAllowuninstall ( const bool allowuninstall) { _allowuninstall = allowuninstall;}
197
198 bool updatesystem () const {return _updatesystem;}
199 void setUpdatesystem ( const bool updatesystem) { _updatesystem = updatesystem;}
200
201 bool noupdateprovide () const {return _noupdateprovide;}
202 void setNoupdateprovide ( const bool noupdateprovide) { _noupdateprovide = noupdateprovide;}
203
204 bool dosplitprovides () const {return _dosplitprovides;}
205 void setDosplitprovides ( const bool dosplitprovides) { _dosplitprovides = dosplitprovides;}
206
207 bool onlyRequires () const {return _onlyRequires;}
208 void setOnlyRequires ( const bool onlyRequires) { _onlyRequires = onlyRequires;}
209
210 bool solveSrcPackages() const { return _solveSrcPackages; }
211 void setSolveSrcPackages( bool state_r ) { _solveSrcPackages = state_r; }
212
213 bool cleandepsOnRemove() const { return _cleandepsOnRemove; }
214 void setCleandepsOnRemove( bool state_r ) { _cleandepsOnRemove = state_r; }
215
216 PoolItemList problematicUpdateItems( void ) const { return _problem_items; }
217 PoolItemList problematicUpdateItems() { return _problem_items; }
218
219 PoolItemList resultItemsToInstall () { return _result_items_to_install; }
220 PoolItemList resultItemsToRemove () { return _result_items_to_remove; }
221
222 sat::StringQueue autoInstalled() const;
223 sat::StringQueue userInstalled() const;
224
225public:
227 sat::detail::CSolver * get() const { return _satSolver; }
228};
229
231 };// namespace detail
234 };// namespace solver
237};// namespace zypp
239#endif // ZYPP_USE_RESOLVER_INTERNALS
240#endif // ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H
operator<<
std::ostream & operator<<(std::ostream &str, const zypp::sat::detail::CDataiterator *obj)
relates: zypp::sat::LookupAttr::iterator Stream output of the underlying iterator for debug.
Definition LookupAttr.cc:808
Types.h
Common types used in the Resolver public API and need to be passed down to the details tree.
zypp::sat::Transaction
Libsolv transaction wrapper.
Definition Transaction.h:52
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
zypp::sat
Libsolv interface
zypp::solver::detail
Definition PoolImpl.h:110
zypp::solver::detail::onlyRequires
onlyRequires
Definition Resolver.cc:169
zypp::solver
Definition PoolImpl.h:109
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::ResolverFocus
ResolverFocus
The resolver's general attitude.
Definition ResolverFocus.h:24
zypp::ResolverProblemList
std::list< ResolverProblem_Ptr > ResolverProblemList
Definition ProblemTypes.h:46
zypp::CapabilitySet
std::unordered_set< Capability > CapabilitySet
Definition Capability.h:35
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
relates: Capability Detailed stream output
Definition Capability.cc:589