libzypp 8.13.6
|
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ 00002 /* SATResolver.h 00003 * 00004 * Copyright (C) 2000-2002 Ximian, Inc. 00005 * Copyright (C) 2005 SUSE Linux Products GmbH 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License, 00009 * version 2, as published by the Free Software Foundation. 00010 * 00011 * This program is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00019 * 02111-1307, USA. 00020 */ 00021 00022 #ifndef ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H 00023 #define ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H 00024 00025 extern "C" 00026 { 00027 #include <satsolver/solver.h> 00028 #include <satsolver/pool.h> 00029 } 00030 00031 #include <iosfwd> 00032 #include <list> 00033 #include <map> 00034 #include <string> 00035 00036 #include "zypp/base/ReferenceCounted.h" 00037 #include "zypp/base/PtrTypes.h" 00038 #include "zypp/ResPool.h" 00039 #include "zypp/base/SerialNumber.h" 00040 #include "zypp/ProblemTypes.h" 00041 #include "zypp/ResolverProblem.h" 00042 #include "zypp/ProblemSolution.h" 00043 #include "zypp/Capability.h" 00044 #include "zypp/solver/detail/SolverQueueItem.h" 00045 00046 00048 namespace zypp 00049 { 00050 00051 namespace solver 00052 { 00053 00054 namespace detail 00055 { 00056 00057 00059 // 00060 // CLASS NAME : SATResolver 00066 class SATResolver : public base::ReferenceCounted, private base::NonCopyable { 00067 00068 private: 00069 ResPool _pool; 00070 Pool *_SATPool; 00071 Solver *_solv; 00072 Queue _jobQueue; 00073 00074 // list of problematic items (orphaned) 00075 PoolItemList _problem_items; 00076 00077 // list populated by calls to addPoolItemTo*() 00078 PoolItemList _items_to_install; 00079 PoolItemList _items_to_remove; 00080 PoolItemList _items_to_lock; 00081 PoolItemList _items_to_keep; 00082 00083 // solve results 00084 PoolItemList _result_items_to_install; 00085 PoolItemList _result_items_to_remove; 00086 00087 bool _fixsystem; // repair errors in rpm dependency graph 00088 bool _allowdowngrade; // allow to downgrade installed solvable 00089 bool _allowarchchange; // allow to change architecture of installed solvables 00090 bool _allowvendorchange; // allow to change vendor of installed solvables 00091 bool _allowuninstall; // allow removal of installed solvables 00092 bool _updatesystem; // update 00093 bool _noupdateprovide; // true: update packages needs not to provide old package 00094 bool _dosplitprovides; // true: consider legacy split provides 00095 bool _onlyRequires; // true: consider required packages only 00096 bool _ignorealreadyrecommended; // true: ignore recommended packages that were already recommended by the installed packages 00097 bool _distupgrade; 00098 bool _distupgrade_removeunsupported; 00099 bool _solveSrcPackages; // false: generate no job rule for source packages selected in the pool 00100 bool _cleandepsOnRemove; // whether removing a package should also remove no longer needed requirements 00101 00102 // ---------------------------------- methods 00103 std::string SATprobleminfoString (Id problem, std::string &detail, Id &ignoreId); 00104 void resetItemTransaction (PoolItem item); 00105 00106 // Create a SAT solver and reset solver selection in the pool (Collecting 00107 void solverInit(const PoolItemList & weakItems); 00108 // common solver run with the _jobQueue; Save results back to pool 00109 bool solving(const CapabilitySet & requires_caps = CapabilitySet(), 00110 const CapabilitySet & conflict_caps = CapabilitySet()); 00111 // cleanup solver 00112 void solverEnd(); 00113 // set locks for the solver 00114 void setLocks(); 00115 // set requirements for a running system 00116 void setSystemRequirements(); 00117 00118 // Checking if this solvable/item has a buddy which reflect the real 00119 // user visible description of an item 00120 // e.g. The release package has a buddy to the concerning product item. 00121 // This user want's the message "Product foo conflicts with product bar" and 00122 // NOT "package release-foo conflicts with package release-bar" 00123 // So these functions return the concerning buddy (e.g. product item) 00124 sat::Solvable mapSolvable (const Id &id); 00125 PoolItem mapItem (const PoolItem &item); 00126 00127 public: 00128 00129 SATResolver (const ResPool & pool, Pool *SATPool); 00130 virtual ~SATResolver(); 00131 00132 // ---------------------------------- I/O 00133 00134 virtual std::ostream & dumpOn( std::ostream & str ) const; 00135 friend std::ostream& operator<<(std::ostream& str, const SATResolver & obj) 00136 { return obj.dumpOn (str); } 00137 00138 ResPool pool (void) const; 00139 void setPool (const ResPool & pool) { _pool = pool; } 00140 00141 // solver run with pool selected items 00142 bool resolvePool(const CapabilitySet & requires_caps, 00143 const CapabilitySet & conflict_caps, 00144 const PoolItemList & weakItems, 00145 const std::set<Repository> & upgradeRepos 00146 ); 00147 // solver run with the given request queue 00148 bool resolveQueue(const SolverQueueItemList &requestQueue, 00149 const PoolItemList & weakItems 00150 ); 00151 // searching for new packages 00152 void doUpdate(); 00153 00154 ResolverProblemList problems (); 00155 void applySolutions (const ProblemSolutionList &solutions); 00156 00157 void addPoolItemToInstall (PoolItem item); 00158 void addPoolItemsToInstallFromList (PoolItemList & rl); 00159 00160 void addPoolItemToLock (PoolItem item); 00161 void addPoolItemToKeep (PoolItem item); 00162 00163 void addPoolItemToRemove (PoolItem item); 00164 void addPoolItemsToRemoveFromList (PoolItemList & rl); 00165 00166 bool fixsystem () const {return _fixsystem;} 00167 void setFixsystem ( const bool fixsystem) { _fixsystem = fixsystem;} 00168 00169 bool ignorealreadyrecommended () const {return _ignorealreadyrecommended;} 00170 void setIgnorealreadyrecommended ( const bool ignorealreadyrecommended) { _ignorealreadyrecommended = ignorealreadyrecommended;} 00171 00172 bool distupgrade () const {return _distupgrade;} 00173 void setDistupgrade ( const bool distupgrade) { _distupgrade = distupgrade;} 00174 00175 bool distupgrade_removeunsupported () const {return _distupgrade_removeunsupported;} 00176 void setDistupgrade_removeunsupported ( const bool distupgrade_removeunsupported) { _distupgrade_removeunsupported = distupgrade_removeunsupported;} 00177 00178 bool allowdowngrade () const {return _allowdowngrade;} 00179 void setAllowdowngrade ( const bool allowdowngrade) { _allowdowngrade = allowdowngrade;} 00180 00181 bool allowarchchange () const {return _allowarchchange;} 00182 void setAllowarchchange ( const bool allowarchchange) { _allowarchchange = allowarchchange;} 00183 00184 bool allowvendorchange () const {return _allowvendorchange;} 00185 void setAllowvendorchange ( const bool allowvendorchange) { _allowvendorchange = allowvendorchange;} 00186 00187 bool allowuninstall () const {return _allowuninstall;} 00188 void setAllowuninstall ( const bool allowuninstall) { _allowuninstall = allowuninstall;} 00189 00190 bool updatesystem () const {return _updatesystem;} 00191 void setUpdatesystem ( const bool updatesystem) { _updatesystem = updatesystem;} 00192 00193 bool noupdateprovide () const {return _noupdateprovide;} 00194 void setNoupdateprovide ( const bool noupdateprovide) { _noupdateprovide = noupdateprovide;} 00195 00196 bool dosplitprovides () const {return _dosplitprovides;} 00197 void setDosplitprovides ( const bool dosplitprovides) { _dosplitprovides = dosplitprovides;} 00198 00199 bool onlyRequires () const {return _onlyRequires;} 00200 void setOnlyRequires ( const bool onlyRequires) { _onlyRequires = onlyRequires;} 00201 00202 bool solveSrcPackages() const { return _solveSrcPackages; } 00203 void setSolveSrcPackages( bool state_r ) { _solveSrcPackages = state_r; } 00204 00205 bool cleandepsOnRemove() const { return _cleandepsOnRemove; } 00206 void setCleandepsOnRemove( bool state_r ) { _cleandepsOnRemove = state_r; } 00207 00208 PoolItemList problematicUpdateItems( void ) const { return _problem_items; } 00209 00210 PoolItemList resultItemsToInstall () { return _result_items_to_install; } 00211 PoolItemList resultItemsToRemove () { return _result_items_to_remove; } 00212 PoolItemList problematicUpdateItems() { return _problem_items; } 00213 00214 }; 00215 00217 };// namespace detail 00220 };// namespace solver 00223 };// namespace zypp 00225 00226 #endif // ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H