df98807c809ea5bf8f41d113aaf891a08e247f0e
[platform/upstream/libzypp.git] / devel / devel.ma / Main.cc
1 #include "Tools.h"
2
3 #include "zypp/base/Easy.h"
4 #include "zypp/base/LogTools.h"
5 #include "zypp/base/InputStream.h"
6 #include "zypp/base/ReferenceCounted.h"
7 #include "zypp/base/NonCopyable.h"
8 #include "zypp/base/PtrTypes.h"
9
10 #include "zypp/TmpPath.h"
11
12 #include "zypp/RepoManager.h"
13 #include "zypp/RepoInfo.h"
14
15 #include "zypp/ResPoolProxy.h"
16
17 using std::endl;
18 using namespace zypp;
19
20 ///////////////////////////////////////////////////////////////////
21
22 static const Pathname sysRoot( getenv("SYSROOT") ? getenv("SYSROOT") : "/Local/ROOT" );
23
24 ///////////////////////////////////////////////////////////////////
25
26 bool solve()
27 {
28   bool rres = false;
29   {
30     //zypp::base::LogControl::TmpLineWriter shutUp;
31     rres = getZYpp()->resolver()->resolvePool();
32   }
33   if ( ! rres )
34   {
35     ERR << "resolve " << rres << endl;
36     return false;
37   }
38   MIL << "resolve " << rres << endl;
39   return true;
40 }
41
42 void mksrc( const std::string & url, const std::string & alias )
43 {
44   RepoManager repoManager( makeRepoManager( sysRoot ) );
45
46   RepoInfo nrepo;
47   nrepo
48       .setAlias( alias )
49       .setName( alias )
50       .setEnabled( true )
51       .setAutorefresh( false )
52       .addBaseUrl( Url(url) );
53
54   if ( ! repoManager.isCached( nrepo ) )
55   {
56     repoManager.buildCache( nrepo );
57   }
58
59   repoManager.loadFromCache( nrepo );
60 }
61
62 /******************************************************************
63 **
64 **      FUNCTION NAME : main
65 **      FUNCTION TYPE : int
66 */
67 int main( int argc, char * argv[] )
68 {
69   INT << "===[START]==========================================" << endl;
70
71   ResPool   pool( ResPool::instance() );
72   sat::Pool satpool( sat::Pool::instance() );
73
74   mksrc( "file:///schnell/CD-ARCHIVE/SLES10/SLE-10-SP1/SLES-10-SP1-GM/ia64/DVD1", "SLE" );
75   mksrc( "file:///mounts/dist/install/SLP/SLES-10-SP2-AS-LATEST/i386/CD1", "factorytest" );
76
77   USR << "pool: " << pool << endl;
78
79   getSel<Product>( "SUSE_SLES_SP1" )->setStatus( ui::S_Install );
80   //getSel<Pattern>( "basesystem" )->setStatus( ui::S_Install );
81   //getSel<Pattern>( "slesas-ofed-base" )->setStatus( ui::S_Install );
82
83   if ( 1 )
84   {
85     vdumpPoolStats( USR << "Transacting:"<< endl,
86                     make_filter_begin<resfilter::ByTransact>(pool),
87                     make_filter_end<resfilter::ByTransact>(pool) ) << endl;
88     solve();
89     vdumpPoolStats( USR << "Transacting:"<< endl,
90                     make_filter_begin<resfilter::ByTransact>(pool),
91                     make_filter_end<resfilter::ByTransact>(pool) ) << endl;
92   }
93
94   INT << "===[END]============================================" << endl << endl;
95   return 0;
96 }