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_SAT_RESOLVER_H
23 #define ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H
30 #include "zypp/base/ReferenceCounted.h"
31 #include "zypp/base/PtrTypes.h"
32 #include "zypp/ResPool.h"
33 #include "zypp/base/SerialNumber.h"
34 #include "zypp/ProblemTypes.h"
35 #include "zypp/ResolverProblem.h"
36 #include "zypp/ProblemSolution.h"
37 #include "zypp/Capability.h"
39 #include "satsolver/solver.h"
40 #include "satsolver/pool.h"
44 /////////////////////////////////////////////////////////////////////////
46 { ///////////////////////////////////////////////////////////////////////
47 ///////////////////////////////////////////////////////////////////////
49 { /////////////////////////////////////////////////////////////////////
50 /////////////////////////////////////////////////////////////////////
52 { ///////////////////////////////////////////////////////////////////
55 ///////////////////////////////////////////////////////////////////
57 // CLASS NAME : SATResolver
59 class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
67 // list populated by calls to addPoolItemTo*()
68 PoolItemList _items_to_install;
69 PoolItemList _items_to_update;
70 PoolItemList _items_to_remove;
71 PoolItemList _items_to_lock;
72 PoolItemList _items_to_keep;
74 bool _fixsystem; // repair errors in rpm dependency graph
75 bool _allowdowngrade; // allow to downgrade installed solvable
76 bool _allowarchchange; // allow to change architecture of installed solvables
77 bool _allowvendorchange; // allow to change vendor of installed solvables
78 bool _allowuninstall; // allow removal of installed solvables
79 bool _updatesystem; // distupgrade
80 bool _allowvirtualconflicts; // false: conflicts on package name, true: conflicts on package provides
81 bool _noupdateprovide; // true: update packages needs not to provide old package
82 bool _dosplitprovides; // true: consider legacy split provides
83 bool _onlyRequires; // true: consider required packages only
85 // ---------------------------------- methods
86 std::string SATprobleminfoString (Id problem, std::string &detail);
87 void resetItemTransaction (PoolItem item);
91 SATResolver (const ResPool & pool, Pool *SATPool);
92 virtual ~SATResolver();
94 // ---------------------------------- I/O
96 virtual std::ostream & dumpOn( std::ostream & str ) const;
97 friend std::ostream& operator<<(std::ostream& str, const SATResolver & obj)
98 { return obj.dumpOn (str); }
100 ResPool pool (void) const;
101 void setPool (const ResPool & pool) { _pool = pool; }
103 bool resolvePool(const CapabilitySet & requires_caps,
104 const CapabilitySet & conflict_caps);
107 ResolverProblemList problems ();
108 void applySolutions (const ProblemSolutionList &solutions);
110 void addPoolItemToInstall (PoolItem item);
111 void addPoolItemsToInstallFromList (PoolItemList & rl);
113 void addPoolItemToLock (PoolItem item);
114 void addPoolItemToKeep (PoolItem item);
116 void addPoolItemToRemove (PoolItem item);
117 void addPoolItemsToRemoveFromList (PoolItemList & rl);
119 bool fixsystem () const {return _fixsystem;}
120 void setFixsystem ( const bool fixsystem) { _fixsystem = fixsystem;}
122 bool allowdowngrade () const {return _allowdowngrade;}
123 void setAllowdowngrade ( const bool allowdowngrade) { _allowdowngrade = allowdowngrade;}
125 bool allowarchchange () const {return _allowarchchange;}
126 void setAllowarchchange ( const bool allowarchchange) { _allowarchchange = allowarchchange;}
128 bool allowvendorchange () const {return _allowvendorchange;}
129 void setAllowvendorchange ( const bool allowvendorchange) { _allowvendorchange = allowvendorchange;}
131 bool allowuninstall () const {return _allowuninstall;}
132 void setAllowuninstall ( const bool allowuninstall) { _allowuninstall = allowuninstall;}
134 bool updatesystem () const {return _updatesystem;}
135 void setUpdatesystem ( const bool updatesystem) { _updatesystem = updatesystem;}
137 bool allowvirtualconflicts () const {return _allowvirtualconflicts;}
138 void setAllowvirtualconflicts ( const bool allowvirtualconflicts) { _allowvirtualconflicts = allowvirtualconflicts;}
140 bool noupdateprovide () const {return _noupdateprovide;}
141 void setNoupdateprovide ( const bool noupdateprovide) { _noupdateprovide = noupdateprovide;}
143 bool dosplitprovides () const {return _dosplitprovides;}
144 void setDosplitprovides ( const bool dosplitprovides) { _dosplitprovides = dosplitprovides;}
146 bool onlyRequires () const {return _onlyRequires;}
147 void setOnlyRequires ( const bool onlyRequires) { _onlyRequires = onlyRequires;}
149 bool doesObsoleteItem (PoolItem candidate, PoolItem installed);
152 ///////////////////////////////////////////////////////////////////
153 };// namespace detail
154 /////////////////////////////////////////////////////////////////////
155 /////////////////////////////////////////////////////////////////////
156 };// namespace solver
157 ///////////////////////////////////////////////////////////////////////
158 ///////////////////////////////////////////////////////////////////////
160 /////////////////////////////////////////////////////////////////////////
162 #endif // ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H