Mailinglist Archive: zypp-commit (171 mails)

< Previous Next >
[zypp-commit] <libzypp> master : LoadSystemAt convenience to detect and load a SolverTestcase, TestSetup or a real system to the pool.
  • From: Michael Andres <ma@xxxxxxx>
  • Date: Fri, 26 Jun 2009 12:45:44 +0200
  • Message-id: <E1MK8xV-00079w-Sw@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit c0c11f52b1754bf9bd96867a3fb8ec0d8d894c3f
Author: Michael Andres <ma@xxxxxxx>
Date: Fri Jun 26 11:47:22 2009 +0200

LoadSystemAt convenience to detect and load a SolverTestcase, TestSetup or
a real system to the pool.
---
tests/lib/TestSetup.h | 74 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 73 insertions(+), 1 deletions(-)

diff --git a/tests/lib/TestSetup.h b/tests/lib/TestSetup.h
index b371712..4108257 100644
--- a/tests/lib/TestSetup.h
+++ b/tests/lib/TestSetup.h
@@ -25,6 +25,7 @@ using std::cin;
using std::cout;
using std::cerr;
using std::endl;
+using std::flush;
using namespace zypp;

#ifndef BOOST_CHECK_NE
@@ -196,7 +197,7 @@ class TestSetup
public:
/** Directly load a helix repo from some testcase.
* An empty alias is guessed.
- */
+ */
void loadHelix( const Pathname & path_r, const std::string & alias_r =
std::string() )
{
// .solv file is loaded directly using a faked RepoInfo
@@ -306,6 +307,77 @@ class TestSetup
}
}

+ public:
+ /** Detect and load the system located at \a sysRoot.
+ *
+ * \a sysRoot needs to be a directory containing either a SolverTestcase,
+ * a TestSetup system or a real system. The provided repostitories are
+ * loaded into the pool (without refresh).
+ */
+ static void LoadSystemAt( const Pathname & sysRoot )
+ {
+ if ( ! PathInfo( sysRoot ).isDir() )
+ ZYPP_THROW( Exception("sysRoot argument needs to be a directory") );
+
+ if ( TestSetup::isTestcase( sysRoot ) )
+ {
+ USR << str::form( "*** Load Testcase from '%s'", sysRoot.c_str() ) <<
endl;
+ TestSetup test;
+ test.loadTestcaseRepos( sysRoot );
+ }
+ else if ( TestSetup::isTestSetup( sysRoot ) )
+ {
+ USR << str::form( "*** Load TestSetup from '%s'", sysRoot.c_str() ) <<
endl;
+ TestSetup test( sysRoot, Arch_x86_64 );
+ test.loadRepos();
+ }
+ else
+ {
+ sat::Pool satpool( sat::Pool::instance() );
+ // a system
+ USR << str::form( "*** Load system at '%s'", sysRoot.c_str() ) << endl;
+ if ( 1 )
+ {
+ USR << "*** load target '" << Repository::systemRepoAlias() << "'\t"
<< endl;
+ getZYpp()->initializeTarget( sysRoot );
+ getZYpp()->target()->load();
+ USR << satpool.systemRepo() << endl;
+ }
+
+ if ( 1 )
+ {
+ RepoManager repoManager( sysRoot );
+ RepoInfoList repos = repoManager.knownRepositories();
+ for_( it, repos.begin(), repos.end() )
+ {
+ RepoInfo & nrepo( *it );
+
+ if ( ! nrepo.enabled() )
+ continue;
+
+ if ( ! repoManager.isCached( nrepo ) )
+ {
+ USR << str::form( "*** omit uncached repo '%s' (do 'zypper
refresh')", nrepo.name().c_str() ) << endl;
+ continue;
+ }
+
+ USR << str::form( "*** load repo '%s'\t", nrepo.name().c_str() )
<< flush;
+ try
+ {
+ repoManager.loadFromCache( nrepo );
+ USR << satpool.reposFind( nrepo.alias() ) << endl;
+ }
+ catch ( const Exception & exp )
+ {
+ USR << exp.asString() + "\n" + exp.historyAsString() << endl;
+ USR << str::form( "*** omit broken repo '%s' (do 'zypper
refresh')", nrepo.name().c_str() ) << endl;
+ continue;
+ }
+ }
+ }
+ }
+ }
+
private:
void _ctor( const Pathname & rootdir_r, const Arch & sysarch_r, const
Options & options_r )
{
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages