ref: refs/heads/master
commit 96d0b535758ac122a1af02990e07ee41ac6fc4ac
Author: Michael Andres
Date: Thu Mar 5 11:09:16 2009 +0100
Add tools/ToolScanRepos: Load repos from URL to test system below /tmp/
---
devel/devel.ma/ToolScanRepos.cc | 132 --------------------------------------
tools/CMakeLists.txt | 17 +++++-
tools/ToolScanRepos.cc | 134 +++++++++++++++++++++++++++++++++++++++
3 files changed, 150 insertions(+), 133 deletions(-)
diff --git a/devel/devel.ma/ToolScanRepos.cc b/devel/devel.ma/ToolScanRepos.cc
deleted file mode 100644
index e2f88db..0000000
--- a/devel/devel.ma/ToolScanRepos.cc
+++ /dev/null
@@ -1,132 +0,0 @@
-#include "Tools.h"
-
-static std::string appname( "ToolScanRepos" );
-
-void message( const std::string & msg_r )
-{
- cerr << "*** " << msg_r << endl;
-}
-
-int usage( const std::string & msg_r = std::string(), int exit_r = 100 )
-{
- if ( ! msg_r.empty() )
- {
- cerr << endl;
- message( msg_r );
- cerr << endl;
- }
- cerr << "Usage: " << appname << "[OPTIONS] URL..." << endl;
- cerr << " Load repos from URL to test system below /tmp/" << appname << "." << endl;
- cerr << " -r ROOT Use /tmp/ROOT as location of test system (default: " << appname << ")." << endl;
- cerr << " -a ARCH Use ARCH as test system architecture (default: x86_64)." << endl;
- cerr << " -c Clear an existing test system (default)." << endl;
- cerr << " -n Do not clear an existing test system but reuse it." << endl;
- return exit_r;
-}
-
-/******************************************************************
-**
-** FUNCTION NAME : main
-** FUNCTION TYPE : int
-*/
-int main( int argc, char * argv[] )
-{
- INT << "===[START]==========================================" << endl;
- appname = Pathname::basename( argv[0] );
- --argc;
- ++argv;
-
- if ( ! argc )
- {
- return usage();
- }
-
- ///////////////////////////////////////////////////////////////////
- Pathname mtmp( "/tmp" );
- Pathname mroot( mtmp/appname );
- Arch march( Arch_x86_64 );
- bool oClearRoot = true;
-
- std::vectorstd::string urls;
-
- while ( argc )
- {
- if ( argv[0] == std::string("-c") )
- {
- oClearRoot = true;
- }
- else if ( argv[0] == std::string("-n") )
- {
- oClearRoot = false;
- }
- else if ( argv[0] == std::string("-r") )
- {
- --argc;
- ++argv;
- if ( ! argc )
- return usage( "Missing arg to -r ROOT", 101 );
-
- if ( *(argv[0]) ) // empty
- mroot = mtmp/argv[0];
- else
- mroot = mtmp/appname;
- }
- else if ( argv[0] == std::string("-a") )
- {
- --argc;
- ++argv;
- if ( ! argc )
- return usage( "Missing arg to -a ARCH", 101 );
-
- if ( *(argv[0]) ) // empty
- march = Arch( argv[0] );
- else
- march = Arch_x86_64;
- }
- else
- {
- urls.push_back( argv[0] );
- }
- --argc;
- ++argv;
- }
-
- if ( urls.empty() )
- {
- return usage( "Missing URLs", 102 );
- }
-
- ///////////////////////////////////////////////////////////////////
-
- if ( oClearRoot )
- {
- message( "Clear test system at " + mroot.asString() );
- filesystem::recursive_rmdir( mroot );
- }
- else
- {
- message( "Use test system at " + mroot.asString() );
- }
- filesystem::assert_dir( mroot );
-
- message( "Use archiecture " + march.asString() );
- TestSetup test( mroot, march );
-
- int ret = 0;
- for_( it, urls.begin(), urls.end() )
- {
- message( "Setup " + *it );
- try
- {
- test.loadRepo( *it );
- }
- catch ( const Exception & exp )
- {
- message( exp.asString() + "\n" + exp.historyAsString() );
- ++ret;
- }
- }
-
- INT << "===[END]============================================" << endl << endl;
- return ret;
-}
\ No newline at end of file
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 128c027..cd81927 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -1,2 +1,17 @@
+
ADD_SUBDIRECTORY( package-manager )
-#ADD_SUBDIRECTORY( migrate-sources )
+
+## ############################################################
+
+FILE( GLOB ALLCC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc" )
+STRING( REPLACE ".cc" ";" APLLPROG ${ALLCC} )
+FOREACH( loop_var ${APLLPROG} )
+ ADD_EXECUTABLE( ${loop_var}
+ ${loop_var}.cc
+ )
+ TARGET_LINK_LIBRARIES( ${loop_var}
+ zypp
+ )
+ENDFOREACH( loop_var )
+
+## ############################################################
diff --git a/tools/ToolScanRepos.cc b/tools/ToolScanRepos.cc
new file mode 100644
index 0000000..77ac136
--- /dev/null
+++ b/tools/ToolScanRepos.cc
@@ -0,0 +1,134 @@
+#define INCLUDE_TESTSETUP_WITHOUT_BOOST
+#include "zypp/../tests/lib/TestSetup.h"
+#undef INCLUDE_TESTSETUP_WITHOUT_BOOST
+
+static std::string appname( "ToolScanRepos" );
+
+void message( const std::string & msg_r )
+{
+ cerr << "*** " << msg_r << endl;
+}
+
+int usage( const std::string & msg_r = std::string(), int exit_r = 100 )
+{
+ if ( ! msg_r.empty() )
+ {
+ cerr << endl;
+ message( msg_r );
+ cerr << endl;
+ }
+ cerr << "Usage: " << appname << "[OPTIONS] URL..." << endl;
+ cerr << " Load repos from URL to test system below /tmp/" << appname << "." << endl;
+ cerr << " -r ROOT Use /tmp/ROOT as location of test system (default: " << appname << ")." << endl;
+ cerr << " -a ARCH Use ARCH as test system architecture (default: x86_64)." << endl;
+ cerr << " -c Clear an existing test system (default)." << endl;
+ cerr << " -n Do not clear an existing test system but reuse it." << endl;
+ return exit_r;
+}
+
+/******************************************************************
+**
+** FUNCTION NAME : main
+** FUNCTION TYPE : int
+*/
+int main( int argc, char * argv[] )
+{
+ INT << "===[START]==========================================" << endl;
+ appname = Pathname::basename( argv[0] );
+ --argc;
+ ++argv;
+
+ if ( ! argc )
+ {
+ return usage();
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ Pathname mtmp( "/tmp" );
+ Pathname mroot( mtmp/appname );
+ Arch march( Arch_x86_64 );
+ bool oClearRoot = true;
+
+ std::vectorstd::string urls;
+
+ while ( argc )
+ {
+ if ( argv[0] == std::string("-c") )
+ {
+ oClearRoot = true;
+ }
+ else if ( argv[0] == std::string("-n") )
+ {
+ oClearRoot = false;
+ }
+ else if ( argv[0] == std::string("-r") )
+ {
+ --argc;
+ ++argv;
+ if ( ! argc )
+ return usage( "Missing arg to -r ROOT", 101 );
+
+ if ( *(argv[0]) ) // empty
+ mroot = mtmp/argv[0];
+ else
+ mroot = mtmp/appname;
+ }
+ else if ( argv[0] == std::string("-a") )
+ {
+ --argc;
+ ++argv;
+ if ( ! argc )
+ return usage( "Missing arg to -a ARCH", 101 );
+
+ if ( *(argv[0]) ) // empty
+ march = Arch( argv[0] );
+ else
+ march = Arch_x86_64;
+ }
+ else
+ {
+ urls.push_back( argv[0] );
+ }
+ --argc;
+ ++argv;
+ }
+
+ if ( urls.empty() )
+ {
+ return usage( "Missing URLs", 102 );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+
+ if ( oClearRoot )
+ {
+ message( "Clear test system at " + mroot.asString() );
+ filesystem::recursive_rmdir( mroot );
+ }
+ else
+ {
+ message( "Use test system at " + mroot.asString() );
+ }
+ filesystem::assert_dir( mroot );
+
+ message( "Use archiecture " + march.asString() );
+ TestSetup test( mroot, march );
+
+ int ret = 0;
+ for_( it, urls.begin(), urls.end() )
+ {
+ message( "Setup " + *it );
+ try
+ {
+ test.loadRepo( *it );
+ }
+ catch ( const Exception & exp )
+ {
+ message( exp.asString() + "\n" + exp.historyAsString() );
+ ++ret;
+ }
+ }
+
+ INT << "===[END]============================================" << endl << endl;
+ return ret;
+}
\ No newline at end of file
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org