Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / zypp / solver / detail / Resolver.cc
index 8fd3f31..7801a50 100644 (file)
  */
 #include <boost/static_assert.hpp>
 
+#define ZYPP_USE_RESOLVER_INTERNALS
+
 #include "zypp/solver/detail/Resolver.h"
-#include "zypp/solver/detail/Helper.h"
 #include "zypp/solver/detail/Testcase.h"
 #include "zypp/solver/detail/SATResolver.h"
+#include "zypp/solver/detail/ItemCapKind.h"
+#include "zypp/solver/detail/SolutionAction.h"
+#include "zypp/solver/detail/SolverQueueItem.h"
 
 #include "zypp/Capabilities.h"
 #include "zypp/ZConfig.h"
@@ -40,6 +44,9 @@
 
 #define MAXSOLVERRUNS 5
 
+using std::endl;
+using std::make_pair;
+
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
 { ///////////////////////////////////////////////////////////////////////
@@ -50,10 +57,7 @@ namespace zypp
     namespace detail
     { ///////////////////////////////////////////////////////////////////
 
-using namespace std;
-
-IMPL_PTR_TYPE(Resolver);
-
+      //using namespace std;
 
 //---------------------------------------------------------------------------
 
@@ -111,10 +115,10 @@ Resolver::~Resolver()
     bool Resolver::ZGETTER() const                                                     \
     { return _satResolver->ZVARNAME; }                                                 \
 
-ZOLV_FLAG_TRIBOOL( dupSetAllowDowngrade,       dupAllowDowngrade,      _dup_allowdowngrade,    true )
-ZOLV_FLAG_TRIBOOL( dupSetAllowNameChange,      dupAllowNameChange,     _dup_allownamechange,   true )
-ZOLV_FLAG_TRIBOOL( dupSetAllowArchChange,      dupAllowArchChange,     _dup_allowarchchange,   true )
-ZOLV_FLAG_TRIBOOL( dupSetAllowVendorChange,    dupAllowVendorChange,   _dup_allowvendorchange, true )
+ZOLV_FLAG_TRIBOOL( dupSetAllowDowngrade,       dupAllowDowngrade,      _dup_allowdowngrade,    ZConfig::instance().solver_dupAllowDowngrade() )
+ZOLV_FLAG_TRIBOOL( dupSetAllowNameChange,      dupAllowNameChange,     _dup_allownamechange,   ZConfig::instance().solver_dupAllowNameChange() )
+ZOLV_FLAG_TRIBOOL( dupSetAllowArchChange,      dupAllowArchChange,     _dup_allowarchchange,   ZConfig::instance().solver_dupAllowArchChange() )
+ZOLV_FLAG_TRIBOOL( dupSetAllowVendorChange,    dupAllowVendorChange,   _dup_allowvendorchange, ZConfig::instance().solver_dupAllowVendorChange() )
 
 #undef ZOLV_FLAG_TRIBOOL
 //---------------------------------------------------------------------------
@@ -255,7 +259,7 @@ bool Resolver::verifySystem()
 {
     UndoTransact resetting (ResStatus::APPL_HIGH);
 
-    _DEBUG ("Resolver::verifySystem() ");
+    DBG << "Resolver::verifySystem()" << endl;
 
     _verifying = true;
 
@@ -392,14 +396,31 @@ ResolverProblemList Resolver::problems() const
 
 void Resolver::applySolutions( const ProblemSolutionList & solutions )
 {
-  for_( iter, solutions.begin(), solutions.end() )
+  for ( ProblemSolution_Ptr solution : solutions )
   {
-    ProblemSolution_Ptr solution = *iter;
-    if ( !solution->apply( *this ) )
+    if ( ! applySolution( *solution ) )
       break;
   }
 }
 
+bool Resolver::applySolution( const ProblemSolution & solution )
+{
+  bool ret = true;
+  DBG << "apply solution " << solution << endl;
+  for ( SolutionAction_Ptr action : solution.actions() )
+  {
+    if ( ! action->execute( *this ) )
+    {
+      WAR << "apply solution action failed: " << action << endl;
+      ret = false;
+      break;
+    }
+  }
+  return ret;
+}
+
+//----------------------------------------------------------------------------
+
 void Resolver::collectResolverInfo()
 {
     if ( _satResolver
@@ -427,7 +448,7 @@ void Resolver::collectResolverInfo()
                           && !found) {
                        alreadySetForInstallation = true;
                        ItemCapKind capKind = pos->second;
-                       if (capKind.item == *instIter)  found = true;
+                       if (capKind.item() == *instIter)  found = true;
                        pos++;
                    }
 
@@ -472,7 +493,7 @@ void Resolver::collectResolverInfo()
                               && !found) {
                            alreadySetForInstallation = true;
                            ItemCapKind capKind = pos->second;
-                           if (capKind.item == *instIter)  found = true;
+                           if (capKind.item() == *instIter)  found = true;
                            pos++;
                        }
 
@@ -515,7 +536,7 @@ void Resolver::collectResolverInfo()
                               && !found) {
                            alreadySetForInstallation = true;
                            ItemCapKind capKind = pos->second;
-                           if (capKind.item == provider)  found = true;
+                           if (capKind.item() == provider)  found = true;
                            pos++;
                        }