add TestSetup::loadRepos: Load all enabled repos in repos.d to pool.
authorMichael Andres <ma@suse.de>
Thu, 6 Nov 2008 17:30:27 +0000 (17:30 +0000)
committerMichael Andres <ma@suse.de>
Thu, 6 Nov 2008 17:30:27 +0000 (17:30 +0000)
devel/devel.ma/NewPool.cc
devel/devel.ma/Test.cc
devel/devel.ma/ToolScanRepos.cc
tests/lib/TestSetup.h

index dfe5a5a..18d325a 100644 (file)
@@ -501,8 +501,8 @@ try {
         getZYpp()->initializeTarget( sysRoot );
       }
       getZYpp()->target()->load();
-      USR << getZYpp()->target()->targetDistribution() << endl;
-      USR << getZYpp()->target()->targetDistributionRelease() << endl;
+      USR << "targetDistribution:        " << getZYpp()->target()->targetDistribution() << endl;
+      USR << "targetDistributionRelease: " << getZYpp()->target()->targetDistributionRelease() << endl;
       dumpRange( USR << "Product ", pool.byKindBegin<Product>(), pool.byKindEnd<Product>() ) << endl;
     }
   }
index 1a756c3..97ce17e 100644 (file)
@@ -1,28 +1,4 @@
 #include "Tools.h"
-#include "ExplicitMap.h"
-#include <boost/call_traits.hpp>
-
-#include <iostream>
-#include <fstream>
-#include <map>
-
-#include <zypp/base/LogControl.h>
-#include <zypp/base/LogTools.h>
-#include "zypp/base/Exception.h"
-#include "zypp/base/InputStream.h"
-#include "zypp/base/DefaultIntegral.h"
-#include <zypp/base/Function.h>
-#include <zypp/base/Iterator.h>
-
-#include <zypp/Pathname.h>
-#include <zypp/Edition.h>
-#include <zypp/CheckSum.h>
-#include <zypp/Date.h>
-
-using namespace std;
-using namespace zypp;
-
-///////////////////////////////////////////////////////////////////
 
 /******************************************************************
 **
@@ -33,6 +9,13 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
+  // https://bugzilla.novell.com/show_bug.cgi?id=442200
+
+  Pathname mroot( "/tmp/ToolScanRepos" );
+  TestSetup test( mroot, Arch_x86_64 );
+  test.loadRepos();
+
+
   INT << "===[END]============================================" << endl << endl;
   return 0;
 }
index 39413fa..11fb82b 100644 (file)
@@ -14,13 +14,22 @@ int main( int argc, char * argv[] )
 
   if ( ! argc )
   {
-    cerr << "Usage: " << appname << " URL..." << endl;
-    cerr << "  Load repos from URL to test system below /tmp/" << appname << endl;
+    cerr << "Usage: " << appname << "[OPTIONS] URL..." << endl;
+    cerr << "  Load repos from URL to test system below /tmp/" << appname << "." << endl;
+    cerr << "  --nc Do not clear an existing test system but reuse it." << endl;
     return 0;
   }
 
   Pathname mroot( "/tmp/"+appname );
-  filesystem::recursive_rmdir( mroot );
+  if ( argc && argv[0] == std::string("--nc") )
+  {
+    --argc;
+    ++argv;
+  }
+  else
+  {
+    filesystem::recursive_rmdir( mroot );
+  }
   filesystem::assert_dir( mroot );
   TestSetup test( mroot, Arch_x86_64 );
 
index f00ebad..310a14c 100644 (file)
@@ -84,6 +84,7 @@ class TestSetup
     void loadRepo( RepoInfo nrepo )
     {
       RepoManager rmanager( repomanager() );
+      rmanager.addRepository( nrepo );
       rmanager.buildCache( nrepo );
       rmanager.loadFromCache( nrepo );
     }
@@ -112,6 +113,37 @@ class TestSetup
       satpool().addRepoSolv( path_r, nrepo );
     }
 
+  public:
+    /** Load all enabled repos in repos.d to pool. */
+    void loadRepos()
+    {
+      RepoManager repoManager( repomanager() );
+      RepoInfoList repos = repoManager.knownRepositories();
+      for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it )
+      {
+        RepoInfo & nrepo( *it );
+        USR << nrepo << endl;
+
+        if ( ! nrepo.enabled() )
+          continue;
+
+        if ( ! repoManager.isCached( nrepo ) || nrepo.type() == repo::RepoType::RPMPLAINDIR )
+        {
+          if ( repoManager.isCached( nrepo ) )
+          {
+            USR << "cleanCache" << endl;
+            repoManager.cleanCache( nrepo );
+          }
+          //USR << "refreshMetadata" << endl;
+          //repoManager.refreshMetadata( nrepo );
+          USR << "buildCache" << endl;
+          repoManager.buildCache( nrepo );
+        }
+        USR << "Create from cache" << endl;
+        repoManager.loadFromCache( nrepo );
+      }
+
+    }
   private:
     void _ctor( const Pathname & rootdir_r, const Arch & sysarch_r )
     {