3 #include <zypp/base/PtrTypes.h>
4 #include <zypp/base/Exception.h>
5 #include <zypp/base/ProvideNumericId.h>
7 #include "zypp/ZYppFactory.h"
8 #include "zypp/ResPoolProxy.h"
9 #include <zypp/SourceManager.h>
10 #include <zypp/SourceFactory.h>
12 #include "zypp/ZYppCallbacks.h"
13 #include "zypp/NVRAD.h"
14 #include "zypp/ResPool.h"
15 #include "zypp/ResFilters.h"
16 #include "zypp/CapFilters.h"
17 #include "zypp/Package.h"
18 #include "zypp/Pattern.h"
19 #include "zypp/Language.h"
20 #include "zypp/PackageKeyword.h"
21 #include "zypp/NameKindProxy.h"
22 #include "zypp/pool/GetResolvablesToInsDel.h"
24 #include "zypp/parser/tagfile/TagFileParser.h"
25 #include "zypp/parser/TagParser.h"
26 #include "zypp/parser/susetags/PackagesFileReader.h"
27 #include "zypp/parser/susetags/PackagesLangFileReader.h"
28 #include "zypp/parser/susetags/PatternFileReader.h"
29 #include "zypp/parser/susetags/ContentFileReader.h"
30 #include "zypp/parser/susetags/RepoIndex.h"
32 #include "zypp2/parser/susetags/RepoParser.h"
33 #include "zypp2/cache/CacheStore.h"
37 using namespace zypp::functor;
39 using zypp::parser::tagfile::TagFileParser;
40 using zypp::parser::TagParser;
42 ///////////////////////////////////////////////////////////////////
44 static const Pathname sysRoot( "/Local/ROOT" );
46 ///////////////////////////////////////////////////////////////////
48 struct ConvertDbReceive : public callback::ReceiveReport<target::ScriptResolvableReport>
50 virtual void start( const Resolvable::constPtr & script_r,
51 const Pathname & path_r,
54 SEC << __FUNCTION__ << endl
55 << " " << script_r << endl
56 << " " << path_r << endl
57 << " " << task_r << endl;
60 virtual bool progress( Notify notify_r, const std::string & text_r )
62 SEC << __FUNCTION__ << endl
63 << " " << notify_r << endl
64 << " " << text_r << endl;
68 virtual void problem( const std::string & description_r )
70 SEC << __FUNCTION__ << endl
71 << " " << description_r << endl;
76 SEC << __FUNCTION__ << endl;
81 ///////////////////////////////////////////////////////////////////
83 struct MediaChangeReceive : public callback::ReceiveReport<media::MediaChangeReport>
85 virtual Action requestMedia( Source_Ref source
88 , const std::string & description )
90 SEC << __FUNCTION__ << endl
91 << " " << source << endl
92 << " " << mediumNr << endl
93 << " " << error << endl
94 << " " << description << endl;
99 ///////////////////////////////////////////////////////////////////
104 bool isIn( const std::set<_Tp> & cont, const typename std::set<_Tp>::value_type & val )
105 { return cont.find( val ) != cont.end(); }
108 ///////////////////////////////////////////////////////////////////
110 struct AddResolvables
112 bool operator()( const Source_Ref & src ) const
114 getZYpp()->addResolvables( src.resolvables() );
119 ///////////////////////////////////////////////////////////////////
122 std::ostream & operator<<( std::ostream & str, const iostr::EachLine & obj )
124 str << "(" << obj.valid() << ")[" << obj.lineNo() << "|" << obj.lineStart() << "]{" << *obj << "}";
129 ///////////////////////////////////////////////////////////////////
131 { /////////////////////////////////////////////////////////////////
132 /////////////////////////////////////////////////////////////////
134 ///////////////////////////////////////////////////////////////////
136 using namespace zypp::parser::susetags;
137 #include "zypp2/cache/CacheStore.h"
139 void consumeIndex( const parser::susetags::RepoIndex_Ptr & index_r )
141 SEC << "[Index]" << index_r << endl;
144 void consumeProd( const data::Product_Ptr & prod_r )
146 SEC << "[Prod]" << prod_r << endl;
149 void consumePkg( const data::Package_Ptr & pkg_r )
151 //MIL << "[Pkg]" << pkg_r << endl;
154 void consumeSrcPkg( const data::SrcPackage_Ptr & pkg_r )
156 //DBG << "[Src]" << pkg_r << endl;
159 void consumePat( const data::Pattern_Ptr & pat_r )
161 MIL << "[Pat]" << pat_r << endl;
164 void pPackages( const Pathname & p )
166 Measure x( p.basename() );
167 PackagesFileReader tp;
168 tp.setPkgConsumer( consumePkg );
169 tp.setSrcPkgConsumer( consumeSrcPkg );
173 void pPackagesLang( const Pathname & p, const Locale & locale_r )
175 Measure x( p.basename() );
176 PackagesLangFileReader tp;
177 tp.setLocale( locale_r );
178 tp.setPkgConsumer( consumePkg );
179 tp.setSrcPkgConsumer( consumeSrcPkg );
183 void pPattern( const Pathname & p )
185 Measure x( p.basename() );
186 PatternFileReader tp;
187 tp.setConsumer( consumePat );
191 /******************************************************************
193 ** FUNCTION NAME : main
194 ** FUNCTION TYPE : int
196 int main( int argc, char * argv[] )
198 //zypp::base::LogControl::instance().logfile( "log.restrict" );
199 INT << "===[START]==========================================" << endl;
201 Pathname dbdir( "store" );
202 Pathname reporoot( "lmd" );
204 cache::CacheStore store( dbdir );
205 data::RecordId repositoryId = store.lookupOrAppendRepository( Url("dir:///"), "/" );
207 Measure x( "XXXXXXXXXXXXX" );
209 parser::susetags::RepoParser repo( repositoryId, store );
210 repo.parse( reporoot );
217 ContentFileReader tp;
218 tp.setProductConsumer( consumeProd );
219 tp.setRepoIndexConsumer( consumeIndex );
220 //tp.setSrcPkgConsumer( consumeSrcPkg );
226 //Pathname dbdir( "/Local/ma/zypp-TRUNK/BUILD/libzypp/devel/devel.ma/store" );
229 Pathname dbdir( "store" );
230 Pathname metadir( "lmd" );
232 cache::CacheStore store( dbdir );
233 data::RecordId repositoryId = store.lookupOrAppendRepository( Url("http://www.google.com"), "/" );
235 RepoParser( metadir, repositoryId, store );
241 ZYpp::Ptr z = getZYpp();
243 Pathname dbfile( "data.db" );
244 cache::CacheStore store(getenv("PWD"));
246 data::RecordId repository_id = store.lookupOrAppendRepository( Url("http://www.google.com"), "/");
248 PackagesParser parser( repository_id, store);
250 parser.start(argv[1], &progress_function);
253 catch ( const Exception &e )
255 cout << "ups! " << e.msg() << std::endl;
259 INT << "===[END]============================================" << endl << endl;
260 zypp::base::LogControl::instance().logNothing();
263 Pathname proot( "lmd/suse/setup/descr" );
265 pPackages( proot/"packages" );
266 //pPackages( proot/"packages.gz" );
267 pPackagesLang( proot/"packages.de", Locale("de") );
268 //pPackagesLang( proot/"packages.de.gz", Locale("de") );
269 pPattern( proot/"base-10.3-30.x86_64.pat" );
273 Measure x( "lmd.idx" );
274 std::ifstream fIndex( "lmd.idx" );
275 for( iostr::EachLine in( fIndex ); in; in.next() )
278 std::ifstream fIn( (*in).c_str() );
279 for( iostr::EachLine l( fIn ); l; l.next() )
285 INT << "===[END]============================================" << endl << endl;
286 zypp::base::LogControl::instance().logNothing();