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