backup
authorMichael Andres <ma@suse.de>
Mon, 20 Jul 2009 15:41:00 +0000 (17:41 +0200)
committerMichael Andres <ma@suse.de>
Mon, 20 Jul 2009 15:41:00 +0000 (17:41 +0200)
devel/devel.ma/Main.cc
zypp/ZYppCommitPolicy.cc
zypp/ZYppCommitPolicy.h
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h

index 55c0f42..867fa96 100644 (file)
@@ -1,11 +1,13 @@
 #include "Tools.h"
 
 #include <zypp/PoolQuery.h>
+#include <zypp/target/rpm/librpmDb.h>
 
 ///////////////////////////////////////////////////////////////////
 
 //static const Pathname sysRoot( getenv("SYSROOT") ? getenv("SYSROOT") : "/Local/ROOT" );
 static const Pathname sysRoot( "/tmp/Local/ma/DNL-test" );
+//static const Pathname sysRoot( "/" );
 
 ///////////////////////////////////////////////////////////////////
 
@@ -14,17 +16,45 @@ bool solve()
   bool rres = false;
   {
     //zypp::base::LogControl::TmpLineWriter shutUp;
-    //rres = test.resolver().resolvePool();
+    rres = getZYpp()->resolver()->resolvePool();
   }
   if ( ! rres )
   {
     ERR << "resolve " << rres << endl;
+    getZYpp()->resolver()->problems();
     return false;
   }
   MIL << "resolve " << rres << endl;
   return true;
 }
 
