backup
authorMichael Andres <ma@suse.de>
Thu, 20 Nov 2008 10:06:49 +0000 (10:06 +0000)
committerMichael Andres <ma@suse.de>
Thu, 20 Nov 2008 10:06:49 +0000 (10:06 +0000)
devel/devel.ma/Iorder.cc
devel/devel.ma/Test.cc
devel/devel.ma/Tools.h

index 9d7705a..a310fca 100644 (file)
@@ -1,14 +1,31 @@
 #include "Tools.h"
+#include <zypp/ResObjects.h>
+
 #include "zypp/pool/GetResolvablesToInsDel.h"
 
-static TestSetup test( Arch_x86_64 );  // use x86_64 as system arch
+bool upgrade()
+{
+  bool rres = false;
+  {
+    //zypp::base::LogControl::TmpLineWriter shutUp;
+    UpgradeStatistics u;
+    rres = getZYpp()->resolver()->doUpgrade( u );
+  }
+  if ( ! rres )
+  {
+    ERR << "upgrade " << rres << endl;
+    return false;
+  }
+  MIL << "upgrade " << rres << endl;
+  return true;
+}
 
 bool solve()
 {
   bool rres = false;
   {
     //zypp::base::LogControl::TmpLineWriter shutUp;
-    rres = test.resolver().resolvePool();
+    rres = getZYpp()->resolver()->resolvePool();
   }
   if ( ! rres )
   {
@@ -19,23 +36,29 @@ bool solve()
   return true;
 }
 
+/******************************************************************
+**
+**      FUNCTION NAME : main
+**      FUNCTION TYPE : int
+*/
 int main( int argc, char * argv[] )
-try {
-  --argc;
-  ++argv;
-  zypp::base::LogControl::instance().logToStdErr();
+{
   INT << "===[START]==========================================" << endl;
 
-  test.loadTarget(); // initialize and load target
-  test.loadRepo( Url("iso:/?iso=/mounts/dist/install/openSUSE-11.1-Beta2-DONTUSE/kiwi.out.dvd-i586.iso") );
+  Pathname mroot( "/tmp/Bb" );
+  TestSetup test( mroot, Arch_ppc64 );
+  test.loadTarget();
+  test.loadTestcaseRepos( "/suse/ma/BUGS/439802/bug439802/YaST2/solverTestcase" );
 
-  ResPool    pool( test.pool() );
-  Resolver & resolver( test.resolver() );
+  //getPi<>( "", "", Edition(""), Arch("") );
+  getPi<Product>( "SUSE_SLES", Edition("11"), Arch("ppc64") ).status().setTransact( true, ResStatus::USER );
+  getPi<Package>( "sles-release", Edition("11-54.3"), Arch("ppc64") ).status().setTransact( true, ResStatus::USER );
 
-  resolver.addRequire( Capability("glibc") );
-  resolver.addRequire( Capability("zlib") );
-  resolver.addRequire( Capability("lsb-buildenv") );
-  solve();
+  ResPool pool( test.pool() );
+  vdumpPoolStats( USR << "Transacting:"<< endl,
+                  make_filter_begin<resfilter::ByTransact>(pool),
+                  make_filter_end<resfilter::ByTransact>(pool) ) << endl;
+  upgrade();
   vdumpPoolStats( USR << "Transacting:"<< endl,
                   make_filter_begin<resfilter::ByTransact>(pool),
                   make_filter_end<resfilter::ByTransact>(pool) ) << endl;
@@ -79,15 +102,7 @@ try {
                collect._toDelete.begin(), collect._toDelete.end() ) << endl;
   }
 
-  ///////////////////////////////////////////////////////////////////
   INT << "===[END]============================================" << endl << endl;
-  zypp::base::LogControl::instance().logNothing();
   return 0;
 }
-catch ( const Exception & exp )
-{
-  INT << exp << endl << exp.historyAsString();
-}
-catch (...)
-{}
 
index 38513ec..3cc44a6 100644 (file)
@@ -1,10 +1,40 @@
 #include "Tools.h"
 #include <zypp/ResObjects.h>
 
-#include "zypp/IdString.h"
-#include "zypp/Glob.h"
+#include "zypp/pool/GetResolvablesToInsDel.h"
 
-using filesystem::Glob;
+bool upgrade()
+{
+  bool rres = false;
+  {
+    zypp::base::LogControl::TmpLineWriter shutUp;
+    UpgradeStatistics u;
+    rres = getZYpp()->resolver()->doUpgrade( u );
+  }
+  if ( ! rres )
+  {
+    ERR << "upgrade " << rres << endl;
+    return false;
+  }
+  MIL << "upgrade " << rres << endl;
+  return true;
+}
+
+bool solve()
+{
+  bool rres = false;
+  {
+    //zypp::base::LogControl::TmpLineWriter shutUp;
+    rres = getZYpp()->resolver()->resolvePool();
+  }
+  if ( ! rres )
+  {
+    ERR << "resolve " << rres << endl;
+    return false;
+  }
+  MIL << "resolve " << rres << endl;
+  return true;
+}
 
 /******************************************************************
 **
@@ -16,24 +46,60 @@ int main( int argc, char * argv[] )
   INT << "===[START]==========================================" << endl;
 
   Pathname mroot( "/tmp/Bb" );
-  TestSetup test( mroot, Arch_x86_64 );
+  TestSetup test( mroot, Arch_ppc64 );
+  test.loadTarget();
+  test.loadTestcaseRepos( "/suse/ma/BUGS/439802/bug439802/YaST2/solverTestcase" );
 
-  //test.loadRepos();
-  test.loadTestcaseRepos( "/suse/ma/BUGS/153548/YaST2/solverTestcase" );
+  //getPi<>( "", "", Edition(""), Arch("") );
+  getPi<Product>( "SUSE_SLES", Edition("11"), Arch("ppc64") ).status().setTransact( true, ResStatus::USER );
+  getPi<Package>( "sles-release", Edition("11-54.3"), Arch("ppc64") ).status().setTransact( true, ResStatus::USER );
 
-  sat::Pool satpool( test.satpool() );
-  for_( it, satpool.reposBegin(), satpool.reposEnd() )
-  {
-    MIL << *it << endl;
-  }
+  ResPool pool( test.pool() );
+  vdumpPoolStats( USR << "Transacting:"<< endl,
+                  make_filter_begin<resfilter::ByTransact>(pool),
+                  make_filter_end<resfilter::ByTransact>(pool) ) << endl;
+  upgrade();
+  vdumpPoolStats( USR << "Transacting:"<< endl,
+                  make_filter_begin<resfilter::ByTransact>(pool),
+                  make_filter_end<resfilter::ByTransact>(pool) ) << endl;
 
-  INT << "===[END]============================================" << endl << endl;
-  return 0;
+  pool::GetResolvablesToInsDel collect( pool, pool::GetResolvablesToInsDel::ORDER_BY_MEDIANR );
+  MIL << "GetResolvablesToInsDel:" << endl << collect << endl;
+  if ( 1 )
+  {
+    // Collect until the 1st package from an unwanted media occurs.
+    // Further collection could violate install order.
+    bool hitUnwantedMedia = false;
+    typedef pool::GetResolvablesToInsDel::PoolItemList PoolItemList;
+    PoolItemList::iterator fst=collect._toInstall.end();
+    for ( PoolItemList::iterator it = collect._toInstall.begin(); it != collect._toInstall.end(); ++it)
+    {
+      ResObject::constPtr res( it->resolvable() );
 
-  ResPool pool( test.pool() );
-  for_( it, pool.byKindBegin<Product>(), pool.byKindEnd<Product>() )
+      if ( hitUnwantedMedia
+           || ( res->mediaNr() && res->mediaNr() != 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
   {
-    MIL << *it << endl;
+    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;
index cb4833a..ba50a65 100644 (file)
@@ -162,16 +162,19 @@ ui::Selectable::Ptr getSel( const std::string & name_r )
   return 0;
 }
 
+
+
 template<class _Res>
-PoolItem getPi( const std::string & name_r, const Edition & ed_r, const Arch & arch_r )
+PoolItem getPi( const std::string & alias_r, const std::string & name_r, const Edition & ed_r, const Arch & arch_r )
 {
   PoolItem ret;
   ResPool pool( getZYpp()->pool() );
-  for_(it, pool.byNameBegin(name_r), pool.byNameEnd(name_r) )
+  for_(it, pool.byIdentBegin<_Res>(name_r), pool.byIdentEnd<_Res>(name_r) )
   {
-    if ( !ret && isKind<_Res>( (*it).resolvable() )
-         && ( ed_r == Edition() || ed_r.match((*it)->edition()) == 0 )
-         && ( arch_r == Arch()  || arch_r == (*it)->arch()  ) )
+    if ( !ret
+         && ( ed_r.empty()    || ed_r.match((*it)->edition()) == 0 )
+         && ( arch_r.empty()  || arch_r == (*it)->arch()  )
+         && ( alias_r.empty() || alias_r == (*it)->repository().alias() ) )
     {
       ret = (*it);
       MIL << "    ->" << *it << endl;
@@ -184,14 +187,19 @@ PoolItem getPi( const std::string & name_r, const Edition & ed_r, const Arch & a
   return ret;
 }
 template<class _Res>
+PoolItem getPi( const std::string & name_r, const Edition & ed_r, const Arch & arch_r )
+{
+  return getPi<_Res>( "", name_r, ed_r, arch_r );
+}
+template<class _Res>
 PoolItem getPi( const std::string & name_r )
 {
-  return getPi<_Res>( name_r, Edition(), Arch() );
+  return getPi<_Res>( name_r, Edition(), Arch_empty );
 }
 template<class _Res>
 PoolItem getPi( const std::string & name_r, const Edition & ed_r )
 {
-  return getPi<_Res>( name_r, ed_r, Arch() );
+  return getPi<_Res>( name_r, ed_r, Arch_empty );
 }
 template<class _Res>
 PoolItem getPi( const std::string & name_r, const Arch & arch_r )