#include <zypp/base/Exception.h>
#include <zypp/base/Gettext.h>
#include <zypp/base/LogTools.h>
+#include <zypp/base/Debug.h>
+#include <zypp/base/Functional.h>
#include <zypp/base/ProvideNumericId.h>
#include <zypp/AutoDispose.h>
-#include "zypp/ZYppFactory.h"
#include "zypp/ResPoolProxy.h"
-#include <zypp/CapMatchHelper.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/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"
#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 <zypp/base/GzStream.h>
+
#include <boost/mpl/int.hpp>
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" );
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
{
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;
}
};
///////////////////////////////////////////////////////////////////
-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 )
{
for ( int i = -3; i < 30; ++i )
{
- DBG << i << '\t' << sat::IdStr( i ) << endl;
+ DBG << i << '\t' << IdString( i ) << endl;
}
}
DBG << lhs << " <=> " << rhs << " --> " << ::strcmp( lhs, rhs ) << endl;
}
+namespace filter
+{
+ template <class _MemFun, class _Value>
+ class HasValue
+ {
+ public:
+ HasValue( _MemFun fun_r, _Value val_r )
+ : _fun( fun_r ), _val( val_r )
+ {}
+ template <class _Tp>
+ bool operator()( const _Tp & obj_r ) const
+ { return( _fun && (obj_r.*_fun)() == _val ); }
+ private:
+ _MemFun _fun;
+ _Value _val;
+ };
+
+ template <class _MemFun, class _Value>
+ HasValue<_MemFun, _Value> byValue( _MemFun fun_r, _Value val_r )
+ { return HasValue<_MemFun, _Value>( fun_r, val_r ); }
+}
+
+namespace zypp
+{
+}
+
+template <class L>
+struct _TestO { _TestO( const L & lhs ) : _lhs( lhs ) {} const L & _lhs; };
+
+template <class L>
+std::ostream & operator<<( std::ostream & str, const _TestO<L> & obj )
+{ const L & lhs( obj._lhs); return str << (lhs?'_':'*') << (lhs.empty()?'e':'_') << "'" << lhs << "'"; }
+
+template <class L>
+_TestO<L> testO( const L & lhs )
+{ return _TestO<L>( lhs ); }
+
+template <class L, class R>
+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<class _Solv>
+ bool operator()( const _Solv & solv_r ) const
+ { return operator()( solv_r.satSolvable() ); }
+
+ private:
+ function<bool(const sat::Solvable &)> _sel;
+ };
+
+
+ /////////////////////////////////////////////////////////////////
+} // namespace sat
+///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+
/******************************************************************
**
** 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 )
if ( ! nrepo.enabled() )
continue;
- if ( ! repoManager.isCached( nrepo ) || 0 )
+ if ( ! repoManager.isCached( nrepo ) || /*force*/false )
{
if ( repoManager.isCached( nrepo ) )
{
}
// create from cache:
- std::list<Repository> repositories;
-
{
Measure x( "CREATE FROM CACHE" );
for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it )
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<Package>("amarok") );
+ MIL << pi << endl;
+ if ( pi )
+ {
+ pi.status().setTransact( true, ResStatus::USER );
+ solve();
+ vdumpPoolStats( USR << "Transacting:"<< endl,
+ make_filter_begin<resfilter::ByTransact>(pool),
+ make_filter_end<resfilter::ByTransact>(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 (...)
+{}