3 #include <zypp/base/PtrTypes.h>
4 #include <zypp/base/Exception.h>
5 #include <zypp/base/LogTools.h>
6 #include <zypp/base/ProvideNumericId.h>
7 #include <zypp/AutoDispose.h>
9 #include "zypp/ZYppFactory.h"
10 #include "zypp/ResPoolProxy.h"
12 #include "zypp/ZYppCallbacks.h"
13 #include "zypp/NVRAD.h"
14 #include "zypp/ResPool.h"
15 #include "zypp/ResFilters.h"
16 #include "zypp/Package.h"
17 #include "zypp/Pattern.h"
18 #include "zypp/Language.h"
19 #include "zypp/Digest.h"
20 #include "zypp/PackageKeyword.h"
23 #include "zypp/parser/TagParser.h"
24 #include "zypp/parser/susetags/PackagesFileReader.h"
25 #include "zypp/parser/susetags/PackagesLangFileReader.h"
26 #include "zypp/parser/susetags/PatternFileReader.h"
27 #include "zypp/parser/susetags/ContentFileReader.h"
28 #include "zypp/parser/susetags/RepoIndex.h"
29 #include "zypp/parser/susetags/RepoParser.h"
30 #include "zypp/cache/CacheStore.h"
31 #include "zypp/RepoManager.h"
32 #include "zypp/RepoInfo.h"
34 #include "zypp/ui/PatchContents.h"
35 #include "zypp/ResPoolProxy.h"
39 using namespace zypp::functor;
40 using namespace zypp::ui;
41 using zypp::parser::TagParser;
43 ///////////////////////////////////////////////////////////////////
45 static const Pathname sysRoot( "/Local/GTEST" );
47 ///////////////////////////////////////////////////////////////////
51 bool operator()( const PoolItem & obj_r )
53 // handle( asKind<Package>( obj_r ) );
54 // handle( asKind<Patch>( obj_r ) );
55 // handle( asKind<Pattern>( obj_r ) );
56 // handle( asKind<Product>( obj_r ) );
60 void handle( const Package_constPtr & p )
66 void handle( const Patch_constPtr & p )
72 void handle( const Pattern_constPtr & p )
78 void handle( const Product_constPtr & p )
85 ///////////////////////////////////////////////////////////////////
86 /******************************************************************
88 ** FUNCTION NAME : main
89 ** FUNCTION TYPE : int
91 int main( int argc, char * argv[] )
93 //zypp::base::LogControl::instance().logfile( "log.restrict" );
94 INT << "===[START]==========================================" << endl;
96 setenv( "ZYPP_CONF", (sysRoot/"zypp.conf").c_str(), 1 );
98 RepoManager repoManager( makeRepoManager( sysRoot ) );
99 RepoInfoList repos = repoManager.knownRepositories();
100 SEC << "knownRepositories " << repos << endl;
106 .setAlias( "factorytest" )
107 .setName( "Test Repo for factory." )
109 .setAutorefresh( false )
110 .addBaseUrl( Url("http://dist.suse.de/install/stable-x86/") );
112 repoManager.addRepository( nrepo );
113 repos = repoManager.knownRepositories();
116 for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it )
118 RepoInfo & nrepo( *it );
119 if ( ! nrepo.enabled() )
122 SEC << "refreshMetadata" << endl;
123 repoManager.refreshMetadata( nrepo );
125 if ( ! repoManager.isCached( nrepo ) || 0 )
127 if ( repoManager.isCached( nrepo ) )
129 SEC << "cleanCache" << endl;
130 repoManager.cleanCache( nrepo );
132 SEC << "refreshMetadata" << endl;
133 repoManager.refreshMetadata( nrepo, RepoManager::RefreshForced );
134 SEC << "buildCache" << endl;
135 repoManager.buildCache( nrepo );
138 SEC << nrepo << endl;
139 Repository nrep( repoManager.createFromCache( nrepo ) );
140 const zypp::ResStore & store( nrep.resolvables() );
141 dumpPoolStats( SEC << "Store: " << endl,
142 store.begin(), store.end() ) << endl;
143 getZYpp()->addResolvables( store );
146 ResPool pool( getZYpp()->pool() );
147 vdumpPoolStats( USR << "Initial pool:" << endl,
149 pool.end() ) << endl;
154 //zypp::base::LogControl::TmpLineWriter shutUp;
155 getZYpp()->initTarget( sysRoot );
157 MIL << "Added target: " << pool << endl;
160 std::for_each( pool.begin(), pool.end(), Xprint() );
162 ///////////////////////////////////////////////////////////////////
163 INT << "===[END]============================================" << endl << endl;
164 zypp::base::LogControl::instance().logNothing();