#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/sat/IdStrType.h"
+
+#include <zypp/base/GzStream.h>
#include <boost/mpl/int.hpp>
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;
}
}
namespace zypp
{
- namespace sat
- {
-
-
- } // namespace sat
-
- namespace par
- {
- class Foo : public sat::IdStrType<Foo>
- {
- public:
- Foo() {}
- explicit Foo( sat::detail::IdType id_r ) : _str( str::toLower(sat::IdStr(id_r).c_str()) ) {}
- explicit Foo( const sat::IdStr & idstr_r ) : _str( str::toLower(idstr_r.c_str()) ) {}
- explicit Foo( const char * cstr_r ) : _str( str::toLower(cstr_r) ) {}
- explicit Foo( const std::string & str_r ) : _str( str::toLower(str_r) ) {}
- private:
- int _doDompareC( const char * rhs ) const
- { return str::compareCI( _str.c_str(), rhs ); }
- private:
- friend class sat::IdStrType<Foo>;
- sat::IdStr _str;
- };
-
- } // namespace par
}
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 )
{
#undef OUTS
}
-/******************************************************************
-**
-** FUNCTION NAME : main
-** FUNCTION TYPE : int
-*/
-int main( int argc, char * argv[] )
-{
- //zypp::base::LogControl::instance().logfile( "log.restrict" );
- INT << "===[START]==========================================" << endl;
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace sat
+{ /////////////////////////////////////////////////////////////////
- sat::Pool satpool( sat::Pool::instance() );
+ class ByLocaleSupport
+ {
+ private:
+ typedef bool (sat::Solvable::*LS1) (const Locale &) const;
+ typedef bool (sat::Solvable::*LS2) (const LocaleSet &) const;
-#if 0
- sat::Repo s( satpool.addRepoSolv( "10.3.solv" ) );
- //sat::Repo s( satpool.addRepoSolv( "target.solv" ) );
+ public:
+ /** Solvables with locale support. */
+ ByLocaleSupport()
+ : _sel( mem_fun_ref( &sat::Solvable::supportsLocales ) )
+ {}
- sat::Capabilities r( (*satpool.solvablesBegin())[Dep::PROVIDES] );
- MIL << r << endl;
- sat::Capabilities::const_iterator it = r.begin();
- DBG << *it << endl;
- it = ++r.begin();
- DBG << *it << endl;
+ /** Solvables supporting \c locale_r. */
+ ByLocaleSupport( const Locale & locale_r )
+ : _sel( bind( mem_fun_ref( (LS1)&sat::Solvable::supportsLocale ), _1, locale_r ) )
+ {}
- if ( 1 )
- {
- std::for_each( make_filter_iterator( filter::byValue( &sat::Solvable::name, "bash" ),
- satpool.solvablesBegin(), satpool.solvablesEnd() ),
- make_filter_iterator( filter::byValue( &sat::Solvable::name, "bash" ),
- satpool.solvablesEnd(), satpool.solvablesEnd() ),
- Xprint() );
- std::for_each( make_filter_iterator( filter::byValue( &sat::Solvable::name, "pattern:yast2_install_wf" ),
- satpool.solvablesBegin(), satpool.solvablesEnd() ),
- make_filter_iterator( filter::byValue( &sat::Solvable::name, "pattern:yast2_install_wf" ),
- satpool.solvablesEnd(), satpool.solvablesEnd() ),
- Xprint() );
- }
+ /** 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 ); }
- // make_filter_iterator(detail::ByRepo( *this ),
- // Repo.cc- detail::SolvableIterator(_repo->end),
- // Repo.cc- detail::SolvableIterator(_repo->end) );
+ template<class _Solv>
+ bool operator()( const _Solv & solv_r ) const
+ { return operator()( solv_r.satSolvable() ); }
+ private:
+ function<bool(const sat::Solvable &)> _sel;
+ };
-// DBG << satpool.solvablesBegin()->name() << endl;
-// DBG << (*satpool.solvablesBegin())[Dep::PROVIDES] << endl;
- //std::for_each( satpool.solvablesBegin(), satpool.solvablesEnd(), Xprint() );
+ /////////////////////////////////////////////////////////////////
+} // namespace sat
+///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- INT << "===[END]============================================" << endl << endl;
- zypp::base::LogControl::instance().logNothing();
- return 0;
-#endif
- setenv( "ZYPP_CONF", (sysRoot/"zypp.conf").c_str(), 1 );
+/******************************************************************
+**
+** FUNCTION NAME : main
+** FUNCTION TYPE : int
+*/
+int main( int argc, char * argv[] )
+try {
+ //zypp::base::LogControl::instance().logfile( "log.restrict" );
+ INT << "===[START]==========================================" << endl;
- ResPool pool( getZYpp()->pool() );
+ sat::Pool satpool( sat::Pool::instance() );
+ 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 ( 0 )
{
- 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() );
- MIL << satpool << endl;
- for_( it, satpool.solvablesBegin(), satpool.solvablesEnd() )
+
+
+ //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 )
{
- MIL << *it << endl;
- //MIL << dump(*it) << endl;
+ 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 (...)
+{}