From: Michael Andres Date: Thu, 6 Nov 2008 17:30:27 +0000 (+0000) Subject: add TestSetup::loadRepos: Load all enabled repos in repos.d to pool. X-Git-Tag: BASE-SuSE-Code-11-Branch~138 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=60d6fc268c8dfca14e77024165565668d84bb9a6;p=platform%2Fupstream%2Flibzypp.git add TestSetup::loadRepos: Load all enabled repos in repos.d to pool. --- diff --git a/devel/devel.ma/NewPool.cc b/devel/devel.ma/NewPool.cc index dfe5a5a..18d325a 100644 --- a/devel/devel.ma/NewPool.cc +++ b/devel/devel.ma/NewPool.cc @@ -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(), pool.byKindEnd() ) << endl; } } diff --git a/devel/devel.ma/Test.cc b/devel/devel.ma/Test.cc index 1a756c3..97ce17e 100644 --- a/devel/devel.ma/Test.cc +++ b/devel/devel.ma/Test.cc @@ -1,28 +1,4 @@ #include "Tools.h" -#include "ExplicitMap.h" -#include - -#include -#include -#include - -#include -#include -#include "zypp/base/Exception.h" -#include "zypp/base/InputStream.h" -#include "zypp/base/DefaultIntegral.h" -#include -#include - -#include -#include -#include -#include - -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; } diff --git a/devel/devel.ma/ToolScanRepos.cc b/devel/devel.ma/ToolScanRepos.cc index 39413fa..11fb82b 100644 --- a/devel/devel.ma/ToolScanRepos.cc +++ b/devel/devel.ma/ToolScanRepos.cc @@ -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 ); diff --git a/tests/lib/TestSetup.h b/tests/lib/TestSetup.h index f00ebad..310a14c 100644 --- a/tests/lib/TestSetup.h +++ b/tests/lib/TestSetup.h @@ -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 ) {