fixup Fix to build with libxml 2.12.x (fixes #505)
[platform/upstream/libzypp.git] / tools / ProvideSignedDirectory.cc
1 #include <iostream>
2
3 #include <zypp/base/LogControl.h>
4 #include <zypp/base/LogTools.h>
5 #include <zypp/ExternalProgram.h>
6
7 #include <zypp/MediaSetAccess.h>
8 #include <zypp/KeyRing.h>
9 #include <zypp/Fetcher.h>
10 #include <zypp/TmpPath.h>
11
12
13 using std::endl;
14
15 int main ( int argc, const char * argv[] )
16 try {
17   --argc;
18   ++argv;
19   //zypp::base::LogControl::instance().logToStdErr();
20   INT << "===[START]==========================================" << endl;
21   ///////////////////////////////////////////////////////////////////
22
23   zypp::Url             oRemoteUrl( argv[0] ); //"http://download.opensuse.org/distribution/openSUSE-current/repo/oss" );
24   std::string           oRemoteDir( argv[1] ); //"/suse/setup/slide" );
25   const bool            oRecursive( true );
26   zypp::Pathname        oLocalDir( "" );
27
28   zypp::scoped_ptr<zypp::filesystem::TmpDir> tmpdir;
29   if ( oLocalDir.empty() )
30   {
31     tmpdir.reset( new zypp::filesystem::TmpDir );
32     oLocalDir = tmpdir->path();
33   }
34
35   zypp::Fetcher fetcher;
36   fetcher.setOptions( zypp::Fetcher::AutoAddIndexes );
37   fetcher.enqueueDir( zypp::OnMediaLocation( oRemoteDir ), oRecursive );
38
39   zypp::KeyRing::setDefaultAccept( zypp::KeyRing::TRUST_KEY_TEMPORARILY );
40   zypp::MediaSetAccess media( oRemoteUrl, "/" );
41   fetcher.start( oLocalDir, media );
42
43   zypp::ExternalProgram( "find "+(oLocalDir/oRemoteDir).asString()+" -ls" ) >> std::cout;
44
45   ///////////////////////////////////////////////////////////////////
46   INT << "===[END]============================================" << endl << endl;
47   zypp::base::LogControl::instance().logNothing();
48   return 0;
49 }
50 catch ( const zypp::Exception & exp )
51 {
52   INT << exp << endl << exp.historyAsString();
53 }
54 catch (...)
55 {}