-#include <ctime>
-#include <iostream>
#include "Tools.h"
#include <zypp/base/PtrTypes.h>
#include <zypp/SourceManager.h>
#include <zypp/SourceFactory.h>
+#include "zypp/ZYppCallbacks.h"
#include "zypp/NVRAD.h"
#include "zypp/ResPool.h"
#include "zypp/ResFilters.h"
#include "zypp/CapFilters.h"
#include "zypp/Package.h"
+#include "zypp/Pattern.h"
#include "zypp/Language.h"
+#include "zypp/PackageKeyword.h"
#include "zypp/NameKindProxy.h"
#include "zypp/pool/GetResolvablesToInsDel.h"
+#include "zypp/parser/tagfile/TagFileParser.h"
+#include "zypp/parser/TagParser.h"
+#include "zypp/parser/susetags/PackagesFileReader.h"
+#include "zypp/parser/susetags/PackagesLangFileReader.h"
+#include "zypp/parser/susetags/PatternFileReader.h"
+#include "zypp/parser/susetags/ContentFileReader.h"
+#include "zypp/parser/susetags/RepoIndex.h"
+
+#include "zypp/parser/susetags/RepoParser.h"
+#include "zypp/cache/CacheStore.h"
using namespace std;
using namespace zypp;
-using namespace zypp::ui;
using namespace zypp::functor;
+using zypp::parser::tagfile::TagFileParser;
+using zypp::parser::TagParser;
+
///////////////////////////////////////////////////////////////////
static const Pathname sysRoot( "/Local/ROOT" );
///////////////////////////////////////////////////////////////////
-namespace container
+struct ConvertDbReceive : public callback::ReceiveReport<target::ScriptResolvableReport>
{
- template<class _Tp>
- bool isIn( const std::set<_Tp> & cont, const typename std::set<_Tp>::value_type & val )
- { return cont.find( val ) != cont.end(); }
-}
-
-///////////////////////////////////////////////////////////////////
-
-template<class _Condition>
- struct SetTrue
+ virtual void start( const Resolvable::constPtr & script_r,
+ const Pathname & path_r,
+ Task task_r )
{
- SetTrue( _Condition cond_r )
- : _cond( cond_r )
- {}
-
- template<class _Tp>
- bool operator()( _Tp t ) const
- {
- _cond( t );
- return true;
- }
-
- _Condition _cond;
- };
+ SEC << __FUNCTION__ << endl
+ << " " << script_r << endl
+ << " " << path_r << endl
+ << " " << task_r << endl;
+ }
-template<class _Condition>
- inline SetTrue<_Condition> setTrue_c( _Condition cond_r )
+ virtual bool progress( Notify notify_r, const std::string & text_r )
{
- return SetTrue<_Condition>( cond_r );
+ SEC << __FUNCTION__ << endl
+ << " " << notify_r << endl
+ << " " << text_r << endl;
+ return true;
}
-template <class _Iterator, class _Filter, class _Function>
- inline _Function for_each_if( _Iterator begin_r, _Iterator end_r,
- _Filter filter_r,
- _Function fnc_r )
+ virtual void problem( const std::string & description_r )
{
- for ( _Iterator it = begin_r; it != end_r; ++it )
- {
- if ( filter_r( *it ) )
- {
- fnc_r( *it );
- }
- }
- return fnc_r;
+ SEC << __FUNCTION__ << endl
+ << " " << description_r << endl;
}
-struct PrintPoolItem
-{
- void operator()( const PoolItem & pi ) const
- { USR << pi << " (" << pi.resolvable().get() << ")" <<endl; }
-};
-
-template <class _Iterator>
- std::ostream & vdumpPoolStats( std::ostream & str,
- _Iterator begin_r, _Iterator end_r )
+ virtual void finish()
{
- pool::PoolStats stats;
- std::for_each( begin_r, end_r,
+ SEC << __FUNCTION__ << endl;
+ }
- functor::chain( setTrue_c(PrintPoolItem()),
- setTrue_c(functor::functorRef<void,ResObject::constPtr>(stats)) )
+};
- );
- return str << stats;
- }
+///////////////////////////////////////////////////////////////////
-struct PoolItemSelect
+struct MediaChangeReceive : public callback::ReceiveReport<media::MediaChangeReport>
{
- void operator()( const PoolItem & pi ) const
+ virtual Action requestMedia( Source_Ref source
+ , unsigned mediumNr
+ , Error error
+ , const std::string & description )
{
- if ( pi->source().numericId() == 2 )
- pi.status().setTransact( true, ResStatus::USER );
+ SEC << __FUNCTION__ << endl
+ << " " << source << endl
+ << " " << mediumNr << endl
+ << " " << error << endl
+ << " " << description << endl;
+ return IGNORE;
}
};
///////////////////////////////////////////////////////////////////
-typedef std::list<PoolItem> PoolItemList;
-typedef std::set<PoolItem> PoolItemSet;
-#include "zypp/solver/detail/InstallOrder.h"
-using zypp::solver::detail::InstallOrder;
-#include "Iorder.h"
+
+namespace container
+{
+ template<class _Tp>
+ bool isIn( const std::set<_Tp> & cont, const typename std::set<_Tp>::value_type & val )
+ { return cont.find( val ) != cont.end(); }
+}
///////////////////////////////////////////////////////////////////
struct AddResolvables
{
bool operator()( const Source_Ref & src ) const
- { getZYpp()->addResolvables( src.resolvables() ); }
+ {
+ getZYpp()->addResolvables( src.resolvables() );
+ return true;
+ }
};
///////////////////////////////////////////////////////////////////
-struct SetTransactValue
+
+std::ostream & operator<<( std::ostream & str, const iostr::EachLine & obj )
{
- SetTransactValue( ResStatus::TransactValue newVal_r, ResStatus::TransactByValue causer_r )
- : _newVal( newVal_r )
- , _causer( causer_r )
- {}
+ str << "(" << obj.valid() << ")[" << obj.lineNo() << "|" << obj.lineStart() << "]{" << *obj << "}";
+ return str;
- ResStatus::TransactValue _newVal;
- ResStatus::TransactByValue _causer;
+}
- bool operator()( const PoolItem & pi ) const
- { return pi.status().setTransactValue( _newVal, _causer ); }
-};
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+
+using namespace zypp::parser::susetags;
+#include "zypp/cache/CacheStore.h"
-struct StatusReset : public SetTransactValue
+void consumeIndex( const parser::susetags::RepoIndex_Ptr & index_r )
{
- StatusReset()
- : SetTransactValue( ResStatus::KEEP_STATE, ResStatus::USER )
- {}
-};
+ SEC << "[Index]" << index_r << endl;
+}
+
+void consumeProd( const data::Product_Ptr & prod_r )
+{
+ SEC << "[Prod]" << prod_r << endl;
+}
+void consumePkg( const data::Package_Ptr & pkg_r )
+{
+ //MIL << "[Pkg]" << pkg_r << endl;
+}
-inline bool selectForTransact( const NameKindProxy & nkp )
+void consumeSrcPkg( const data::SrcPackage_Ptr & pkg_r )
{
- if ( nkp.availableEmpty() )
- return false;
+ //DBG << "[Src]" << pkg_r << endl;
+}
- return nkp.availableBegin()->status().setTransact( true, ResStatus::USER );
+void consumePat( const data::Pattern_Ptr & pat_r )
+{
+ MIL << "[Pat]" << pat_r << endl;
}
-///////////////////////////////////////////////////////////////////
+void pPackages( const Pathname & p )
+{
+ Measure x( p.basename() );
+ PackagesFileReader tp;
+ tp.setPkgConsumer( consumePkg );
+ tp.setSrcPkgConsumer( consumeSrcPkg );
+ tp.parse( p );
+}
+
+void pPackagesLang( const Pathname & p, const Locale & locale_r )
+{
+ Measure x( p.basename() );
+ PackagesLangFileReader tp;
+ tp.setLocale( locale_r );
+ tp.setPkgConsumer( consumePkg );
+ tp.setSrcPkgConsumer( consumeSrcPkg );
+ tp.parse( p );
+}
+
+void pPattern( const Pathname & p )
+{
+ Measure x( p.basename() );
+ PatternFileReader tp;
+ tp.setConsumer( consumePat );
+ tp.parse( p );
+}
-/******************************************************************
+ /******************************************************************
**
** FUNCTION NAME : main
** FUNCTION TYPE : int
//zypp::base::LogControl::instance().logfile( "log.restrict" );
INT << "===[START]==========================================" << endl;
- ResPool pool( getZYpp()->pool() );
+ Pathname dbdir( "store" );
+ Pathname reporoot( "lmd" );
- if ( 1 )
- {
- zypp::base::LogControl::TmpLineWriter shutUp;
- getZYpp()->initTarget( sysRoot );
- USR << "Added target: " << pool << endl;
- }
+ cache::CacheStore store( dbdir );
+ data::RecordId repositoryId = store.lookupOrAppendRepository( Url("dir:///"), "/" );
+ {
+ Measure x( "XXXXXXXXXXXXX" );
- if ( 1 ) {
- zypp::base::LogControl::TmpLineWriter shutUp;
- SourceManager::sourceManager()->restore( sysRoot );
- if ( SourceManager::sourceManager()->allSources().empty() )
- {
- Source_Ref src1( createSource( "dir:///Local/SUSE-Linux-10.1-Build_830-i386/CD1" ) );
- Source_Ref src2( createSource( "dir:///Local/SUSE-Linux-10.1-Build_830-Addon-BiArch/CD1" ) );
- SourceManager::sourceManager()->addSource( src1 );
- SourceManager::sourceManager()->addSource( src2 );
- SourceManager::sourceManager()->store( sysRoot, true );
- }
- for_each( SourceManager::sourceManager()->Source_begin(), SourceManager::sourceManager()->Source_end(),
- AddResolvables() );
- dumpRange( USR << "Sources: ",
- SourceManager::sourceManager()->Source_begin(), SourceManager::sourceManager()->Source_end()
- ) << endl;
- }
+ parser::susetags::RepoParser repo( repositoryId, store );
+ repo.parse( reporoot );
- MIL << *SourceManager::sourceManager() << endl;
- MIL << pool << endl;
- //dumpRange( USR << "Pool: " << pool,
- // pool.begin(), pool.end()
- // ) << endl;
+ store.commit();
+ }
- if ( 0 )
- {
- selectForTransact( nameKindProxy<Pattern>( pool, "default" ) );
- selectForTransact( nameKindProxy<Pattern>( pool, "x11" ) );
- selectForTransact( nameKindProxy<Pattern>( pool, "kde" ) );
- selectForTransact( nameKindProxy<Pattern>( pool, "OOo" ) );
- }
- else
- {
- selectForTransact( nameKindProxy<Selection>( pool, "default" ) );
- selectForTransact( nameKindProxy<Selection>( pool, "X11" ) );
- selectForTransact( nameKindProxy<Selection>( pool, "Kde" ) );
- selectForTransact( nameKindProxy<Selection>( pool, "Office" ) );
- }
- //getZYpp()->commit( ZYppCommitPolicy() ),
+#if 0
+ ContentFileReader tp;
+ tp.setProductConsumer( consumeProd );
+ tp.setRepoIndexConsumer( consumeIndex );
+ //tp.setSrcPkgConsumer( consumeSrcPkg );
+ tp.parse( p );
- vdumpPoolStats( USR << "Transacting:"<< endl,
- make_filter_begin<resfilter::ByTransact>(pool),
- make_filter_end<resfilter::ByTransact>(pool) ) << endl;
- bool eres, rres;
+ //try
{
- zypp::base::LogControl::TmpLineWriter shutUp;
- zypp::base::LogControl::instance().logfile( "SOLVER" );
- eres = getZYpp()->resolver()->establishPool();
- rres = getZYpp()->resolver()->resolvePool();
- }
- MIL << "est " << eres << " slv " << rres << endl;
+ //Pathname dbdir( "/Local/ma/zypp-TRUNK/BUILD/libzypp/devel/devel.ma/store" );
+
- dumpPoolStats( USR << "Transacting:"<< endl,
- make_filter_begin<resfilter::ByTransact>(pool),
- make_filter_end<resfilter::ByTransact>(pool) ) << endl;
+ Pathname dbdir( "store" );
+ Pathname metadir( "lmd" );
+ cache::CacheStore store( dbdir );
+ data::RecordId repositoryId = store.lookupOrAppendRepository( Url("http://www.google.com"), "/" );
- pool::GetResolvablesToInsDel collect( pool );
- MIL << "GetResolvablesToInsDel:" << endl << collect << endl;
+ RepoParser( metadir, repositoryId, store );
+ }
- if ( 1 )
+ try
{
- // Collect until the 1st package from an unwanted media occurs.
- // Further collection could violate install order.
- bool hitUnwantedMedia = false;
- PoolItemList::iterator fst=collect._toInstall.end();
- for ( PoolItemList::iterator it = collect._toInstall.begin(); it != collect._toInstall.end(); ++it)
- {
- ResObject::constPtr res( it->resolvable() );
-
- if ( hitUnwantedMedia
- || ( res->sourceMediaNr() && res->sourceMediaNr() != 1 ) )
- {
- if ( !hitUnwantedMedia )
- fst=it;
- hitUnwantedMedia = true;
- }
- else
- {
- }
- }
- dumpRange( WAR << "toInstall1: " << endl,
- collect._toInstall.begin(), fst ) << endl;
- dumpRange( WAR << "toInstall2: " << endl,
- fst, collect._toInstall.end() ) << endl;
- dumpRange( ERR << "toDelete: " << endl,
- collect._toDelete.begin(), collect._toDelete.end() ) << endl;
+ ZYpp::Ptr z = getZYpp();
+
+ Pathname dbfile( "data.db" );
+ cache::CacheStore store(getenv("PWD"));
+
+ data::RecordId repository_id = store.lookupOrAppendRepository( Url("http://www.google.com"), "/");
+
+ PackagesParser parser( repository_id, store);
+ Measure m;
+ parser.start(argv[1], &progress_function);
+ m.elapsed();
}
- else
+ catch ( const Exception &e )
{
- dumpRange( WAR << "toInstall: " << endl,
- collect._toInstall.begin(), collect._toInstall.end() ) << endl;
- dumpRange( ERR << "toDelete: " << endl,
- collect._toDelete.begin(), collect._toDelete.end() ) << endl;
+ cout << "ups! " << e.msg() << std::endl;
}
+#endif
+
+ INT << "===[END]============================================" << endl << endl;
+ zypp::base::LogControl::instance().logNothing();
+ return 0;
+
+ Pathname proot( "lmd/suse/setup/descr" );
+ pPackages( proot/"packages" );
+ //pPackages( proot/"packages.gz" );
+ pPackagesLang( proot/"packages.de", Locale("de") );
+ //pPackagesLang( proot/"packages.de.gz", Locale("de") );
+ pPattern( proot/"base-10.3-30.x86_64.pat" );
+
+ if ( 0 )
+ {
+ Measure x( "lmd.idx" );
+ std::ifstream fIndex( "lmd.idx" );
+ for( iostr::EachLine in( fIndex ); in; in.next() )
+ {
+ Measure x( *in );
+ std::ifstream fIn( (*in).c_str() );
+ for( iostr::EachLine l( fIn ); l; l.next() )
+ {
+ ;
+ }
+ }
+ }
INT << "===[END]============================================" << endl << endl;
zypp::base::LogControl::instance().logNothing();
return 0;