libzypp  14.48.5
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 
25 extern "C"
26 {
27 #include <solv/solver.h>
28 #include <solv/pool.h>
29 }
30 
31 #include <iosfwd>
32 #include <list>
33 #include <map>
34 #include <string>
35 
37 #include "zypp/base/PtrTypes.h"
38 #include "zypp/ResPool.h"
39 #include "zypp/base/SerialNumber.h"
40 #include "zypp/ProblemTypes.h"
41 #include "zypp/ResolverProblem.h"
42 #include "zypp/ProblemSolution.h"
43 #include "zypp/Capability.h"
45 
47 namespace zypp
48 {
49 
50  namespace sat
51  {
52  class Transaction;
53  }
54 
56  namespace solver
57  {
58  namespace detail
60  {
61 
62 
64 //
65 // CLASS NAME : SATResolver
72 
73  private:
78 
79  // list of problematic items (orphaned)
81 
82  // list populated by calls to addPoolItemTo*()
87 
88  // solve results
91  public:
92  bool _fixsystem:1; // repair errors in rpm dependency graph
93  bool _allowdowngrade:1; // allow to downgrade installed solvable
94  bool _allowarchchange:1; // allow to change architecture of installed solvables
95  bool _allowvendorchange:1; // allow to change vendor of installed solvables
96  bool _allowuninstall:1; // allow removal of installed solvables
97  bool _updatesystem:1; // update
98  bool _noupdateprovide:1; // true: update packages needs not to provide old package
99  bool _dosplitprovides:1; // true: consider legacy split provides
100  bool _onlyRequires:1; // true: consider required packages only
101  bool _ignorealreadyrecommended:1; // true: ignore recommended packages that were already recommended by the installed packages
102  bool _distupgrade:1;
104  bool _dup_allowdowngrade:1; // dup mode: allow to downgrade installed solvable
105  bool _dup_allownamechange:1; // dup mode: allow to change name of installed solvable
106  bool _dup_allowarchchange:1; // dup mode: allow to change architecture of installed solvables
107  bool _dup_allowvendorchange:1; // dup mode: allow 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  // ---------------------------------- methods
113  std::string SATprobleminfoString (Id problem, std::string &detail, Id &ignoreId);
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 
165  void applySolutions (const ProblemSolutionList &solutions);
166 
167  void addPoolItemToInstall (PoolItem item);
169 
170  void addPoolItemToLock (PoolItem item);
171  void addPoolItemToKeep (PoolItem item);
172 
173  void addPoolItemToRemove (PoolItem item);
175 
176  bool fixsystem () const {return _fixsystem;}
177  void setFixsystem ( const bool fixsystem) { _fixsystem = fixsystem;}
178 
181 
182  bool distupgrade () const {return _distupgrade;}
184 
187 
188  bool allowdowngrade () const {return _allowdowngrade;}
190 
191  bool allowarchchange () const {return _allowarchchange;}
193 
194  bool allowvendorchange () const {return _allowvendorchange;}
196 
197  bool allowuninstall () const {return _allowuninstall;}
199 
200  bool updatesystem () const {return _updatesystem;}
202 
203  bool noupdateprovide () const {return _noupdateprovide;}
205 
206  bool dosplitprovides () const {return _dosplitprovides;}
208 
209  bool onlyRequires () const {return _onlyRequires;}
211 
212  bool solveSrcPackages() const { return _solveSrcPackages; }
213  void setSolveSrcPackages( bool state_r ) { _solveSrcPackages = state_r; }
214 
215  bool cleandepsOnRemove() const { return _cleandepsOnRemove; }
216  void setCleandepsOnRemove( bool state_r ) { _cleandepsOnRemove = state_r; }
217 
219 
223 
226 };
227 
229  };// namespace detail
232  };// namespace solver
235 };// namespace zypp
237 
238 #endif // ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H
void addPoolItemToKeep(PoolItem item)
Definition: SATResolver.cc:298
std::list< ProblemSolution_Ptr > ProblemSolutionList
Definition: ProblemTypes.h:42
void setSolveSrcPackages(bool state_r)
Definition: SATResolver.h:213
A Solvable object within the sat Pool.
Definition: Solvable.h:55
void setCleandepsOnRemove(bool state_r)
Definition: SATResolver.h:216
PoolItemList problematicUpdateItems(void) const
Definition: SATResolver.h:218
void addPoolItemsToInstallFromList(PoolItemList &rl)
Definition: SATResolver.cc:264
void setPool(const ResPool &pool)
Definition: SATResolver.h:149
bool distupgrade_removeunsupported() const
Definition: SATResolver.h:185
SATResolver(const ResPool &pool, sat::detail::CPool *satPool)
Definition: SATResolver.cc:170
void setAllowarchchange(const bool allowarchchange)
Definition: SATResolver.h:192
::_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:86
void addPoolItemToLock(PoolItem item)
Definition: SATResolver.cc:290
void resetItemTransaction(PoolItem item)
Definition: SATResolver.cc:210
std::list< PoolItem > PoolItemList
Definition: Types.h:51
std::list< SolverQueueItem_Ptr > SolverQueueItemList
std::tr1::unordered_set< Capability > CapabilitySet
Definition: Capability.h:33
bool solving(const CapabilitySet &requires_caps=CapabilitySet(), const CapabilitySet &conflict_caps=CapabilitySet())
Definition: SATResolver.cc:458
void setUpdatesystem(const bool updatesystem)
Definition: SATResolver.h:201
void addPoolItemToRemove(PoolItem item)
Definition: SATResolver.cc:273
std::string SATprobleminfoString(Id problem, std::string &detail, Id &ignoreId)
sat::detail::CSolver * _satSolver
Definition: SATResolver.h:76
void setOnlyRequires(const bool onlyRequires)
Definition: SATResolver.h:210
::_Solver CSolver
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:90
void addPoolItemToInstall(PoolItem item)
Definition: SATResolver.cc:255
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
std::list< ResolverProblem_Ptr > ResolverProblemList
Definition: ProblemTypes.h:46
void setAllowdowngrade(const bool allowdowngrade)
Definition: SATResolver.h:189
sat::Solvable mapSolvable(const Id &id)
friend std::ostream & operator<<(std::ostream &str, const SATResolver &obj)
Definition: SATResolver.h:145
void setNoupdateprovide(const bool noupdateprovide)
Definition: SATResolver.h:204
void setAllowvendorchange(const bool allowvendorchange)
Definition: SATResolver.h:195
void setDistupgrade_removeunsupported(const bool distupgrade_removeunsupported)
Definition: SATResolver.h:186
void setIgnorealreadyrecommended(const bool ignorealreadyrecommended)
Definition: SATResolver.h:180
Base class for reference counted objects.
void addPoolItemsToRemoveFromList(PoolItemList &rl)
Definition: SATResolver.cc:282
void applySolutions(const ProblemSolutionList &solutions)
sat::detail::CQueue _jobQueue
Definition: SATResolver.h:77
void setDosplitprovides(const bool dosplitprovides)
Definition: SATResolver.h:207
sat::detail::CPool * _satPool
Definition: SATResolver.h:75
bool resolveQueue(const SolverQueueItemList &requestQueue, const PoolItemList &weakItems)
Definition: SATResolver.cc:829
Libsolv Id queue wrapper.
Definition: Queue.h:34
sat::StringQueue userInstalled() const
Global ResObject pool.
Definition: ResPool.h:48
sat::StringQueue autoInstalled() const
void setDistupgrade(const bool distupgrade)
Definition: SATResolver.h:183
bool resolvePool(const CapabilitySet &requires_caps, const CapabilitySet &conflict_caps, const PoolItemList &weakItems, const std::set< Repository > &upgradeRepos)
Definition: SATResolver.cc:763
void solverInit(const PoolItemList &weakItems)
Definition: SATResolver.cc:679
PoolItem mapItem(const PoolItem &item)
Reference to a PoolItem connecting ResObject and ResStatus.
Definition: PoolItem.h:50
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream & operator<<.
Definition: SATResolver.cc:130
::_Queue CQueue
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:87
void setAllowuninstall(const bool allowuninstall)
Definition: SATResolver.h:198
ResolverProblemList problems()
void setFixsystem(const bool fixsystem)
Definition: SATResolver.h:177