1 #define INCLUDE_TESTSETUP_WITHOUT_BOOST
2 #include "zypp/../tests/lib/TestSetup.h"
3 #undef INCLUDE_TESTSETUP_WITHOUT_BOOST
6 #include <zypp/PoolQuery.h>
8 static std::string appname( "DumpSelectable" );
13 int errexit( const std::string & msg_r = std::string(), int exit_r = 100 )
15 if ( ! msg_r.empty() )
17 cerr << endl << msg_r << endl << endl;
22 int usage( const std::string & msg_r = std::string(), int exit_r = 100 )
24 if ( ! msg_r.empty() )
26 cerr << endl << msg_r << endl << endl;
28 cerr << "Usage: " << appname << " [--root ROOTDIR] [OPTIONS] NAME..." << endl;
29 cerr << " Load all enabled repositories (no refresh) and search for" << endl;
30 cerr << " Selectables names NAME" << endl;
31 cerr << " --root Load repos from the system located below ROOTDIR. If ROOTDIR" << endl;
32 cerr << " denotes a sover testcase, the testcase is loaded." << endl;
37 /******************************************************************
39 ** FUNCTION NAME : main
40 ** FUNCTION TYPE : int
42 int main( int argc, char * argv[] )
44 INT << "===[START]==========================================" << endl;
45 appname = Pathname::basename( argv[0] );
53 ///////////////////////////////////////////////////////////////////
56 Pathname sysRoot("/");
57 sat::Pool satpool( sat::Pool::instance() );
59 if ( (*argv) == std::string("--root") )
63 return errexit("--root requires an argument.");
65 if ( ! PathInfo( *argv ).isDir() )
66 return errexit("--root requires a directory.");
72 if ( TestSetup::isTestcase( sysRoot ) )
74 message << str::form( "*** Load Testcase from '%s'", sysRoot.c_str() ) << endl;
76 test.loadTestcaseRepos( sysRoot );
78 else if ( TestSetup::isTestSetup( sysRoot ) )
80 message << str::form( "*** Load TestSetup from '%s'", sysRoot.c_str() ) << endl;
81 TestSetup test( sysRoot, Arch_x86_64 );
87 message << str::form( "*** Load system at '%s'", sysRoot.c_str() ) << endl;
90 message << "*** load target '" << Repository::systemRepoAlias() << "'\t" << endl;
91 getZYpp()->initializeTarget( sysRoot );
92 getZYpp()->target()->load();
93 message << satpool.systemRepo() << endl;
98 RepoManager repoManager( sysRoot );
99 RepoInfoList repos = repoManager.knownRepositories();
100 for_( it, repos.begin(), repos.end() )
102 RepoInfo & nrepo( *it );
104 if ( ! nrepo.enabled() )
107 if ( ! repoManager.isCached( nrepo ) )
109 message << str::form( "*** omit uncached repo '%s' (do 'zypper refresh')", nrepo.name().c_str() ) << endl;
113 message << str::form( "*** load repo '%s'\t", nrepo.name().c_str() ) << flush;
116 repoManager.loadFromCache( nrepo );
117 message << satpool.reposFind( nrepo.alias() ) << endl;
119 catch ( const Exception & exp )
121 message << exp.asString() + "\n" + exp.historyAsString() << endl;
122 message << str::form( "*** omit broken repo '%s' (do 'zypper refresh')", nrepo.name().c_str() ) << endl;
129 ///////////////////////////////////////////////////////////////////
131 for ( ; argc; --argc,++argv )
133 message << dump( ui::Selectable::get( IdString( *argv ) ) ) << endl;
136 INT << "===[END]============================================" << endl << endl;