libzypp  17.25.1
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
27 extern "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 
41 namespace zypp
42 {
43 
44  namespace sat
45  {
46  class Transaction;
47  }
48 
50  namespace solver
51  {
52  namespace detail
54  {
55 
56 
58 //
59 // CLASS NAME : SATResolver
65 class 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  public:
87  ResolverFocus _focus; // The resolvers general attitude
88 
89  bool _fixsystem:1; // repair errors in rpm dependency graph
90  bool _allowdowngrade:1; // allow to downgrade installed solvable
91  bool _allownamechange:1; // allow to change name of installed solvable
92  bool _allowarchchange:1; // allow to change architecture of installed solvables
93  bool _allowvendorchange:1; // allow to change vendor of installed solvables
94  bool _allowuninstall:1; // allow removal of installed solvables
95  bool _updatesystem:1; // update
96  bool _noupdateprovide:1; // true: update packages needs not to provide old package
97  bool _dosplitprovides:1; // true: consider legacy split provides
98  bool _onlyRequires:1; // true: consider required packages only (but recommended namespaces)
99  bool _ignorealreadyrecommended:1; // true: ignore recommended packages that were already recommended by the installed packages
100  bool _distupgrade:1;
101  bool _distupgrade_removeunsupported:1;
102  bool _dup_allowdowngrade:1; // dup mode: allow to downgrade installed solvable
103  bool _dup_allownamechange:1; // dup mode: allow to change name of installed solvable
104  bool _dup_allowarchchange:1; // dup mode: allow to change architecture of installed solvables
105  bool _dup_allowvendorchange:1; // dup mode: allow to change vendor of installed solvables
106  bool _solveSrcPackages:1; // false: generate no job rule for source packages selected in the pool
107  bool _cleandepsOnRemove:1; // whether removing a package should also remove no longer needed requirements
108 
109  private:
110  // ---------------------------------- methods
111  std::string SATprobleminfoString (Id problem, std::string &detail, Id &ignoreId);
112  std::string SATproblemRuleInfoString (Id rule, std::string &detail, Id &ignoreId);
113  std::vector<std::string> SATgetCompleteProblemInfoStrings ( Id problem );
114  void resetItemTransaction (PoolItem item);
115 
116  // Create a SAT solver and reset solver selection in the pool (Collecting
117  void solverInit(const PoolItemList & weakItems);
118  // common solver run with the _jobQueue; Save results back to pool
119  bool solving(const CapabilitySet & requires_caps = CapabilitySet(),
120  const CapabilitySet & conflict_caps = CapabilitySet());
121  // cleanup solver
122  void solverEnd();
123  // set locks for the solver
124  void setLocks();
125  // set requirements for a running system
126  void setSystemRequirements();
127 
128  // Checking if this solvable/item has a buddy which reflect the real
129  // user visible description of an item
130  // e.g. The release package has a buddy to the concerning product item.
131  // This user want's the message "Product foo conflicts with product bar" and
132  // NOT "package release-foo conflicts with package release-bar"
133  // So these functions return the concerning buddy (e.g. product item)
134  sat::Solvable mapSolvable (const Id &id);
135  PoolItem mapItem (const PoolItem &item);
136 
137  public:
138 
139  SATResolver (const ResPool & pool, sat::detail::CPool *satPool);
140  virtual ~SATResolver();
141 
142  // ---------------------------------- I/O
143 
144  virtual std::ostream & dumpOn( std::ostream & str ) const;
145  friend std::ostream& operator<<(std::ostream& str, const SATResolver & obj)
146  { return obj.dumpOn (str); }
147 
148  ResPool pool (void) const;
149  void setPool (const ResPool & pool) { _pool = pool; }
150 
151  // solver run with pool selected items
152  bool resolvePool(const CapabilitySet & requires_caps,
153  const CapabilitySet & conflict_caps,
154  const PoolItemList & weakItems,
155  const std::set<Repository> & upgradeRepos
156  );
157  // solver run with the given request queue
158  bool resolveQueue(const SolverQueueItemList &requestQueue,
159  const PoolItemList & weakItems
160  );
161  // searching for new packages
162  void doUpdate();
163 
164  ResolverProblemList problems ();
165  void applySolutions (const ProblemSolutionList &solutions);
166 
167  bool fixsystem () const {return _fixsystem;}
168  void setFixsystem ( const bool fixsystem) { _fixsystem = fixsystem;}
169 
170  bool ignorealreadyrecommended () const {return _ignorealreadyrecommended;}
171  void setIgnorealreadyrecommended ( const bool ignorealreadyrecommended) { _ignorealreadyrecommended = ignorealreadyrecommended;}
172 
173  bool distupgrade () const {return _distupgrade;}
174  void setDistupgrade ( const bool distupgrade) { _distupgrade = distupgrade;}
175 
176  bool distupgrade_removeunsupported () const {return _distupgrade_removeunsupported;}
177  void setDistupgrade_removeunsupported ( const bool distupgrade_removeunsupported) { _distupgrade_removeunsupported = distupgrade_removeunsupported;}
178 
179  bool allowdowngrade () const {return _allowdowngrade;}
180  void setAllowdowngrade ( const bool allowdowngrade) { _allowdowngrade = allowdowngrade;}
181 
182  bool allowarchchange () const {return _allowarchchange;}
183  void setAllowarchchange ( const bool allowarchchange) { _allowarchchange = allowarchchange;}
184 
185  bool allowvendorchange () const {return _allowvendorchange;}
186  void setAllowvendorchange ( const bool allowvendorchange) { _allowvendorchange = allowvendorchange;}
187 
188  bool allowuninstall () const {return _allowuninstall;}
189  void setAllowuninstall ( const bool allowuninstall) { _allowuninstall = allowuninstall;}
190 
191  bool updatesystem () const {return _updatesystem;}
192  void setUpdatesystem ( const bool updatesystem) { _updatesystem = updatesystem;}
193 
194  bool noupdateprovide () const {return _noupdateprovide;}
195  void setNoupdateprovide ( const bool noupdateprovide) { _noupdateprovide = noupdateprovide;}
196 
197  bool dosplitprovides () const {return _dosplitprovides;}
198  void setDosplitprovides ( const bool dosplitprovides) { _dosplitprovides = dosplitprovides;}
199 
200  bool onlyRequires () const {return _onlyRequires;}
201  void setOnlyRequires ( const bool onlyRequires) { _onlyRequires = onlyRequires;}
202 
203  bool solveSrcPackages() const { return _solveSrcPackages; }
204  void setSolveSrcPackages( bool state_r ) { _solveSrcPackages = state_r; }
205 
206  bool cleandepsOnRemove() const { return _cleandepsOnRemove; }
207  void setCleandepsOnRemove( bool state_r ) { _cleandepsOnRemove = state_r; }
208 
209  PoolItemList problematicUpdateItems( void ) const { return _problem_items; }
210  PoolItemList problematicUpdateItems() { return _problem_items; }
211 
212  PoolItemList resultItemsToInstall () { return _result_items_to_install; }
213  PoolItemList resultItemsToRemove () { return _result_items_to_remove; }
214 
215  sat::StringQueue autoInstalled() const;
216  sat::StringQueue userInstalled() const;
217 
218 public:
220  sat::detail::CSolver * get() const { return _satSolver; }
221 };
222 
224  };// namespace detail
227  };// namespace solver
230 };// namespace zypp
232 #endif // ZYPP_USE_RESOLVER_INTERNALS
233 #endif // ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H
Types.h
zypp::sat::detail::CPool
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:61
zypp::sat::StringQueue
Queue StringQueue
Queue with String ids.
Definition: Queue.h:27
zypp::solver::detail::_dup_allowdowngrade
_dup_allowdowngrade
Definition: Resolver.cc:123
zypp::ProblemSolutionList
std::list< ProblemSolution_Ptr > ProblemSolutionList
Definition: ProblemTypes.h:43
zypp::ResolverFocus
ResolverFocus
The resolvers general attitude.
Definition: ResolverFocus.h:21
zypp::sat::detail::CSolver
::s_Solver CSolver
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:65
zypp::CapabilitySet
std::unordered_set< Capability > CapabilitySet
Definition: Capability.h:33
zypp::solver::detail::SolverQueueItemList
std::list< SolverQueueItem_Ptr > SolverQueueItemList
Definition: Types.h:45
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::solver::detail::operator<<
std::ostream & operator<<(std::ostream &os, const SolutionActionList &actionlist)
Definition: SolutionAction.cc:81
zypp::ResolverProblemList
std::list< ResolverProblem_Ptr > ResolverProblemList
Definition: ProblemTypes.h:46
zypp::sat::detail::CQueue
::s_Queue CQueue
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:62
str
String related utilities and Regular expression matching.
zypp::solver::detail::_dup_allowvendorchange
_dup_allowvendorchange
Definition: Resolver.cc:126
zypp::solver::detail::_dup_allownamechange
_dup_allownamechange
Definition: Resolver.cc:124
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:443
zypp::solver::detail::_allowvendorchange
_allowvendorchange
Definition: Resolver.cc:121
zypp::solver::detail::_dup_allowarchchange
_dup_allowarchchange
Definition: Resolver.cc:125