X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=devel%2Fdevel.ma%2FNewPool.cc;h=959959c55ba5331f49380e79151e24ebe62d29ef;hb=5d24d890a4e7c0a6b0273ce13b6ccb7ebf010386;hp=f6fa1c3e947fdcc4bd3988fa13a3e6bd68c825df;hpb=43194f39e30434834247deb236a21051422da792;p=platform%2Fupstream%2Flibzypp.git diff --git a/devel/devel.ma/NewPool.cc b/devel/devel.ma/NewPool.cc index f6fa1c3..959959c 100644 --- a/devel/devel.ma/NewPool.cc +++ b/devel/devel.ma/NewPool.cc @@ -4,35 +4,25 @@ #include #include #include +#include +#include #include #include -#include "zypp/ZYppFactory.h" #include "zypp/ResPoolProxy.h" -#include #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/ResObjects.h" #include "zypp/Digest.h" #include "zypp/PackageKeyword.h" #include "zypp/ManagedFile.h" #include "zypp/NameKindProxy.h" #include "zypp/pool/GetResolvablesToInsDel.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" #include "zypp/RepoManager.h" #include "zypp/RepoInfo.h" @@ -44,19 +34,21 @@ #include "zypp/sat/Pool.h" #include "zypp/sat/Repo.h" #include "zypp/sat/Solvable.h" +#include "zypp/sat/detail/PoolMember.h" #include "zypp/sat/detail/PoolImpl.h" +#include + #include using namespace std; using namespace zypp; using namespace zypp::functor; using namespace zypp::ui; -using zypp::parser::TagParser; /////////////////////////////////////////////////////////////////// -static const Pathname sysRoot( "/Local/ROOT" ); +static const Pathname sysRoot( getenv("SYSROOT") ? getenv("SYSROOT") : "/Local/ROOT" ); /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// @@ -147,15 +139,15 @@ struct Xprint { bool operator()( const PoolItem & obj_r ) { - MIL << obj_r << endl; - DBG << " -> " << obj_r .satSolvable() << endl; + //MIL << obj_r << endl; + //DBG << " -> " << obj_r->satSolvable() << endl; return true; } bool operator()( const sat::Solvable & obj_r ) { - dumpOn( MIL, obj_r ) << endl; + //dumpOn( MIL, obj_r ) << endl; return true; } }; @@ -218,26 +210,11 @@ inline bool g( const NameKindProxy & nkp, Arch arch = Arch() ) /////////////////////////////////////////////////////////////////// -bool solve( bool establish = false ) +bool solve() { - if ( establish ) - { - bool eres = false; - { - zypp::base::LogControl::TmpLineWriter shutUp; - eres = getZYpp()->resolver()->establishPool(); - } - if ( ! eres ) - { - ERR << "establish " << eres << endl; - return false; - } - MIL << "establish " << eres << endl; - } - bool rres = false; { - zypp::base::LogControl::TmpLineWriter shutUp; + //zypp::base::LogControl::TmpLineWriter shutUp; rres = getZYpp()->resolver()->resolvePool(); } if ( ! rres ) @@ -375,7 +352,7 @@ void dumpIdStr() { for ( int i = -3; i < 30; ++i ) { - DBG << i << '\t' << sat::IdStr( i ) << endl; + DBG << i << '\t' << IdString( i ) << endl; } } @@ -384,6 +361,111 @@ void ttt( const char * lhs, const char * rhs ) DBG << lhs << " <=> " << rhs << " --> " << ::strcmp( lhs, rhs ) << endl; } +namespace filter +{ + template + class HasValue + { + public: + HasValue( _MemFun fun_r, _Value val_r ) + : _fun( fun_r ), _val( val_r ) + {} + template + bool operator()( const _Tp & obj_r ) const + { return( _fun && (obj_r.*_fun)() == _val ); } + private: + _MemFun _fun; + _Value _val; + }; + + template + HasValue<_MemFun, _Value> byValue( _MemFun fun_r, _Value val_r ) + { return HasValue<_MemFun, _Value>( fun_r, val_r ); } +} + +namespace zypp +{ +} + +template +struct _TestO { _TestO( const L & lhs ) : _lhs( lhs ) {} const L & _lhs; }; + +template +std::ostream & operator<<( std::ostream & str, const _TestO & obj ) +{ const L & lhs( obj._lhs); return str << (lhs?'_':'*') << (lhs.empty()?'e':'_') << "'" << lhs << "'"; } + +template +_TestO testO( const L & lhs ) +{ return _TestO( lhs ); } + +template +void testCMP( const L & lhs, const R & rhs ) +{ + MIL << "LHS " << testO(lhs) << endl; + MIL << "RHS " << rhs << endl; + +#define OUTS(S) DBG << #S << ": " << (S) << endl + OUTS( lhs.compare(rhs) ); + OUTS( lhs != rhs ); + OUTS( lhs < rhs ); + OUTS( lhs <= rhs ); + OUTS( lhs == rhs ); + OUTS( lhs >= rhs ); + OUTS( lhs > rhs ); +#undef OUTS +} + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////// +namespace sat +{ ///////////////////////////////////////////////////////////////// + + class ByLocaleSupport + { + private: + typedef bool (sat::Solvable::*LS1) (const Locale &) const; + typedef bool (sat::Solvable::*LS2) (const LocaleSet &) const; + + public: + /** Solvables with locale support. */ + ByLocaleSupport() + : _sel( mem_fun_ref( &sat::Solvable::supportsLocales ) ) + {} + + /** Solvables supporting \c locale_r. */ + ByLocaleSupport( const Locale & locale_r ) + : _sel( bind( mem_fun_ref( (LS1)&sat::Solvable::supportsLocale ), _1, locale_r ) ) + {} + + /** Solvables supporting at least one locale in \c locales_r. */ + ByLocaleSupport( const LocaleSet & locales_r ) + : _sel( bind( boost::mem_fun_ref( (LS2)&sat::Solvable::supportsLocale ), _1, locales_r ) ) + {} + + public: + bool operator()( const sat::Solvable & solv_r ) const + { return _sel && _sel( solv_r ); } + + + template + bool operator()( const _Solv & solv_r ) const + { return operator()( solv_r.satSolvable() ); } + + private: + function _sel; + }; + + + ///////////////////////////////////////////////////////////////// +} // namespace sat +/////////////////////////////////////////////////////////////////// + + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// + /****************************************************************** ** @@ -391,34 +473,16 @@ void ttt( const char * lhs, const char * rhs ) ** FUNCTION TYPE : int */ int main( int argc, char * argv[] ) -{ +try { //zypp::base::LogControl::instance().logfile( "log.restrict" ); INT << "===[START]==========================================" << endl; sat::Pool satpool( sat::Pool::instance() ); - -#if 1 - //sat::Repo r( satpool.addRepoSolv( "sl10.1-beta7-packages.solv" ) ); - //sat::Repo s( satpool.addRepoSolv( "sl10.1-beta7-selections.solv" ) ); - sat::Repo s( satpool.addRepoSolv( "target.solv" ) ); - - std::for_each( satpool.solvablesBegin(), satpool.solvablesEnd(), Xprint() ); - - /////////////////////////////////////////////////////////////////// - INT << "===[END]============================================" << endl << endl; - zypp::base::LogControl::instance().logNothing(); - return 0; -#endif - - setenv( "ZYPP_CONF", (sysRoot/"zypp.conf").c_str(), 1 ); - - ResPool pool( getZYpp()->pool() ); + ResPool pool( ResPool::instance() ); USR << "pool: " << pool << endl; - pool.satSync(); RepoManager repoManager( makeRepoManager( sysRoot ) ); RepoInfoList repos = repoManager.knownRepositories(); - // SEC << "/Local/ROOT " << repos << endl; // launch repos for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it ) @@ -429,7 +493,7 @@ int main( int argc, char * argv[] ) if ( ! nrepo.enabled() ) continue; - if ( ! repoManager.isCached( nrepo ) || 0 ) + if ( ! repoManager.isCached( nrepo ) || /*force*/false ) { if ( repoManager.isCached( nrepo ) ) { @@ -444,8 +508,6 @@ int main( int argc, char * argv[] ) } // create from cache: - std::list repositories; - { Measure x( "CREATE FROM CACHE" ); for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it ) @@ -455,51 +517,78 @@ int main( int argc, char * argv[] ) continue; Measure x( "CREATE FROM CACHE "+nrepo.alias() ); - Repository nrep( repoManager.createFromCache( nrepo ) ); - const zypp::ResStore & store( nrep.resolvables() ); - repositories.push_back( nrep ); + repoManager.loadFromCache( nrepo ); + USR << "pool: " << pool << endl; } } - // load pool: + if ( 0 ) { - Measure x( "LOAD POOL" ); - for_( it, repositories.begin(), repositories.end() ) + Measure x( "INIT TARGET" ); { - Measure x( "LOAD POOL "+(*it).info().alias() ); - const zypp::ResStore & store( (*it).resolvables() ); - getZYpp()->addResolvables( store ); + getZYpp()->initializeTarget( sysRoot ); + getZYpp()->target()->load(); } } + USR << "pool: " << pool << endl; + /////////////////////////////////////////////////////////////////// + + satpool.addRequestedLocale( Locale("de") ); + satpool.addRequestedLocale( Locale("cs") ); + + LocaleSet s; + s.insert( Locale("de") ); + +// MIL << satpool.getAvailableLocales() << endl; - if ( 1 ) { - Measure x( "INIT TARGET" ); + Measure x( "de" ); + sat::ByLocaleSupport f( Locale("de") ); + for_( it, satpool.filterBegin(f), satpool.filterEnd(f) ) { - zypp::base::LogControl::TmpLineWriter shutUp; - getZYpp()->initTarget( sysRoot ); - //getZYpp()->initTarget( "/" ); + MIL << *it << endl; } - dumpPoolStats( SEC << "TargetStore: " << endl, - getZYpp()->target()->resolvables().begin(), - getZYpp()->target()->resolvables().end() ) << endl; } - USR << "pool: " << pool << endl; - pool.satSync(); - waitForInput(); - //std::for_each( pool.begin(), pool.end(), Xprint() ); - //sat::detail::PoolImpl satpool; - //sat::Pool satpool; - //MIL << satpool << endl; + + //MIL << sat::WhatProvides( Capability("amarok") ) << endl; + //MIL << sat::WhatProvides( Capability("amarok == 1.4.7-37.4") ) << endl; + + if ( 0 ) + { + Measure x( "Upgrade" ); + UpgradeStatistics u; + getZYpp()->resolver()->doUpgrade( u ); + } + + + if ( 0 ) { + PoolItem pi ( getPi("amarok") ); + MIL << pi << endl; + if ( pi ) + { + pi.status().setTransact( true, ResStatus::USER ); + solve(); + vdumpPoolStats( USR << "Transacting:"<< endl, + make_filter_begin(pool), + make_filter_end(pool) ) << endl; + + } + } + //vdumpPoolStats( USR << "Pool:"<< endl, pool.begin(), pool.end() ) << endl; + //waitForInput(); + + //std::for_each( pool.begin(), pool.end(), Xprint() ); /////////////////////////////////////////////////////////////////// INT << "===[END]============================================" << endl << endl; zypp::base::LogControl::instance().logNothing(); return 0; } +catch (...) +{}