backport ma changes
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 22 Jun 2006 14:26:33 +0000 (14:26 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 22 Jun 2006 14:26:33 +0000 (14:26 +0000)
devel/devel.ma/Parse.cc
package/libzypp.changes
zypp/pool/GetResolvablesToInsDel.cc
zypp/pool/GetResolvablesToInsDel.h
zypp/target/TargetImpl.cc

index 3033c32..e1a7057 100644 (file)
@@ -10,7 +10,6 @@
 #include "zypp/ResPoolProxy.h"
 #include <zypp/SourceManager.h>
 #include <zypp/SourceFactory.h>
-#include "zypp/CapFactory.h"
 
 #include "zypp/NVRAD.h"
 #include "zypp/ResPool.h"
@@ -193,7 +192,7 @@ int main( int argc, char * argv[] )
     }
 
   if ( 1 ) {
-    //zypp::base::LogControl::TmpLineWriter shutUp;
+    zypp::base::LogControl::TmpLineWriter shutUp;
     //SourceManager::sourceManager()->restore( sysRoot );
     if ( 1 || SourceManager::sourceManager()->allSources().empty() )
       {
@@ -214,21 +213,6 @@ int main( int argc, char * argv[] )
   MIL << pool << endl;
 
 
-  NameKindProxy rug( nameKindProxy<Package>( pool, "rug" ) );
-  INT << rug << endl;
-  if ( ! rug.availableEmpty() )
-    {
-      PoolItem rugAv( *rug.availableBegin() );
-      CapSet rugPrv( rugAv->dep( Dep::PROVIDES ) );
-      dumpRange( USR << "rug prv: " << endl,
-                 rugPrv.begin(), rugPrv.end() ) << endl;
-
-    }
-
-  INT << rug << endl;
-  return 0;
-
-
   if ( 1 )
     {
 #if 0
@@ -268,9 +252,9 @@ Resolver.cc(show_pool):915 1: U_Th_[S2:0][product]SUSE-Linux-Enterprise-Server-i
                   make_filter_begin<resfilter::ByTransact>(pool),
                   make_filter_end<resfilter::ByTransact>(pool) ) << endl;
 
-  vdumpPoolStats( SEC,
-                  pool.byKindBegin<Package>(),
-                  pool.byKindEnd<Package>() ) << endl;
+  //vdumpPoolStats( SEC,
+  //                pool.byKindBegin<Package>(),
+  //                pool.byKindEnd<Package>() ) << endl;
 
   if ( 1 ) {
     bool eres, rres;
@@ -288,7 +272,7 @@ Resolver.cc(show_pool):915 1: U_Th_[S2:0][product]SUSE-Linux-Enterprise-Server-i
                   make_filter_end<resfilter::ByTransact>(pool) ) << endl;
 
 
-  pool::GetResolvablesToInsDel collect( pool );
+  pool::GetResolvablesToInsDel collect( pool, pool::GetResolvablesToInsDel::ORDER_BY_MEDIANR );
   MIL << "GetResolvablesToInsDel:" << endl << collect << endl;
 
   if ( 1 )
index 328a7e7..522ebf8 100644 (file)
@@ -1,4 +1,12 @@
 -------------------------------------------------------------------
+Thu Jun 22 16:01:15 CEST 2006 - ma@suse.de
+
+- backport from sle branch
+- Fixed installation of SP or Add-On product switching to media 2
+  too early. (#186607)
+- revision 3686
+
+-------------------------------------------------------------------
 Wed Jun 21 15:47:39 CEST 2006 - dmacvicar@suse.de
 
 - backport from sle branch
index 0f9c9fa..7165bb1 100644 (file)
@@ -25,7 +25,6 @@ using zypp::solver::detail::InstallOrder;
 #undef  ZYPP_BASE_LOGGER_LOGGROUP
 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::GetResolvablesToInsDel"
 
-
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
@@ -101,7 +100,7 @@ namespace zypp
     // METHOD NAME : GetResolvablesToInsDel::GetResolvablesToInsDel
     // METHOD TYPE : Ctor
     //
-    GetResolvablesToInsDel::GetResolvablesToInsDel( ResPool pool_r )
+    GetResolvablesToInsDel::GetResolvablesToInsDel( ResPool pool_r, Order order_r )
     {
       typedef std::set<PoolItem_Ref> PoolItemSet;
 
@@ -177,25 +176,6 @@ namespace zypp
       if ( instlist_r.empty() )
         return;
 
-#warning Source Rank Priority ?
-#if 0
-      ///////////////////////////////////////////////////////////////////
-      // Get desired order of InstSrc'es to install from.
-      ///////////////////////////////////////////////////////////////////
-      typedef map<unsigned,unsigned> RankPriority;
-
-      RankPriority rankPriority;
-      {
-        InstSrcManager::ISrcIdList sourcerank( Y2PM::instSrcManager().instOrderSources() );
-        // map InstSrc rank to install priority
-        unsigned prio = 0;
-        for ( InstSrcManager::ISrcIdList::const_iterator it = sourcerank.begin();
-              it != sourcerank.end(); ++it, ++prio ) {
-          rankPriority[(*it)->descr()->default_rank()] = prio;
-        }
-      }
-#endif
-
       ///////////////////////////////////////////////////////////////////
       // Compute install order according to packages prereq.
       // Try to group packages with respect to the desired install order
@@ -252,10 +232,10 @@ namespace zypp
                 continue;
               }
 
-              XXX << "Package " << *cobj << ", media " << cobj->sourceMediaNr() << " last_medianum " << last_medianum << " best_medianum " << best_medianum << endl;
               if ( cobj->source().numericId() == last_prio &&
                    cobj->sourceMediaNr() == last_medianum ) {
                 // prefer packages on current media.
+                XXX << "Stay with current media " << *cit << endl;
                 last_list.push_back( *cit );
                 continue;
               }
@@ -265,28 +245,53 @@ namespace zypp
 
                 if ( ! best_list.empty() ) {
 
-                  if ( cobj->source().numericId() < best_prio ) {
-                    best_list.clear(); // new best
-                  } else if ( cobj->source().numericId() == best_prio ) {
-                    if ( cobj->sourceMediaNr() < best_medianum ) {
-                      best_list.clear(); // new best
-                    } else if ( cobj->sourceMediaNr() == best_medianum ) {
-                      best_list.push_back( *cit ); // same as best -> add
-                      continue;
-                    } else {
-                      continue; // worse
+                  if ( order_r == ORDER_BY_MEDIANR )
+                    {
+                      if ( cobj->sourceMediaNr() < best_medianum ) {
+                        best_list.clear(); // new best
+                      } else if ( cobj->sourceMediaNr() == best_medianum ) {
+                        if ( cobj->source().numericId() < best_prio ) {
+                          best_list.clear(); // new best
+                        } else if ( cobj->source().numericId() == best_prio ) {
+                          XXX << "Add to best list " << *cit << endl;
+                          best_list.push_back( *cit ); // same as best -> add
+                          continue;
+                        } else {
+                          continue; // worse
+                        }
+                      } else {
+                        continue; // worse
+                      }
+                    }
+                  else // default: ORDER_BY_SOURCE
+                    {
+                      if ( cobj->source().numericId() < best_prio ) {
+                        best_list.clear(); // new best
+                      } else if ( cobj->source().numericId() == best_prio ) {
+                        if ( cobj->sourceMediaNr() < best_medianum ) {
+                          best_list.clear(); // new best
+                        } else if ( cobj->sourceMediaNr() == best_medianum ) {
+                          XXX << "Add to best list " << *cit << endl;
+                          best_list.push_back( *cit ); // same as best -> add
+                          continue;
+                        } else {
+                          continue; // worse
+                        }
+                      } else {
+                        continue; // worse
+                      }
                     }
-                  } else {
-                    continue; // worse
-                  }
                 }
 
                 if ( best_list.empty() )
                   {
-                    // first package or new best
-                    best_list.push_back( *cit );
+                    XXX << "NEW BEST LIST [S" << cobj->source().numericId() << ":" << cobj->sourceMediaNr()
+                        << "] (last [S" << best_prio << ":" << best_medianum << "])" << endl;
                     best_prio     = cobj->source().numericId();
                     best_medianum = cobj->sourceMediaNr();
+                    // first package or new best
+                    XXX << "Add to best list " << *cit << endl;
+                    best_list.push_back( *cit );
                     continue;
                   }
               }
@@ -300,19 +305,19 @@ namespace zypp
           PoolItemList & take_list( last_list.empty() ? best_list : last_list );
           if ( last_list.empty() )
             {
-              MIL << "SET NEW media " << best_medianum << endl;
+              MIL << "SET NEW media [S" << best_prio << ":" << best_medianum << "]" << endl;
               last_prio     = best_prio;
               last_medianum = best_medianum;
             }
           else
             {
-              MIL << "SET CONTINUE" << endl;
+              MIL << "SET CONTINUE [S" << best_prio << ":" << best_medianum << "]" << endl;
             }
 
           for ( PoolItemList::iterator it = take_list.begin(); it != take_list.end(); ++it )
             {
               order.setInstalled( *it );
-              XXX << "SET isrc " << (*it)->source().numericId() << " -> " << (*it) << endl;
+              XXX << "SET collect " << (*it) << endl;
             }
           // move everthing from take_list to the end of instlist_r, clean take_list
           instlist_r.splice( instlist_r.end(), take_list );
index ee432b4..7b110fc 100644 (file)
@@ -30,13 +30,26 @@ namespace zypp
     //
     /** Collect transacting items and sort according to prereqs and
      *  media access.
+     *
+     * \todo Replace \c enum \c Order and take a functor that
+     * that determines how to group the resolvables.
      */
     struct GetResolvablesToInsDel
     {
       typedef std::list<PoolItem_Ref> PoolItemList;
 
+      /** Influences the sequence of sources and media proscessed.
+       * If true prefer a better source, otherwise a better media.
+       * \code
+       * ORDER_BY_SOURCE:  [S1:1], [S1:2], ... , [S2:1], [S2:2], ...
+       * ORDER_BY_MEDIANR: [S1:1], [S2:1], ... , [S1:2], [S2:2], ...
+       * \endcode
+       */
+      enum Order { ORDER_BY_SOURCE, ORDER_BY_MEDIANR };
+
       /** */
-      GetResolvablesToInsDel( ResPool pool_r );
+      GetResolvablesToInsDel( ResPool pool_r,
+                              Order order_r = ORDER_BY_SOURCE );
 
       PoolItemList _toDelete;
       PoolItemList _toInstall;
@@ -54,3 +67,4 @@ namespace zypp
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
 #endif // ZYPP_POOL_GETRESOLVABLESTOINSDEL_H
+
index 0a6e4f5..2f75bfb 100644 (file)
@@ -162,7 +162,16 @@ namespace zypp
       TargetImpl::PoolItemList to_uninstall;
       TargetImpl::PoolItemList to_install;
       TargetImpl::PoolItemList to_srcinstall;
-      getResolvablesToInsDel( pool_r, to_uninstall, to_install, 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_srcinstall.swap( collect._toSrcinstall );
+      }
 
       if ( policy_r.restrictToMedia() ) {
         MIL << "Restrict to media number " << policy_r.restrictToMedia() << endl;