+bool upgrade()
+{
+  bool rres = false;
+  {
+    //zypp::base::LogControl::TmpLineWriter shutUp;
+    Measure x( "Upgrade" );
+    rres = getZYpp()->resolver()->doUpgrade();
+  }
+  if ( ! rres )
+  {
+    Measure x( "Upgrade Error" );
+    ERR << "upgrade " << rres << endl;
+    getZYpp()->resolver()->problems();
+    return false;
+  }
+  MIL << "upgrade " << rres << endl;
+  return true;
+}
+
+namespace zypp
+{
+  namespace target
+  {
+    void writeUpgradeTestcase();
+  }
+}
+
 int main( int argc, char * argv[] )
 try {
   --argc;
@@ -33,6 +63,7 @@ try {
   INT << "===[START]==========================================" << endl;
   ZConfig::instance();
   TestSetup::LoadSystemAt( sysRoot );
+  getZYpp()->initializeTarget( sysRoot );
   ///////////////////////////////////////////////////////////////////
   ResPool   pool( ResPool::instance() );
   sat::Pool satpool( sat::Pool::instance() );
@@ -41,12 +72,25 @@ try {
   USR << "pool: " << pool << endl;
   ///////////////////////////////////////////////////////////////////
 
+  if ( 1 )
+  {
+    getZYpp()->resolver()->addRequire( Capability("emacs") );
+    solve();
+    vdumpPoolStats( USR << "Transacting:"<< endl,
+                    make_filter_begin<resfilter::ByTransact>(pool),
+                    make_filter_end<resfilter::ByTransact>(pool) ) << endl;
+  }
+
 
-  getZYpp()->resolver()->addRequire( Capability("xteddy") );
-  solve();
-  vdumpPoolStats( USR << "Transacting:"<< endl,
-                  make_filter_begin<resfilter::ByTransact>(pool),
-                  make_filter_end<resfilter::ByTransact>(pool) ) << endl;
+  {
+    ZYppCommitPolicy policy;
+    policy.downloadMode( DownloadOnly );
+    //policy.dryRun( true );
+
+    USR << policy << endl;
+    ZYppCommitResult result( getZYpp()->commit( policy ) );
+    USR << result << endl;
+  }
 
 
   ///////////////////////////////////////////////////////////////////
index 05c2c6d..c39c25c 100644 (file)
 #include "zypp/base/String.h"
 
 #include "zypp/ZConfig.h"
-
 #include "zypp/ZYppCommitPolicy.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
 
+  std::ostream & operator<<( std::ostream & str, DownloadMode obj )
+  {
+    switch ( obj )
+    {
+#define OUTS(VAL) case VAL: return str << #VAL; break
+      OUTS( DownloadOnly );
+      OUTS( DownloadInAdvance );
+      OUTS( DownloadImHeaps );
+      OUTS( DownloadAsNeeded );
+#undef OUTS
+    }
+    return str << "DownloadMode(" << int(obj) << ")";
+  }
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : ZYppCommitPolicy::Impl
+  //
+  ///////////////////////////////////////////////////////////////////
+
+  class ZYppCommitPolicy::Impl
+  {
+    public:
+      Impl()
+      : _restrictToMedia       ( 0 )
+      , _dryRun                        ( false )
+      , _downloadMode          ( DownloadAsNeeded )
+      , _rpmInstFlags          ( ZConfig::instance().rpmInstallFlags() )
+      , _syncPoolAfterCommit   ( true )
+      {}
+
+    public:
+      unsigned                 _restrictToMedia;
+      bool                     _dryRun;
+      DownloadMode             _downloadMode;
+      target::rpm::RpmInstFlags        _rpmInstFlags;
+      bool                     _syncPoolAfterCommit;
+
+    private:
+      friend Impl * rwcowClone<Impl>( const Impl * rhs );
+      /** clone for RWCOW_pointer */
+      Impl * clone() const { return new Impl( *this ); }
+  };
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : ZYppCommitPolicy
+  //
+  ///////////////////////////////////////////////////////////////////
+
   ZYppCommitPolicy::ZYppCommitPolicy()
-      : _restrictToMedia    ( 0 )
-      , _dryRun             ( false )
-      , _rpmInstFlags       ( ZConfig::instance().rpmInstallFlags() )
-      , _syncPoolAfterCommit( true )
+  : _pimpl( new Impl )
   {}
 
+
+  ZYppCommitPolicy & ZYppCommitPolicy::restrictToMedia( unsigned mediaNr_r )
+  { _pimpl->_restrictToMedia = ( mediaNr_r == 1 ) ? 1 : 0; return *this; }
+
+  unsigned ZYppCommitPolicy::restrictToMedia() const
+  { return _pimpl->_restrictToMedia; }
+
+
+  ZYppCommitPolicy & ZYppCommitPolicy::dryRun( bool yesNo_r )
+  { _pimpl->_dryRun = yesNo_r; return *this; }
+
+  bool ZYppCommitPolicy::dryRun() const
+  { return _pimpl->_dryRun; }
+
+
+  ZYppCommitPolicy & ZYppCommitPolicy::downloadMode( DownloadMode val_r )
+  { _pimpl->_downloadMode = val_r; return *this; }
+
+  DownloadMode ZYppCommitPolicy::downloadMode() const
+  { return _pimpl->_downloadMode; }
+
+
+  ZYppCommitPolicy &  ZYppCommitPolicy::rpmInstFlags( target::rpm::RpmInstFlags newFlags_r )
+  { _pimpl->_rpmInstFlags = newFlags_r; return *this; }
+
+  ZYppCommitPolicy & ZYppCommitPolicy::rpmNoSignature( bool yesNo_r )
+  { _pimpl->_rpmInstFlags.setFlag( target::rpm::RPMINST_NOSIGNATURE, yesNo_r ); return *this; }
+
+  ZYppCommitPolicy & ZYppCommitPolicy::rpmExcludeDocs( bool yesNo_r )
+  { _pimpl->_rpmInstFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS, yesNo_r ); return *this; }
+
+  target::rpm::RpmInstFlags ZYppCommitPolicy::rpmInstFlags() const
+  { return _pimpl->_rpmInstFlags; }
+
+  bool ZYppCommitPolicy::rpmNoSignature() const
+  { return _pimpl->_rpmInstFlags.testFlag( target::rpm::RPMINST_NOSIGNATURE ); }
+
+  bool ZYppCommitPolicy::rpmExcludeDocs() const
+  { return _pimpl->_rpmInstFlags.testFlag( target::rpm::RPMINST_EXCLUDEDOCS ); }
+
+
+  ZYppCommitPolicy & ZYppCommitPolicy::syncPoolAfterCommit( bool yesNo_r )
+  { _pimpl->_syncPoolAfterCommit = yesNo_r; return *this; }
+
+  bool ZYppCommitPolicy::syncPoolAfterCommit() const
+  { return _pimpl->_syncPoolAfterCommit; }
+
+
   std::ostream & operator<<( std::ostream & str, const ZYppCommitPolicy & obj )
   {
     str << "CommitPolicy(";
@@ -36,6 +130,7 @@ namespace zypp
       str << " restrictToMedia:" << obj.restrictToMedia();
     if ( obj.dryRun() )
       str << " dryRun";
+    str << " " << obj.downloadMode();
     if ( obj.syncPoolAfterCommit() )
       str << " syncPoolAfterCommit";
     if ( obj.rpmInstFlags() )
index 90b79d3..3773956 100644 (file)
 
 #include <iosfwd>
 
+#include "zypp/base/PtrTypes.h"
+
 #include "zypp/target/rpm/RpmFlags.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
 
+  /** Supported commit download policies. */
+  enum DownloadMode
+  {
+    DownloadOnly,      //!< Just download all packages to the local cache.
+                       //!< Do not install. Implies a dry-run.
+    DownloadInAdvance, //!< First download all packages to the local cache.
+                       //!< Then start to install.
+    DownloadImHeaps,   //!< Similar to DownloadInAdvance, but try to split
+                       //!< the transaction into heaps, where at the end of
+                       //!< each heap a consistent system state is reached.
+    DownloadAsNeeded   //!< Alternating download and install. Packages are
+                       //!< cached just to avid CD/DVD hopping. This is the
+                       //!< traditional behaviour.
+  };
+
+  /** \relates DownloadMode Stream output. */
+  std::ostream & operator<<( std::ostream & str, DownloadMode obj );
+
   ///////////////////////////////////////////////////////////////////
   //
   //   CLASS NAME : ZYppCommitPolicy
@@ -27,67 +47,70 @@ namespace zypp
   /** */
   class ZYppCommitPolicy
   {
-  public:
-    ZYppCommitPolicy();
+    public:
+
+      ZYppCommitPolicy();
+
+    public:
+      /** Restrict commit to media 1.
+       * Fake outstanding YCP fix: Honour restriction to media 1
+       * at installation, but install all remaining packages if
+       * post-boot (called with <tt>mediaNr_r &gt; 1</tt>).
+       */
+      ZYppCommitPolicy & restrictToMedia( unsigned mediaNr_r );
+
+      /** Process all media (default) */
+      ZYppCommitPolicy & allMedia()
+      { return restrictToMedia( 0 ); }
+
+      unsigned restrictToMedia() const;
+
+
+      /** Set dry run (default: false).
+       * Dry-run should not change anything on the system, unless
+       * the \ref downloadMode is set to \ref DownloadOnly. In that
+       * case packages are downloaded to the local cache.
+      */
+      ZYppCommitPolicy & dryRun( bool yesNo_r );
 
-  public:
-    unsigned restrictToMedia() const
-    { return _restrictToMedia; }
+      bool dryRun() const;
 
-    bool dryRun() const
-    { return _dryRun; }
 
-    target::rpm::RpmInstFlags rpmInstFlags() const
-    { return _rpmInstFlags; }
+      /** Commit download policy to use. (default: \ref DownloadAsNeeded)
+       *  \note \ref DownloadOnly also implies a \ref dryRun.
+       */
+      ZYppCommitPolicy & downloadMode( DownloadMode val_r );
 
-    bool rpmNoSignature() const
-    { return _rpmInstFlags.testFlag( target::rpm::RPMINST_NOSIGNATURE ); }
+      DownloadMode downloadMode() const;
 
-    bool rpmExcludeDocs() const
-    { return _rpmInstFlags.testFlag( target::rpm::RPMINST_EXCLUDEDOCS ); }
 
+      /** The default \ref target::rpm::RpmInstFlags. (default: none)*/
+      ZYppCommitPolicy &  rpmInstFlags( target::rpm::RpmInstFlags newFlags_r );
 
-    bool syncPoolAfterCommit() const
-    { return _syncPoolAfterCommit; }
+      /** Use rpm option --nosignature (default: false) */
+      ZYppCommitPolicy & rpmNoSignature( bool yesNo_r );
 
-  public:
-    /** Restrict commit to media 1.
-     * Fake outstanding YCP fix: Honour restriction to media 1
-     * at installation, but install all remaining packages if
-     * post-boot (called with <tt>mediaNr_r &gt; 1</tt>).
-     */
-    ZYppCommitPolicy & restrictToMedia( unsigned mediaNr_r )
-    { _restrictToMedia = ( mediaNr_r == 1 ) ? 1 : 0; return *this; }
+      /** Use rpm option --excludedocs (default: false) */
+      ZYppCommitPolicy & rpmExcludeDocs( bool yesNo_r );
 
-    /** Process all media (default) */
-    ZYppCommitPolicy & allMedia()
-    { return restrictToMedia( 0 ); }
+      target::rpm::RpmInstFlags rpmInstFlags() const;
 
-    /** Set dry run (default: false) */
-    ZYppCommitPolicy & dryRun( bool yesNo_r )
-    { _dryRun = yesNo_r; return *this; }
+      bool rpmNoSignature() const;
 
-    /** The default \ref target::rpm::RpmInstFlags. (default: none)*/
-    ZYppCommitPolicy &  rpmInstFlags( target::rpm::RpmInstFlags newFlags_r )
-    { _rpmInstFlags = newFlags_r; return *this; }
+      bool rpmExcludeDocs() const;
 
-    /** Use rpm option --nosignature (default: false) */
-    ZYppCommitPolicy & rpmNoSignature( bool yesNo_r )
-    { _rpmInstFlags.setFlag( target::rpm::RPMINST_NOSIGNATURE, yesNo_r ); return *this; }
 
-    /** Use rpm option --excludedocs (default: false) */
-    ZYppCommitPolicy & rpmExcludeDocs( bool yesNo_r )
-    { _rpmInstFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS, yesNo_r ); return *this; }
+      /** Kepp pool in sync with the Target databases after commit (default: true) */
+      ZYppCommitPolicy & syncPoolAfterCommit( bool yesNo_r );
 
-    /** Kepp pool in sync with the Target databases after commit (default: true) */
-    ZYppCommitPolicy & syncPoolAfterCommit( bool yesNo_r )
-    { _syncPoolAfterCommit = yesNo_r; return *this; }
+      bool syncPoolAfterCommit() const;
 
-  private:
-    unsigned                  _restrictToMedia;
-    bool                      _dryRun;
-    target::rpm::RpmInstFlags _rpmInstFlags;
-    bool                      _syncPoolAfterCommit;
+    public:
+      /** Implementation  */
+      class Impl;
+    private:
+      /** Pointer to data. */
+      RWCOW_pointer<Impl> _pimpl;
   };
   ///////////////////////////////////////////////////////////////////
 
index f691981..1f5ee1c 100644 (file)
@@ -48,7 +48,6 @@
 #include "zypp/parser/ProductFileReader.h"
 
 #include "zypp/pool/GetResolvablesToInsDel.h"
-#include "zypp/solver/detail/Helper.h"
 #include "zypp/solver/detail/Testcase.h"
 
 #include "zypp/repo/DeltaCandidates.h"
@@ -292,9 +291,7 @@ namespace zypp
 
       RepoProvidePackage( repo::RepoMediaAccess &access, ResPool pool_r )
         : _pool(pool_r), _access(access)
-      {
-
-      }
+      {}
 
       ManagedFile operator()( const PoolItem & pi )
       {
@@ -708,11 +705,16 @@ namespace zypp
     ZYppCommitResult TargetImpl::commit( ResPool pool_r, const ZYppCommitPolicy & policy_rX )
     {
       // ----------------------------------------------------------------- //
+      ZYppCommitPolicy policy_r( policy_rX );
+
       // Fake outstanding YCP fix: Honour restriction to media 1
       // at installation, but install all remaining packages if post-boot.
-      ZYppCommitPolicy policy_r( policy_rX );
       if ( policy_r.restrictToMedia() > 1 )
         policy_r.allMedia();
+
+      // DownloadOnly implies dry-run.
+      if ( policy_r.downloadMode() == DownloadOnly )
+        policy_r.dryRun( true );
       // ----------------------------------------------------------------- //
 
       MIL << "TargetImpl::commit(<pool>, " << policy_r << ")" << endl;
@@ -722,99 +724,73 @@ namespace zypp
       ///////////////////////////////////////////////////////////////////
       if ( getZYpp()->resolver()->upgradeMode() )
       {
-        writeUpgradeTestcase();
+        if ( ! policy_r.dryRun() )
+        {
+          writeUpgradeTestcase();
+        }
+        else
+        {
+          DBG << "dryRun: Not writing upgrade testcase." << endl;
+        }
       }
 
       ///////////////////////////////////////////////////////////////////
       // Store non-package data:
       ///////////////////////////////////////////////////////////////////
-      filesystem::assert_dir( home() );
-      // requested locales
-      _requestedLocalesFile.setLocales( pool_r.getRequestedLocales() );
-      // weak locks
+      if ( ! policy_r.dryRun() )
       {
-        SoftLocksFile::Data newdata;
-        pool_r.getActiveSoftLocks( newdata );
-        _softLocksFile.setData( newdata );
+        filesystem::assert_dir( home() );
+        // requested locales
+        _requestedLocalesFile.setLocales( pool_r.getRequestedLocales() );
+        // weak locks
+        {
+          SoftLocksFile::Data newdata;
+          pool_r.getActiveSoftLocks( newdata );
+          _softLocksFile.setData( newdata );
+        }
+        // hard locks
+        if ( ZConfig::instance().apply_locks_file() )
+        {
+          HardLocksFile::Data newdata;
+          pool_r.getHardLockQueries( newdata );
+          _hardLocksFile.setData( newdata );
+        }
       }
-      // hard locks
-      if ( ZConfig::instance().apply_locks_file() )
+      else
       {
-        HardLocksFile::Data newdata;
-        pool_r.getHardLockQueries( newdata );
-        _hardLocksFile.setData( newdata );
+        DBG << "dryRun: Not stroring non-package data." << endl;
       }
 
       ///////////////////////////////////////////////////////////////////
-      // Process packages:
+      // Compute transaction:
       ///////////////////////////////////////////////////////////////////
 
-      DBG << "commit log file is set to: " << HistoryLog::fname() << endl;
-
       ZYppCommitResult result;
-
       TargetImpl::PoolItemList to_uninstall;
       TargetImpl::PoolItemList to_install;
       TargetImpl::PoolItemList to_srcinstall;
-      {
 
+      {
         pool::GetResolvablesToInsDel
         collect( pool_r, policy_r.restrictToMedia() ? pool::GetResolvablesToInsDel::ORDER_BY_MEDIANR
                  : pool::GetResolvablesToInsDel::ORDER_BY_SOURCE );
         MIL << "GetResolvablesToInsDel: " << endl << collect << endl;
-        to_uninstall.swap( collect._toDelete );
-        to_install.swap( collect._toInstall );
+        to_uninstall.swap ( collect._toDelete );
+        to_install.swap   ( collect._toInstall );
         to_srcinstall.swap( collect._toSrcinstall );
       }
 
       if ( policy_r.restrictToMedia() )
       {
         MIL << "Restrict to media number " << policy_r.restrictToMedia() << endl;
-      }
 
-      ///////////////////////////////////////////////////////////////////
-      // First collect and display all messages
-      // associated with patches to be installed.
-      ///////////////////////////////////////////////////////////////////
-      for_( it, to_install.begin(), to_install.end() )
-      {
-        if ( ! isKind<Patch>(it->resolvable()) )
-          continue;
-        if ( ! it->status().isToBeInstalled() )
-          continue;
-
-        Patch::constPtr patch( asKind<Patch>(it->resolvable()) );
-        if ( ! patch->message().empty() )
-        {
-          MIL << "Show message for " << patch << endl;
-          callback::SendReport<target::PatchMessageReport> report;
-          if ( ! report->show( patch ) )
-          {
-            WAR << "commit aborted by the user" << endl;
-            ZYPP_THROW( TargetAbortedException( N_("Installation has been aborted as directed.") ) );
-          }
-        }
-      }
-
-      ///////////////////////////////////////////////////////////////////
-      // Remove/install packages.
-      ///////////////////////////////////////////////////////////////////
-     commit ( to_uninstall, policy_r, pool_r );
-
-      if (policy_r.restrictToMedia() == 0)
-      {                        // commit all
-        result._remaining = commit( to_install, policy_r, pool_r );
-        result._srcremaining = commit( to_srcinstall, policy_r, pool_r );
-      }
-      else
-      {
         TargetImpl::PoolItemList current_install;
         TargetImpl::PoolItemList current_srcinstall;
 
         // Collect until the 1st package from an unwanted media occurs.
         // Further collection could violate install order.
         bool hitUnwantedMedia = false;
-        for (TargetImpl::PoolItemList::iterator it = to_install.begin(); it != to_install.end(); ++it)
+        for ( TargetImpl::PoolItemList::iterator it = to_install.begin(); it != to_install.end(); ++it )
         {
           ResObject::constPtr res( it->resolvable() );
 
@@ -830,16 +806,12 @@ namespace zypp
           }
         }
 
-        TargetImpl::PoolItemList bad = commit( current_install, policy_r, pool_r );
-        result._remaining.insert(result._remaining.end(), bad.begin(), bad.end());
-
         for (TargetImpl::PoolItemList::iterator it = to_srcinstall.begin(); it != to_srcinstall.end(); ++it)
         {
           Resolvable::constPtr res( it->resolvable() );
           Package::constPtr pkg( asKind<Package>(res) );
-          if (pkg && policy_r.restrictToMedia() != pkg->mediaNr()) // check medianr for packages only
+          if ( pkg && policy_r.restrictToMedia() != pkg->mediaNr() ) // check medianr for packages only
           {
-            XXX << "Package " << *pkg << ", wrong media " << pkg->mediaNr() << endl;
             result._srcremaining.push_back( *it );
           }
           else
@@ -847,14 +819,86 @@ namespace zypp
             current_srcinstall.push_back( *it );
           }
         }
-        bad = commit( current_srcinstall, policy_r, pool_r );
-        result._srcremaining.insert(result._srcremaining.end(), bad.begin(), bad.end());
+
+        to_install.swap   ( current_install );
+        to_srcinstall.swap( current_srcinstall );
+      }
+
+      ///////////////////////////////////////////////////////////////////
+      // First collect and display all messages
+      // associated with patches to be installed.
+      ///////////////////////////////////////////////////////////////////
+      if ( ! policy_r.dryRun() )
+      {
+        for_( it, to_install.begin(), to_install.end() )
+        {
+          if ( ! isKind<Patch>(it->resolvable()) )
+            continue;
+          if ( ! it->status().isToBeInstalled() )
+            continue;
+
+          Patch::constPtr patch( asKind<Patch>(it->resolvable()) );
+          if ( ! patch->message().empty() )
+          {
+            MIL << "Show message for " << patch << endl;
+            callback::SendReport<target::PatchMessageReport> report;
+            if ( ! report->show( patch ) )
+            {
+              WAR << "commit aborted by the user" << endl;
+              ZYPP_THROW( TargetAbortedException( N_("Installation has been aborted as directed.") ) );
+            }
+          }
+        }
+      }
+      else
+      {
+        DBG << "dryRun: Not checking patch messages." << endl;
+      }
+
+      ///////////////////////////////////////////////////////////////////
+      // Remove/install packages.
+      ///////////////////////////////////////////////////////////////////
+
+      DBG << "commit log file is set to: " << HistoryLog::fname() << endl;
+      {
+        // somewhat uggly constraint: The iterator passed to the CommitPackageCache
+        // must match begin and end of the install PoolItemList passed to commit.
+        // For the download policies it's the easiest, if we have just a single
+        // toInstall list. So we unify to_install and to_srcinstall. In case
+        // of errors we have to split it up again. This will be cleaned up when
+        // we introduce the new install order.
+        TargetImpl::PoolItemList items( to_install );
+        items.insert( items.end(), to_srcinstall.begin(), to_srcinstall.end() );
+
+        // prepare the package cache according to the download options:
+        repo::RepoMediaAccess access;
+        RepoProvidePackage repoProvidePackage( access, pool_r );
+        CommitPackageCache packageCache( items.begin(), items.end(),
+                                         root() / "tmp", repoProvidePackage );
+
+        commit ( to_uninstall, policy_r, packageCache );
+        {
+          TargetImpl::PoolItemList bad = commit( items, policy_r, packageCache );
+          if ( ! bad.empty() )
+          {
+            for_( it, bad.begin(), bad.end() )
+            {
+              if ( isKind<SrcPackage>(it->resolvable()) )
+                result._srcremaining.push_back( *it );
+              else
+                result._remaining.push_back( *it );
+            }
+          }
+        }
       }
 
       ///////////////////////////////////////////////////////////////////
       // Try to rebuild solv file while rpm database is still in cache.
       ///////////////////////////////////////////////////////////////////
-      buildCache();
+      if ( ! policy_r.dryRun() )
+      {
+        buildCache();
+      }
 
       result._result = (to_install.size() - result._remaining.size());
       MIL << "TargetImpl::commit(<pool>, " << policy_r << ") returns: " << result << endl;
@@ -870,19 +914,13 @@ namespace zypp
     TargetImpl::PoolItemList
     TargetImpl::commit( const TargetImpl::PoolItemList & items_r,
                         const ZYppCommitPolicy & policy_r,
-                        const ResPool & pool_r )
+                        CommitPackageCache & packageCache_r )
     {
-      TargetImpl::PoolItemList remaining;
-      repo::RepoMediaAccess access;
       MIL << "TargetImpl::commit(<list>" << policy_r << ")" << items_r.size() << endl;
 
       bool abort = false;
       std::vector<sat::Solvable> successfullyInstalledPackages;
-
-      // prepare the package cache.
-      RepoProvidePackage repoProvidePackage( access, pool_r );
-      CommitPackageCache packageCache( items_r.begin(), items_r.end(),
-                                       root() / "tmp", repoProvidePackage );
+      TargetImpl::PoolItemList remaining;
 
       for ( TargetImpl::PoolItemList::const_iterator it = items_r.begin(); it != items_r.end(); it++ )
       {
@@ -894,7 +932,7 @@ namespace zypp
             ManagedFile localfile;
             try
             {
-              localfile = packageCache.get( it );
+              localfile = packageCache_r.get( it );
             }
             catch ( const AbortRequestException &e )
             {
index 5d99984..f619cb9 100644 (file)
@@ -40,6 +40,7 @@ namespace zypp
   { /////////////////////////////////////////////////////////////////
 
     DEFINE_PTR_TYPE(TargetImpl);
+    class CommitPackageCache;
 
     ///////////////////////////////////////////////////////////////////
     //
@@ -142,10 +143,11 @@ namespace zypp
       }
 
       /** Commit ordered changes
-       *  @param pool_r only needed for #160792
+       *  @param packageCache_r Access to the package provider
        *  @return uncommitted ones (due to error)
        */
-      PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r, const ResPool & pool_r );
+      PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r,
+                           CommitPackageCache & packageCache_r );
 
       /** Install a source package on the Target. */
       void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );