- Do not violate install order when restricting commit to a certain
authorMichael Andres <ma@suse.de>
Mon, 22 May 2006 19:21:48 +0000 (19:21 +0000)
committerMichael Andres <ma@suse.de>
Mon, 22 May 2006 19:21:48 +0000 (19:21 +0000)
  mediaNumber. (#170079)
- Version 1.1.0

configure.ac
devel/devel.ma/Parse.cc
package/libzypp.changes
zypp/ResObject.cc
zypp/ResObject.h
zypp/Resolvable.cc
zypp/target/TargetImpl.cc

index 8d98343..2d62004 100644 (file)
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 dnl ==================================================
 m4_include([VERSION])
-AC_INIT([zypp], [LIBZYPP_CURRENT.LIBZYPP_AGE.LIBZYPP_REVISION])
+AC_INIT([zypp], [LIBZYPP_CURRENT.LIBZYPP_REVISION.LIBZYPP_AGE])
 dnl ==================================================
 AC_CONFIG_SRCDIR(zypp/Makefile.am)
 
index 42cbd47..ebdd5fa 100644 (file)
@@ -164,7 +164,7 @@ inline bool selectForTransact( const NameKindProxy & nkp )
 */
 int main( int argc, char * argv[] )
 {
-  //zypp::base::LogControl::instance().logfile( "xxx" );
+  //zypp::base::LogControl::instance().logfile( "log.restrict" );
   INT << "===[START]==========================================" << endl;
 
   ResPool pool( getZYpp()->pool() );
@@ -173,7 +173,6 @@ int main( int argc, char * argv[] )
     {
       zypp::base::LogControl::TmpLineWriter shutUp;
       getZYpp()->initTarget( sysRoot );
-      //getZYpp()->addResolvables( getZYpp()->target()->resolvables(), true );
       USR << "Added target: " << pool << endl;
     }
 
@@ -239,11 +238,42 @@ int main( int argc, char * argv[] )
   pool::GetResolvablesToInsDel collect( pool );
   MIL << "GetResolvablesToInsDel:" << endl << collect << endl;
 
-  dumpRange( WAR << "toInstall: " << endl,
-             collect._toInstall.begin(), collect._toInstall.end() ) << endl;
-  dumpRange( ERR << "toDelete: " << endl,
-             collect._toDelete.begin(), collect._toDelete.end() ) << endl;
 
+  if ( 1 )
+    {
+      // Collect until the 1st package from an unwanted media occurs.
+      // Further collection could violate install order.
+      bool hitUnwantedMedia = false;
+      PoolItemList::iterator fst=collect._toInstall.end();
+      for ( PoolItemList::iterator it = collect._toInstall.begin(); it != collect._toInstall.end(); ++it)
+        {
+          ResObject::constPtr res( it->resolvable() );
+
+          if ( hitUnwantedMedia
+               || ( res->sourceMediaNr() && res->sourceMediaNr() != 1 ) )
+            {
+              if ( !hitUnwantedMedia )
+                fst=it;
+              hitUnwantedMedia = true;
+            }
+          else
+            {
+            }
+        }
+      dumpRange( WAR << "toInstall1: " << endl,
+                 collect._toInstall.begin(), fst ) << endl;
+      dumpRange( WAR << "toInstall2: " << endl,
+                 fst, collect._toInstall.end() ) << endl;
+      dumpRange( ERR << "toDelete: " << endl,
+                 collect._toDelete.begin(), collect._toDelete.end() ) << endl;
+    }
+  else
+    {
+      dumpRange( WAR << "toInstall: " << endl,
+                 collect._toInstall.begin(), collect._toInstall.end() ) << endl;
+      dumpRange( ERR << "toDelete: " << endl,
+                 collect._toDelete.begin(), collect._toDelete.end() ) << endl;
+    }
 
   INT << "===[END]============================================" << endl << endl;
   zypp::base::LogControl::instance().logNothing();
index 60031dc..3f031ee 100644 (file)
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Mon May 22 20:51:59 CEST 2006 - ma@suse.de
+
+- Do not violate install order when restricting commit to a certain
+  mediaNumber. (#170079)
+- Version 1.1.0
+
+-------------------------------------------------------------------
 Mon May 22 19:03:20 CEST 2006 - mvidner@suse.cz
 
 - Added SourceManager::findSourceByUrl to overcome alias mismatches
index 0f374b2..9f34401 100644 (file)
@@ -39,6 +39,17 @@ namespace zypp
 
   ///////////////////////////////////////////////////////////////////
   //
+  //   METHOD NAME : ResObject::dumpOn
+  //   METHOD TYPE : std::ostream &
+  //
+  std::ostream & ResObject::dumpOn( std::ostream & str ) const
+  {
+    str << "[S" << source().numericId() << ":" << sourceMediaNr() << "]";
+    return Resolvable::dumpOn( str );
+  }
+
+  ///////////////////////////////////////////////////////////////////
+  //
   //   ResObject interface forwarded to implementation
   //
   ///////////////////////////////////////////////////////////////////
index 5a46d89..e4bd7a6 100644 (file)
@@ -101,6 +101,9 @@ namespace zypp
     /** Dtor */
     virtual ~ResObject();
 
+    /** Helper for stream output */
+    virtual std::ostream & dumpOn( std::ostream & str ) const;
+
   private:
     friend class detail::ImplConnect;
     /** Access implementation */
index e6dcee6..71314ac 100644 (file)
@@ -48,14 +48,7 @@ namespace zypp
   ///////////////////////////////////////////////////////////////////
 
   std::ostream & Resolvable::dumpOn( std::ostream & str ) const
-  {
-    const ResObject * obj = dynamic_cast<const ResObject *>(this);
-    if ( obj )
-      {
-        str << "[S" << obj->source().numericId() << ":" << obj->sourceMediaNr() << "]";
-      }
-    return _pimpl->dumpOn( str );
-  }
+  { return _pimpl->dumpOn( str ); }
 
   const Resolvable::Kind & Resolvable::kind() const
   { return _pimpl->kind(); }
index 08265fb..4803adb 100644 (file)
@@ -145,8 +145,16 @@ namespace zypp
 
 
 
-    ZYppCommitResult TargetImpl::commit( ResPool pool_r, const ZYppCommitPolicy & policy_r )
+    ZYppCommitResult TargetImpl::commit( ResPool pool_r, const ZYppCommitPolicy & 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();
+      // ----------------------------------------------------------------- //
+
       MIL << "TargetImpl::commit(<pool>, " << policy_r << ")" << endl;
       ZYppCommitResult result;
 #warning Commit does not provide ZYppCommitResult::_errors
@@ -171,20 +179,25 @@ namespace zypp
         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)
         {
-          Resolvable::constPtr res( it->resolvable() );
-          Package::constPtr pkg( asKind<Package>(res) );
-          if (pkg && policy_r.restrictToMedia() != pkg->sourceMediaNr())                                                               // check medianr for packages only
-          {
-            XXX << "Package " << *pkg << ", wrong media " << pkg->sourceMediaNr() << endl;
-            result._remaining.push_back( *it );
-          }
+          ResObject::constPtr res( it->resolvable() );
+
+          if ( hitUnwantedMedia
+               || ( res->sourceMediaNr() && res->sourceMediaNr() != policy_r.restrictToMedia() ) )
+            {
+              hitUnwantedMedia = true;
+              result._remaining.push_back( *it );
+            }
           else
-          {
-            current_install.push_back( *it );
-          }
+            {
+              current_install.push_back( *it );
+            }
         }
+
         TargetImpl::PoolItemList bad = commit( current_install, policy_r, pool_r );
         result._remaining.insert(result._remaining.end(), bad.begin(), bad.end());