Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / Resolver.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/Resolver.cc
10  *
11 */
12 #include <iostream>
13
14 #include "zypp/Resolver.h"
15 #include "zypp/ZConfig.h"
16 #include "zypp/TriBool.h"
17 #include "zypp/solver/detail/Resolver.h"
18 #include "zypp/solver/detail/Testcase.h"
19 #include "zypp/sat/Transaction.h"
20
21 using namespace std;
22
23 ///////////////////////////////////////////////////////////////////
24 namespace zypp
25 { /////////////////////////////////////////////////////////////////
26
27   using namespace solver;
28
29   IMPL_PTR_TYPE(Resolver);
30
31   ///////////////////////////////////////////////////////////////////
32   //
33   //    METHOD NAME : Resolver::Resolver
34   //    METHOD TYPE : Ctor
35   //
36   Resolver::Resolver( const ResPool & pool )
37   : _pimpl( new Impl(pool) )
38   {}
39
40   ///////////////////////////////////////////////////////////////////
41   //
42   //    METHOD NAME : Resolver::~Resolver
43   //    METHOD TYPE : Dtor
44   //
45   Resolver::~Resolver()
46   {}
47
48   ///////////////////////////////////////////////////////////////////
49   //
50   //    Resolver interface forwarded to implementation
51   //
52   ///////////////////////////////////////////////////////////////////
53   bool Resolver::verifySystem ()
54   { return _pimpl->verifySystem(); }
55
56   bool Resolver::resolvePool ()
57   { return _pimpl->resolvePool(); }
58
59   bool Resolver::resolveQueue( solver::detail::SolverQueueItemList & queue )
60   { return _pimpl->resolveQueue(queue); }
61
62   void Resolver::undo()
63   { _pimpl->undo(); }
64
65   ResolverProblemList Resolver::problems ()
66   { return _pimpl->problems (); }
67
68   void Resolver::applySolutions( const ProblemSolutionList & solutions )
69   { _pimpl->applySolutions (solutions); }
70
71   sat::Transaction Resolver::getTransaction()
72   { return _pimpl->getTransaction(); }
73
74   bool Resolver::doUpgrade()
75   { return _pimpl->doUpgrade(); }
76
77   void Resolver::doUpdate()
78   { _pimpl->doUpdate(); }
79
80   void Resolver::setForceResolve( bool yesno_r )        { _pimpl->setForceResolve( yesno_r ); }
81   bool Resolver::forceResolve() const                   { return _pimpl->forceResolve(); }
82
83   void Resolver::setIgnoreAlreadyRecommended( bool yesno_r) { _pimpl->setIgnoreAlreadyRecommended( yesno_r ); }
84   bool Resolver::ignoreAlreadyRecommended() const       { return _pimpl->ignoreAlreadyRecommended(); }
85
86   void Resolver::setOnlyRequires( bool yesno_r )        { _pimpl->setOnlyRequires( yesno_r ); }
87   void Resolver::resetOnlyRequires()                    { _pimpl->setOnlyRequires( indeterminate ); }
88   bool Resolver::onlyRequires() const                   { return _pimpl->onlyRequires(); }
89
90   void Resolver::setUpgradeMode( bool yesno_r )         { return _pimpl->setUpgradeMode( yesno_r ); }
91   bool Resolver::upgradeMode() const                    { return _pimpl->isUpgradeMode(); }
92
93   void Resolver::setAllowVendorChange( bool yesno_r )   { _pimpl->setAllowVendorChange( yesno_r ); }
94   void Resolver::setDefaultAllowVendorChange()          { _pimpl->setAllowVendorChange( indeterminate ); }
95   bool Resolver::allowVendorChange() const              { return _pimpl->allowVendorChange(); }
96
97   void Resolver::setSystemVerification( bool yesno_r )  { _pimpl->setVerifyingMode( yesno_r ); }
98   void Resolver::setDefaultSystemVerification()         { _pimpl->setVerifyingMode( indeterminate ); }
99   bool Resolver::systemVerification() const             { return _pimpl->isVerifyingMode(); }
100
101   void Resolver::setSolveSrcPackages( bool yesno_r )    { _pimpl->setSolveSrcPackages( yesno_r ); }
102   void Resolver::setDefaultSolveSrcPackages()           { _pimpl->setSolveSrcPackages( indeterminate ); }
103   bool Resolver::solveSrcPackages() const               { return _pimpl->solveSrcPackages(); }
104
105   void Resolver::setCleandepsOnRemove( bool yesno_r )   { _pimpl->setCleandepsOnRemove( yesno_r ); }
106   void Resolver::setDefaultCleandepsOnRemove()          { _pimpl->setCleandepsOnRemove( indeterminate ); }
107   bool Resolver::cleandepsOnRemove() const              { return _pimpl->cleandepsOnRemove(); }
108
109 #define ZOLV_FLAG_BOOL( ZSETTER, ZGETTER )                                      \
110   void Resolver::ZSETTER( bool yesno_r ){ _pimpl->ZSETTER( yesno_r ); }         \
111   bool Resolver::ZGETTER() const        { return _pimpl->ZGETTER(); }           \
112
113 #define ZOLV_FLAG_TRIBOOL( ZSETTER, ZDEFAULT, ZGETTER )                         \
114   ZOLV_FLAG_BOOL( ZSETTER , ZGETTER )                                           \
115   void Resolver::ZDEFAULT()             { _pimpl->ZSETTER( indeterminate ); }   \
116
117   ZOLV_FLAG_TRIBOOL( dupSetAllowDowngrade,      dupSetDefaultAllowDowngrade,    dupAllowDowngrade )
118   ZOLV_FLAG_TRIBOOL( dupSetAllowNameChange,     dupSetDefaultAllowNameChange,   dupAllowNameChange )
119   ZOLV_FLAG_TRIBOOL( dupSetAllowArchChange,     dupSetDefaultAllowArchChange,   dupAllowArchChange )
120   ZOLV_FLAG_TRIBOOL( dupSetAllowVendorChange,   dupSetDefaultAllowVendorChange, dupAllowVendorChange )
121
122 #undef ZOLV_FLAG_BOOL
123 #undef ZOLV_FLAG_TRIBOOL
124
125   void Resolver::addUpgradeRepo( Repository repo_r )    { _pimpl->addUpgradeRepo( repo_r ); }
126   bool Resolver::upgradingRepos() const                 { return !_pimpl->upgradeRepos().empty(); }
127   bool Resolver::upgradingRepo( Repository repo_r ) const { return _pimpl->upgradingRepo( repo_r ); }
128   void Resolver::removeUpgradeRepo( Repository repo_r ) { _pimpl->removeUpgradeRepo( repo_r ); }
129   void Resolver::removeUpgradeRepos()                   { _pimpl->removeUpgradeRepos(); }
130
131   void Resolver::addRequire( const Capability & capability )    { _pimpl->addExtraRequire( capability ); }
132   void Resolver::addConflict( const Capability & capability )   { _pimpl->addExtraConflict( capability ); }
133   void Resolver::removeRequire( const Capability & capability ) { _pimpl->removeExtraRequire( capability ); }
134   void Resolver::removeConflict( const Capability & capability ){ _pimpl->removeExtraConflict( capability ); }
135
136   CapabilitySet Resolver::getRequire() const    { return _pimpl->extraRequires(); }
137   CapabilitySet Resolver::getConflict() const   { return _pimpl->extraConflicts(); }
138
139   std::list<PoolItem> Resolver::problematicUpdateItems() const
140   { return _pimpl->problematicUpdateItems(); }
141
142   bool Resolver::createSolverTestcase( const std::string & dumpPath, bool runSolver )
143   {
144     solver::detail::Testcase testcase (dumpPath);
145     return testcase.createTestcase(*_pimpl, true, runSolver);
146   }
147
148   solver::detail::ItemCapKindList Resolver::isInstalledBy( const PoolItem & item )
149   { return _pimpl->isInstalledBy (item); }
150
151   solver::detail::ItemCapKindList Resolver::installs( const PoolItem & item )
152   { return _pimpl->installs (item); }
153
154   solver::detail::ItemCapKindList Resolver::satifiedByInstalled( const PoolItem & item )
155   { return _pimpl->satifiedByInstalled (item); }
156
157   solver::detail::ItemCapKindList Resolver::installedSatisfied( const PoolItem & item )
158   { return _pimpl->installedSatisfied (item); }
159
160   void Resolver::reset()
161   { _pimpl->reset( false ); /* Do not keep extra requires/conflicts */ }
162
163   std::ostream & operator<<( std::ostream & str, const Resolver & obj )
164   { return str << *obj._pimpl; }
165
166   /////////////////////////////////////////////////////////////////
167 } // namespace zypp
168 ///////////////////////////////////////////////////////////////////