12 #include <zypp/base/String.h>
13 #include <zypp/base/Exception.h>
14 #include <zypp/base/PtrTypes.h>
15 #include <zypp/base/Iterator.h>
16 #include <zypp/base/Algorithm.h>
17 #include <zypp/base/Functional.h>
18 #include <zypp/base/ProvideNumericId.h>
19 #include <zypp/base/ProvideNumericId.h>
21 #include "zypp/NVRAD.h"
22 #include "zypp/ResPool.h"
23 #include "zypp/ResFilters.h"
24 #include "zypp/CapFilters.h"
25 #include "zypp/Package.h"
26 #include "zypp/Language.h"
27 #include "zypp/NameKindProxy.h"
29 #include <zypp/SourceManager.h>
30 #include <zypp/SourceFactory.h>
31 #include <zypp/source/susetags/SuseTagsImpl.h>
33 #include "zypp/ZYppFactory.h"
34 #include "zypp/ResPoolProxy.h"
35 #include "zypp/ResPoolProxy.h"
36 #include "zypp/target/rpm/RpmDb.h"
40 using namespace zypp::ui;
41 using namespace zypp::functor;
43 ///////////////////////////////////////////////////////////////////
45 static const Pathname sysRoot( "/Local/ROOT" );
46 static const Url instSrc( "dir:/Local/SLES10" );
47 //static const Url instSrc( "dir:/Local/FACTORY" );
49 ///////////////////////////////////////////////////////////////////
54 bool isIn( const std::set<_Tp> & cont, const typename std::set<_Tp>::value_type & val )
55 { return cont.find( val ) != cont.end(); }
58 ///////////////////////////////////////////////////////////////////
60 template<class _Condition>
63 SetTrue( _Condition cond_r )
68 bool operator()( _Tp t ) const
77 template<class _Condition>
78 inline SetTrue<_Condition> setTrue_c( _Condition cond_r )
80 return SetTrue<_Condition>( cond_r );
83 template <class _Iterator, class _Filter, class _Function>
84 inline _Function for_each_if( _Iterator begin_r, _Iterator end_r,
88 for ( _Iterator it = begin_r; it != end_r; ++it )
90 if ( filter_r( *it ) )
98 ///////////////////////////////////////////////////////////////////
100 template <class _Iterator>
101 std::ostream & vdumpPoolStats( std::ostream & str,
102 _Iterator begin_r, _Iterator end_r )
104 pool::PoolStats stats;
105 // std::for_each( begin_r, end_r,
107 // functor::chain( setTrue_c(PrintPoolItem()),
108 // setTrue_c(functor::functorRef<void,ResObject::constPtr>(stats)) )
114 struct PoolItemSelect
116 void operator()( const PoolItem & pi ) const
118 if ( pi->source().numericId() == 2 )
119 pi.status().setTransact( true, ResStatus::USER );
123 /******************************************************************
125 ** FUNCTION NAME : main
126 ** FUNCTION TYPE : int
128 int main( int argc, char * argv[] )
130 //zypp::base::LogControl::instance().logfile( "xxx" );
131 INT << "===[START]==========================================" << endl;
133 ResPool pool( getZYpp()->pool() );
137 Measure x( "initTarget " + sysRoot.asString() );
138 getZYpp()->initTarget( sysRoot );
139 getZYpp()->addResolvables( getZYpp()->target()->resolvables(), true );
140 INT << "Added target: " << pool << endl;
144 SourceManager::sourceManager()->restore( sysRoot );
145 if ( SourceManager::sourceManager()->allSources().empty() )
147 Source_Ref src( createSource( instSrc ) );
148 SourceManager::sourceManager()->addSource( src );
149 SourceManager::sourceManager()->store( sysRoot, true );
152 Source_Ref src( *SourceManager::sourceManager()->Source_begin() );
153 getZYpp()->addResolvables( src.resolvables() );
154 INT << "Added source: " << pool << endl;
157 Source_Ref src1( createSource( "dir:/Local/SUSE-Linux-10.1-Build_830-Addon-BiArch/CD1" ) );
158 Source_Ref src2( createSource( "dir:/Local/SUSE-Linux-10.1-Build_830-i386/CD1" ) );
159 INT << "Pool: " << pool << endl;
160 getZYpp()->addResolvables( src1.resolvables() );
161 INT << "Added source1: " << pool << endl;
162 getZYpp()->addResolvables( src2.resolvables() );
163 INT << "Added source2: " << pool << endl;
169 Source_Ref src( *SourceManager::sourceManager()->Source_begin() );
170 const std::list<Pathname> srcKeys( src.publicKeys() );
172 DBG << srcKeys << endl;
174 target::rpm::RpmDb rpm;
175 rpm.initDatabase( sysRoot );
176 std::set<Edition> rpmKeys( rpm.pubkeys() );
178 DBG << rpmKeys << endl;
180 ResPool pool( getZYpp()->pool() );
181 getZYpp()->addResolvables( src.resolvables() );
187 INT << "===[END]============================================" << endl << endl;