libzypp  17.16.0
Resolver.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include <iostream>
13 
14 #define ZYPP_USE_RESOLVER_INTERNALS
15 
16 #include "zypp/Resolver.h"
20 #include "zypp/sat/Transaction.h"
21 
22 using namespace std;
23 
25 namespace zypp
26 {
27 
28  using namespace solver;
29 
30  IMPL_PTR_TYPE(Resolver);
31 
33  //
34  // METHOD NAME : Resolver::Resolver
35  // METHOD TYPE : Ctor
36  //
37  Resolver::Resolver( const ResPool & pool )
38  : _pimpl( new solver::detail::ResolverInternal(pool) )
39  {}
40 
42  //
43  // METHOD NAME : Resolver::~Resolver
44  // METHOD TYPE : Dtor
45  //
47  {}
48 
50  //
51  // Resolver interface forwarded to implementation
52  //
55  { return _pimpl->verifySystem(); }
56 
58  { return _pimpl->resolvePool(); }
59 
61  { return _pimpl->resolveQueue(queue); }
62 
64  { _pimpl->undo(); }
65 
67  { return _pimpl->problems (); }
68 
70  { _pimpl->applySolutions (solutions); }
71 
73  { return _pimpl->getTransaction(); }
74 
76  { return _pimpl->doUpgrade(); }
77 
79  { _pimpl->doUpdate(); }
80 
81  void Resolver::setFocus( ResolverFocus focus_r ) { _pimpl->setFocus( focus_r ); }
82  ResolverFocus Resolver::focus() const { return _pimpl->focus(); }
83 
84  void Resolver::setForceResolve( bool yesno_r ) { _pimpl->setForceResolve( yesno_r ); }
85  bool Resolver::forceResolve() const { return _pimpl->forceResolve(); }
86 
87  void Resolver::setIgnoreAlreadyRecommended( bool yesno_r) { _pimpl->setIgnoreAlreadyRecommended( yesno_r ); }
88  bool Resolver::ignoreAlreadyRecommended() const { return _pimpl->ignoreAlreadyRecommended(); }
89 
90  void Resolver::setOnlyRequires( bool yesno_r ) { _pimpl->setOnlyRequires( yesno_r ); }
91  void Resolver::resetOnlyRequires() { _pimpl->setOnlyRequires( indeterminate ); }
92  bool Resolver::onlyRequires() const { return _pimpl->onlyRequires(); }
93 
94  void Resolver::setUpgradeMode( bool yesno_r ) { return _pimpl->setUpgradeMode( yesno_r ); }
95  bool Resolver::upgradeMode() const { return _pimpl->isUpgradeMode(); }
96 
97  void Resolver::setUpdateMode( bool yesno_r ) { return _pimpl->setUpdateMode( yesno_r ); }
98  bool Resolver::updateMode() const { return _pimpl->isUpdateMode(); }
99 
100  void Resolver::setSystemVerification( bool yesno_r ) { _pimpl->setVerifyingMode( yesno_r ); }
101  void Resolver::setDefaultSystemVerification() { _pimpl->setVerifyingMode( indeterminate ); }
102  bool Resolver::systemVerification() const { return _pimpl->isVerifyingMode(); }
103 
104  void Resolver::setSolveSrcPackages( bool yesno_r ) { _pimpl->setSolveSrcPackages( yesno_r ); }
105  void Resolver::setDefaultSolveSrcPackages() { _pimpl->setSolveSrcPackages( indeterminate ); }
106  bool Resolver::solveSrcPackages() const { return _pimpl->solveSrcPackages(); }
107 
108  void Resolver::setCleandepsOnRemove( bool yesno_r ) { _pimpl->setCleandepsOnRemove( yesno_r ); }
109  void Resolver::setDefaultCleandepsOnRemove() { _pimpl->setCleandepsOnRemove( indeterminate ); }
110  bool Resolver::cleandepsOnRemove() const { return _pimpl->cleandepsOnRemove(); }
111 
112 #define ZOLV_FLAG_BOOL( ZSETTER, ZGETTER ) \
113  void Resolver::ZSETTER( bool yesno_r ){ _pimpl->ZSETTER( yesno_r ); } \
114  bool Resolver::ZGETTER() const { return _pimpl->ZGETTER(); } \
115 
116 #define ZOLV_FLAG_TRIBOOL( ZSETTER, ZDEFAULT, ZGETTER ) \
117  ZOLV_FLAG_BOOL( ZSETTER , ZGETTER ) \
118  void Resolver::ZDEFAULT() { _pimpl->ZSETTER( indeterminate ); } \
119 
120  ZOLV_FLAG_TRIBOOL( setAllowDowngrade, setDefaultAllowDowngrade, allowDowngrade )
121  ZOLV_FLAG_TRIBOOL( setAllowNameChange, setDefaultAllowNameChange, allowNameChange )
122  ZOLV_FLAG_TRIBOOL( setAllowArchChange, setDefaultAllowArchChange, allowArchChange )
123  ZOLV_FLAG_TRIBOOL( setAllowVendorChange, setDefaultAllowVendorChange, allowVendorChange )
124 
125  ZOLV_FLAG_TRIBOOL( dupSetAllowDowngrade, dupSetDefaultAllowDowngrade, dupAllowDowngrade )
126  ZOLV_FLAG_TRIBOOL( dupSetAllowNameChange, dupSetDefaultAllowNameChange, dupAllowNameChange )
127  ZOLV_FLAG_TRIBOOL( dupSetAllowArchChange, dupSetDefaultAllowArchChange, dupAllowArchChange )
128  ZOLV_FLAG_TRIBOOL( dupSetAllowVendorChange, dupSetDefaultAllowVendorChange, dupAllowVendorChange )
129 
130 #undef ZOLV_FLAG_BOOL
131 #undef ZOLV_FLAG_TRIBOOL
132 
133  void Resolver::addUpgradeRepo( Repository repo_r ) { _pimpl->addUpgradeRepo( repo_r ); }
134  bool Resolver::upgradingRepos() const { return !_pimpl->upgradeRepos().empty(); }
135  bool Resolver::upgradingRepo( Repository repo_r ) const { return _pimpl->upgradingRepo( repo_r ); }
136  void Resolver::removeUpgradeRepo( Repository repo_r ) { _pimpl->removeUpgradeRepo( repo_r ); }
137  void Resolver::removeUpgradeRepos() { _pimpl->removeUpgradeRepos(); }
138 
139  void Resolver::addRequire( const Capability & capability ) { _pimpl->addExtraRequire( capability ); }
140  void Resolver::addConflict( const Capability & capability ) { _pimpl->addExtraConflict( capability ); }
141  void Resolver::removeRequire( const Capability & capability ) { _pimpl->removeExtraRequire( capability ); }
142  void Resolver::removeConflict( const Capability & capability ){ _pimpl->removeExtraConflict( capability ); }
143 
144  CapabilitySet Resolver::getRequire() const { return _pimpl->extraRequires(); }
145  CapabilitySet Resolver::getConflict() const { return _pimpl->extraConflicts(); }
146 
147  std::list<PoolItem> Resolver::problematicUpdateItems() const
148  { return _pimpl->problematicUpdateItems(); }
149 
150  bool Resolver::createSolverTestcase( const std::string & dumpPath, bool runSolver )
151  {
152  solver::detail::Testcase testcase (dumpPath);
153  return testcase.createTestcase(*_pimpl, true, runSolver);
154  }
155 
157  { return _pimpl->isInstalledBy (item); }
158 
160  { return _pimpl->installs (item); }
161 
163  { return _pimpl->satifiedByInstalled (item); }
164 
166  { return _pimpl->installedSatisfied (item); }
167 
169  { _pimpl->reset( false ); /* Do not keep extra requires/conflicts */ }
170 
171  std::ostream & operator<<( std::ostream & str, const Resolver & obj )
172  { return str << *obj._pimpl; }
173 
175 } // namespace zypp
void doUpdate()
Update to newest package.
Definition: Resolver.cc:78
solver::detail::ItemCapKindList installs(const PoolItem &item)
Gives information about WHICH additional items will be installed due the installation of an item.
Definition: Resolver.cc:159
std::list< ProblemSolution_Ptr > ProblemSolutionList
Definition: ProblemTypes.h:43
bool resolvePool()
Resolve package dependencies:
Definition: Resolver.cc:57
sat::Transaction getTransaction()
Return the Transaction computed by the last solver run.
Definition: Resolver.cc:72
bool upgradingRepos() const
Whether there is at least one UpgradeRepo request pending.
Definition: Resolver.cc:134
void addUpgradeRepo(Repository repo_r)
Adding request to perform a dist upgrade restricted to this repository.
Definition: Resolver.cc:133
bool createSolverTestcase(const std::string &dumpPath="/var/log/YaST2/solverTestcase", bool runSolver=true)
Generates a solver Testcase of the current state.
Definition: Resolver.cc:150
CapabilitySet getRequire() const
Get all the additional requirements set by addRequire(Capability).
Definition: Resolver.cc:144
ResolverFocus
The resolvers general attitude.
Definition: ResolverFocus.h:21
void setDefaultSolveSrcPackages()
Definition: Resolver.cc:105
void setCleandepsOnRemove(bool yesno_r)
Cleanup when deleting packages.
Definition: Resolver.cc:108
void removeRequire(const Capability &capability)
Remove the additional requirement set by addRequire(Capability).
Definition: Resolver.cc:141
String related utilities and Regular expression matching.
zypp::RW_pointer< solver::detail::ResolverInternal > _pimpl
Definition: Resolver.h:443
void setUpdateMode(bool yesno_r)
Setting whether the solver should perform in 'update' mode or not.
Definition: Resolver.cc:97
Definition: Arch.h:347
void setOnlyRequires(bool yesno_r)
Setting whether required packages are installed ONLY So recommended packages, language packages and p...
Definition: Resolver.cc:90
Libsolv transaction wrapper.
Definition: Transaction.h:51
void undo()
Definition: Resolver.cc:63
bool doUpgrade()
Do an distribution upgrade (DUP)
Definition: Resolver.cc:75
std::list< SolverQueueItem_Ptr > SolverQueueItemList
Definition: Types.h:45
solver::detail::ItemCapKindList isInstalledBy(const PoolItem &item)
Gives information about WHO has pused an installation of an given item.
Definition: Resolver.cc:156
bool resolveQueue(solver::detail::SolverQueueItemList &queue)
Resolve package dependencies:
Definition: Resolver.cc:60
bool ignoreAlreadyRecommended() const
Definition: Resolver.cc:88
ResolverProblemList problems()
Return the dependency problems found by the last call to resolveDependencies().
Definition: Resolver.cc:66
void removeUpgradeRepo(Repository repo_r)
Remove an upgrade request for this repo.
Definition: Resolver.cc:136
solver::detail::ItemCapKindList installedSatisfied(const PoolItem &item)
Gives information about WHICH items require an already installed item.
Definition: Resolver.cc:165
bool updateMode() const
Definition: Resolver.cc:98
CapabilitySet getConflict() const
Get all the additional conflicts set by addConflict(Capability).
Definition: Resolver.cc:145
void setUpgradeMode(bool yesno_r)
Setting whether the solver should perform in 'upgrade' mode or not.
Definition: Resolver.cc:94
solver::detail::ItemCapKindList satifiedByInstalled(const PoolItem &item)
Gives information about WHICH installed items are requested by the installation of an item.
Definition: Resolver.cc:162
void setDefaultCleandepsOnRemove()
Definition: Resolver.cc:109
std::list< ResolverProblem_Ptr > ResolverProblemList
Definition: ProblemTypes.h:46
Dependency resolver interface.
Definition: Resolver.h:44
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
#define ZOLV_FLAG_TRIBOOL(ZSETTER, ZDEFAULT, ZGETTER)
Definition: Resolver.cc:116
virtual ~Resolver()
Dtor.
Definition: Resolver.cc:46
std::list< PoolItem > problematicUpdateItems() const
Unmaintained packages which does not fit to the updated system (broken dependencies) will be deleted.
Definition: Resolver.cc:147
void resetOnlyRequires()
Definition: Resolver.cc:91
ResolverFocus focus() const
Definition: Resolver.cc:82
bool solveSrcPackages() const
Definition: Resolver.cc:106
bool forceResolve() const
Definition: Resolver.cc:85
void addConflict(const Capability &capability)
Adding additional conflict.
Definition: Resolver.cc:140
bool onlyRequires() const
Definition: Resolver.cc:92
bool cleandepsOnRemove() const
Definition: Resolver.cc:110
void setSystemVerification(bool yesno_r)
System verification mode also monitors and repairs dependencies of already installed packages.
Definition: Resolver.cc:100
void applySolutions(const ProblemSolutionList &solutions)
Apply problem solutions.
Definition: Resolver.cc:69
std::unordered_set< Capability > CapabilitySet
Definition: Capability.h:33
bool upgradeMode() const
Definition: Resolver.cc:95
Global ResObject pool.
Definition: ResPool.h:60
Resolver ResolverInternal
Preferred name in API.
Definition: Types.h:38
void addRequire(const Capability &capability)
Adding additional requirement.
Definition: Resolver.cc:139
std::list< ItemCapKind > ItemCapKindList
Definition: Types.h:41
A sat capability.
Definition: Capability.h:59
void removeConflict(const Capability &capability)
Remove the additional conflict set by addConflict(Capability).
Definition: Resolver.cc:142
bool verifySystem()
Resolve package dependencies:
Definition: Resolver.cc:54
void setForceResolve(bool force)
Remove resolvables which are conflicts with others or have unfulfilled requirements.
Definition: Resolver.cc:84
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
void setFocus(ResolverFocus focus_r)
Define the resolvers general attitude when resolving jobs.
Definition: Resolver.cc:81
void reset()
Definition: Resolver.cc:168
bool upgradingRepo(Repository repo_r) const
Whether there is an UpgradeRepo request pending for this repo.
Definition: Resolver.cc:135
void setIgnoreAlreadyRecommended(bool yesno_r)
Ignore recommended packages that were already recommended by the installed packages.
Definition: Resolver.cc:87
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
void setDefaultSystemVerification()
Definition: Resolver.cc:101
void removeUpgradeRepos()
Remove all upgrade repo requests.
Definition: Resolver.cc:137
#define IMPL_PTR_TYPE(NAME)
void setSolveSrcPackages(bool yesno_r)
Set whether to solve source packages build dependencies per default.
Definition: Resolver.cc:104
bool systemVerification() const
Definition: Resolver.cc:102