Imported Upstream version 15.10.0
[platform/upstream/libzypp.git] / zypp / sat / Transaction.cc
index ca8e5ad..d351aa4 100644 (file)
 extern "C"
 {
 #include <solv/transaction.h>
-#include <solv/bitmap.h>
+#include <solv/solver.h>
 }
 #include <iostream>
 #include "zypp/base/LogTools.h"
 #include "zypp/base/SerialNumber.h"
 #include "zypp/base/DefaultIntegral.h"
 #include "zypp/base/NonCopyable.h"
-#include "zypp/base/Tr1hash.h"
+#include "zypp/base/Hash.h"
 
 #include "zypp/sat/detail/PoolImpl.h"
 #include "zypp/sat/Transaction.h"
 #include "zypp/sat/Solvable.h"
 #include "zypp/sat/Queue.h"
+#include "zypp/sat/Map.h"
 #include "zypp/ResPool.h"
 
 using std::endl;
@@ -49,8 +50,8 @@ namespace zypp
       friend std::ostream & operator<<( std::ostream & str, const Impl & obj );
 
       public:
-       typedef std::tr1::unordered_set<detail::IdType> set_type;
-       typedef std::tr1::unordered_map<detail::IdType,detail::IdType> map_type;
+       typedef std::unordered_set<detail::IdType> set_type;
+       typedef std::unordered_map<detail::IdType,detail::IdType> map_type;
 
        struct PostMortem
        {
@@ -66,14 +67,14 @@ namespace zypp
          Edition  _edition;
          Arch     _arch;
        };
-       typedef std::tr1::unordered_map<detail::IdType,PostMortem> pmmap_type;
+       typedef std::unordered_map<detail::IdType,PostMortem> pmmap_type;
 
       public:
        Impl()
          : _trans( ::transaction_create( nullptr ) )
-       { memset( _trans, 0, sizeof(_trans) ); }
+       { memset( _trans, 0, sizeof(*_trans) ); }
 
-       Impl( ::_Transaction & trans_r )
+       Impl( LoadFromPoolType )
          : _watcher( myPool().serial() )
          , _trans( nullptr )
        {
@@ -85,9 +86,15 @@ namespace zypp
            sat::Solvable solv( (*it).satSolvable() );
            decisionq.push( solv.isSystem() ? -solv.id() : solv.id() );
          }
-         if ( trans_r.noobsmap.size )
-           ::map_grow( &trans_r.noobsmap, myPool()->nsolvables );
-         _trans = ::transaction_create_decisionq( myPool().getPool(), decisionq, &trans_r.noobsmap );
+         Queue noobsq;
+         for_( it, sat::Pool::instance().multiversionBegin(), sat::Pool::instance().multiversionEnd() )
+         {
+           noobsq.push( SOLVER_NOOBSOLETES | SOLVER_SOLVABLE_NAME );
+           noobsq.push( it->id() );
+         }
+         Map noobsmap;
+         ::solver_calculate_noobsmap( myPool().getPool(), noobsq, noobsmap );
+         _trans = ::transaction_create_decisionq( myPool().getPool(), decisionq, noobsmap );
 
          // NOTE: package/product buddies share the same ResStatus
          // so we also link the buddies stepStages. This assumes
@@ -179,6 +186,16 @@ namespace zypp
        { detail::IdType * it( _find( solv_r ) ); return it ? iterator( self_r, it ) : end( self_r ); }
 
       public:
+       int installedResult( Queue & result_r ) const
+       { return ::transaction_installedresult( _trans, result_r ); }
+
+       StringQueue autoInstalled() const
+       { return _autoInstalled; }
+
+       void autoInstalled( const StringQueue & queue_r )
+       { _autoInstalled = queue_r; }
+
+      public:
        StepType stepType( Solvable solv_r ) const
        {
          if ( ! solv_r )
@@ -270,6 +287,8 @@ namespace zypp
        set_type        _systemErase;   // @System packages to be eased (otherse are TRANSACTION_IGNORE)
        pmmap_type      _pmMap;         // Post mortem data of deleted @System solvables
 
+       StringQueue     _autoInstalled; // ident strings of all packages that would be auto-installed after the transaction is run.
+
       public:
         /** Offer default Impl. */
         static shared_ptr<Impl> nullimpl()
@@ -295,8 +314,8 @@ namespace zypp
       : _pimpl( Impl::nullimpl() )
     {}
 
-    Transaction::Transaction( ::_Transaction & trans_r )
-      : _pimpl( new Impl( trans_r ) )
+    Transaction::Transaction( LoadFromPoolType )
+      : _pimpl( new Impl( loadFromPool ) )
     {}
 
     Transaction::~Transaction()
@@ -332,6 +351,15 @@ namespace zypp
     Transaction::iterator Transaction::find( const sat::Solvable & solv_r )
     { return _pimpl->find( _pimpl, solv_r ); }
 
+    int Transaction::installedResult( Queue & result_r ) const
+    { return _pimpl->installedResult( result_r ); }
+
+    StringQueue Transaction::autoInstalled() const
+    { return _pimpl->autoInstalled(); }
+
+    void Transaction::autoInstalled( const StringQueue & queue_r )
+    { _pimpl->autoInstalled( queue_r ); }
+
     std::ostream & operator<<( std::ostream & str, const Transaction & obj )
     { return str << *obj._pimpl; }