libzypp  17.3.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::setOnlyRequires( bool yesno_r ) { _pimpl->setOnlyRequires( yesno_r ); }
90  void Resolver::resetOnlyRequires() { _pimpl->setOnlyRequires( indeterminate ); }
91  bool Resolver::onlyRequires() const { return _pimpl->onlyRequires(); }
92 
93  void Resolver::setUpgradeMode( bool yesno_r ) { return _pimpl->setUpgradeMode( yesno_r ); }
94  bool Resolver::upgradeMode() const { return _pimpl->isUpgradeMode(); }
95 
96  void Resolver::setUpdateMode( bool yesno_r ) { return _pimpl->setUpdateMode( yesno_r ); }
97  bool Resolver::updateMode() const { return _pimpl->isUpdateMode(); }
98 
99  void Resolver::setSystemVerification( bool yesno_r ) { _pimpl->setVerifyingMode( yesno_r ); }
100  void Resolver::setDefaultSystemVerification() { _pimpl->setVerifyingMode( indeterminate ); }
101  bool Resolver::systemVerification() const { return _pimpl->isVerifyingMode(); }
102 
103  void Resolver::setSolveSrcPackages( bool yesno_r ) { _pimpl->setSolveSrcPackages( yesno_r ); }
104  void Resolver::setDefaultSolveSrcPackages() { _pimpl->setSolveSrcPackages( indeterminate ); }
105  bool Resolver::solveSrcPackages() const { return _pimpl->solveSrcPackages(); }
106 
107  void Resolver::setCleandepsOnRemove( bool yesno_r ) { _pimpl->setCleandepsOnRemove( yesno_r ); }
108  void Resolver::setDefaultCleandepsOnRemove() { _pimpl->setCleandepsOnRemove( indeterminate ); }
109  bool Resolver::cleandepsOnRemove() const { return _pimpl->cleandepsOnRemove(); }
110 
111 #define ZOLV_FLAG_BOOL( ZSETTER, ZGETTER ) \
112  void Resolver::ZSETTER( bool yesno_r ){ _pimpl->ZSETTER( yesno_r ); } \
113  bool Resolver::ZGETTER() const { return _pimpl->ZGETTER(); } \
114 
115 #define ZOLV_FLAG_TRIBOOL( ZSETTER, ZDEFAULT, ZGETTER ) \
116  ZOLV_FLAG_BOOL( ZSETTER , ZGETTER ) \
117  void Resolver::ZDEFAULT() { _pimpl->ZSETTER( indeterminate ); } \
118 
123 
128 
129 #undef ZOLV_FLAG_BOOL
130 #undef ZOLV_FLAG_TRIBOOL
131 
132  void Resolver::addUpgradeRepo( Repository repo_r ) { _pimpl->addUpgradeRepo( repo_r ); }
133  bool Resolver::upgradingRepos() const { return !_pimpl->upgradeRepos().empty(); }
134  bool Resolver::upgradingRepo( Repository repo_r ) const { return _pimpl->upgradingRepo( repo_r ); }
135  void Resolver::removeUpgradeRepo( Repository repo_r ) { _pimpl->removeUpgradeRepo( repo_r ); }
136  void Resolver::removeUpgradeRepos() { _pimpl->removeUpgradeRepos(); }
137 
138  void Resolver::addRequire( const Capability & capability ) { _pimpl->addExtraRequire( capability ); }
139  void Resolver::addConflict( const Capability & capability ) { _pimpl->addExtraConflict( capability ); }
140  void Resolver::removeRequire( const Capability & capability ) { _pimpl->removeExtraRequire( capability ); }
141  void Resolver::removeConflict( const Capability & capability ){ _pimpl->removeExtraConflict( capability ); }
142 
143  CapabilitySet Resolver::getRequire() const { return _pimpl->extraRequires(); }
144  CapabilitySet Resolver::getConflict() const { return _pimpl->extraConflicts(); }
145 
146  std::list<PoolItem> Resolver::problematicUpdateItems() const
147  { return _pimpl->problematicUpdateItems(); }
148 
149  bool Resolver::createSolverTestcase( const std::string & dumpPath, bool runSolver )
150  {
151  solver::detail::Testcase testcase (dumpPath);
152  return testcase.createTestcase(*_pimpl, true, runSolver);
153  }
154 
156  { return _pimpl->isInstalledBy (item); }
157 
159  { return _pimpl->installs (item); }
160 
162  { return _pimpl->satifiedByInstalled (item); }
163 
165  { return _pimpl->installedSatisfied (item); }
166 
168  { _pimpl->reset( false ); /* Do not keep extra requires/conflicts */ }
169 
170  std::ostream & operator<<( std::ostream & str, const Resolver & obj )
171  { return str << *obj._pimpl; }
172 
174 } // namespace zypp
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:158
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:133
void addUpgradeRepo(Repository repo_r)
Adding request to perform a dist upgrade restricted to this repository.
Definition: Resolver.cc:132
void setDefaultAllowVendorChange()
bool createSolverTestcase(const std::string &dumpPath="/var/log/YaST2/solverTestcase", bool runSolver=true)
Generates a solver Testcase of the current state.
Definition: Resolver.cc:149
CapabilitySet getRequire() const
Get all the additional requirements set by addRequire(Capability).
Definition: Resolver.cc:143
void setAllowDowngrade(bool yesno_r)
Whether to allow to downgrade installed solvable.
bool dupAllowVendorChange() const
void setAllowNameChange(bool yesno_r)
Whether to allow to change name of installed solvable.
void setDefaultSolveSrcPackages()
Definition: Resolver.cc:104
void setCleandepsOnRemove(bool yesno_r)
Cleanup when deleting packages.
Definition: Resolver.cc:107
void removeRequire(const Capability &capability)
Remove the additional requirement set by addRequire(Capability).
Definition: Resolver.cc:140
void dupSetDefaultAllowNameChange()
void dupSetAllowNameChange(bool yesno_r)
dup mode: allow to change name of installed solvable
void setAllowVendorChange(bool yesno_r)
Whether to allow to change vendor of installed solvables.
String related utilities and Regular expression matching.
zypp::RW_pointer< solver::detail::ResolverInternal > _pimpl
Definition: Resolver.h:445
void setUpdateMode(bool yesno_r)
Setting whether the solver should perform in &#39;update&#39; mode or not.
Definition: Resolver.cc:96
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:89
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
friend std::ostream & operator<<(std::ostream &str, const Resolver &obj)
Definition: Resolver.cc:170
solver::detail::ItemCapKindList isInstalledBy(const PoolItem &item)
Gives information about WHO has pused an installation of an given item.
Definition: Resolver.cc:155
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:135
solver::detail::ItemCapKindList installedSatisfied(const PoolItem &item)
Gives information about WHICH items require an already installed item.
Definition: Resolver.cc:164
bool updateMode() const
Definition: Resolver.cc:97
void setDefaultAllowArchChange()
CapabilitySet getConflict() const
Get all the additional conflicts set by addConflict(Capability).
Definition: Resolver.cc:144
void setUpgradeMode(bool yesno_r)
Setting whether the solver should perform in &#39;upgrade&#39; mode or not.
Definition: Resolver.cc:93
solver::detail::ItemCapKindList satifiedByInstalled(const PoolItem &item)
Gives information about WHICH installed items are requested by the installation of an item...
Definition: Resolver.cc:161
void setDefaultCleandepsOnRemove()
Definition: Resolver.cc:108
std::list< ResolverProblem_Ptr > ResolverProblemList
Definition: ProblemTypes.h:46
Dependency resolver interface.
Definition: Resolver.h:53
void setDefaultAllowNameChange()
#define ZOLV_FLAG_TRIBOOL(ZSETTER, ZDEFAULT, ZGETTER)
Definition: Resolver.cc:115
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:146
void resetOnlyRequires()
Definition: Resolver.cc:90
void dupSetDefaultAllowArchChange()
bool solveSrcPackages() const
Definition: Resolver.cc:105
void setAllowArchChange(bool yesno_r)
Whether to allow to change architecture of installed solvables.
bool forceResolve() const
Definition: Resolver.cc:84
void setDefaultAllowDowngrade()
void addConflict(const Capability &capability)
Adding additional conflict.
Definition: Resolver.cc:139
bool onlyRequires() const
Definition: Resolver.cc:91
bool allowDowngrade() const
bool cleandepsOnRemove() const
Definition: Resolver.cc:109
void setSystemVerification(bool yesno_r)
System verification mode also monitors and repairs dependencies of already installed packages...
Definition: Resolver.cc:99
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:94
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:138
std::list< ItemCapKind > ItemCapKindList
Definition: Types.h:41
bool allowNameChange() const
void dupSetDefaultAllowDowngrade()
bool dupAllowNameChange() const
A sat capability.
Definition: Capability.h:59
void removeConflict(const Capability &capability)
Remove the additional conflict set by addConflict(Capability).
Definition: Resolver.cc:141
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 dupSetAllowDowngrade(bool yesno_r)
dup mode: allow to downgrade installed solvable
void dupSetAllowArchChange(bool yesno_r)
dup mode: allow to change architecture of installed solvables
bool allowVendorChange() const
void reset()
Definition: Resolver.cc:167
bool upgradingRepo(Repository repo_r) const
Whether there is an UpgradeRepo request pending for this repo.
Definition: Resolver.cc:134
void setIgnoreAlreadyRecommended(bool yesno_r)
Ignore recommended packages that were already recommended by the installed packages.
Definition: Resolver.cc:86
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
void dupSetDefaultAllowVendorChange()
void setDefaultSystemVerification()
Definition: Resolver.cc:100
void removeUpgradeRepos()
Remove all upgrade repo requests.
Definition: Resolver.cc:136
void dupSetAllowVendorChange(bool yesno_r)
dup mode: allow to change vendor of installed solvables
#define IMPL_PTR_TYPE(NAME)
void setSolveSrcPackages(bool yesno_r)
Set whether to solve source packages build dependencies per default.
Definition: Resolver.cc:103
bool systemVerification() const
Definition: Resolver.cc:101
bool dupAllowDowngrade() const
bool allowArchChange() const
bool dupAllowArchChange() const