14 #include <zypp/base/Easy.h>
15 #include <zypp/base/Counter.h>
16 #include <zypp/base/Measure.h>
18 #include <zypp/PathInfo.h>
19 #include <zypp/Date.h>
20 #include <zypp/ResObject.h>
21 #include <zypp/pool/PoolStats.h>
23 #include "zypp/ZYppFactory.h"
24 #include "zypp/ResPool.h"
25 #include "zypp/ResPoolProxy.h"
26 #include "zypp/ui/Selectable.h"
27 #include <zypp/Repository.h>
28 #include <zypp/RepoManager.h>
31 using zypp::debug::Measure;
34 ///////////////////////////////////////////////////////////////////
36 #define for_providers_(IT,CAP) for ( sat::WhatProvides::const_iterator IT = sat::WhatProvides( Capability CAP ).begin(), _for_end = sat::WhatProvides().end(); IT != _for_end; ++IT )
38 ///////////////////////////////////////////////////////////////////
43 USR << "WAITING FOR INPUT!" << endl;
47 ///////////////////////////////////////////////////////////////////
49 void mksrc( const std::string & url, const std::string & alias, RepoManager & repoManager )
52 nrepo.setAlias( alias );
53 nrepo.setName( alias );
54 nrepo.setEnabled( true );
55 nrepo.setAutorefresh( false );
56 nrepo.addBaseUrl( Url(url) );
58 if ( ! repoManager.isCached( nrepo ) )
60 repoManager.buildCache( nrepo );
63 repoManager.loadFromCache( nrepo );
66 ///////////////////////////////////////////////////////////////////
68 template<class _Condition>
71 SetTrue( _Condition cond_r )
76 bool operator()( _Tp t ) const
85 template<class _Condition>
86 inline SetTrue<_Condition> setTrue_c( _Condition cond_r )
88 return SetTrue<_Condition>( cond_r );
93 void operator()( const PoolItem & pi ) const
94 { USR << pi << endl; }
97 template <class _Iterator>
98 std::ostream & vdumpPoolStats( std::ostream & str,
99 _Iterator begin_r, _Iterator end_r )
101 pool::PoolStats stats;
102 std::for_each( begin_r, end_r,
104 functor::chain( setTrue_c(PrintPoolItem()),
105 setTrue_c(functor::functorRef<void,ResObject::constPtr>(stats)) )
111 ///////////////////////////////////////////////////////////////////
114 typedef zypp::pool::PoolStats Rstats;
116 template<class _Iterator>
117 void rstats( _Iterator begin, _Iterator end )
119 DBG << __PRETTY_FUNCTION__ << endl;
121 for_each( begin, end, functor::functorRef<void,ResObject::constPtr>(stats) );
122 MIL << stats << endl;
125 template<class _Container>
126 void rstats( const _Container & c )
128 rstats( c.begin(), c.end() );
131 ///////////////////////////////////////////////////////////////////
133 inline RepoManager makeRepoManager( const Pathname & mgrdir_r )
136 return RepoManager();
139 ///////////////////////////////////////////////////////////////////
142 ui::Selectable::Ptr getSel( const std::string & name_r )
144 ResPoolProxy uipool( getZYpp()->poolProxy() );
145 for_(it, uipool.byKindBegin<_Res>(), uipool.byKindEnd<_Res>() )
147 if ( (*it)->name() == name_r )
154 PoolItem getPi( const std::string & name_r, const Edition & ed_r, const Arch & arch_r )
157 ResPool pool( getZYpp()->pool() );
158 for_(it, pool.byNameBegin(name_r), pool.byNameEnd(name_r) )
160 if ( !ret && isKind<_Res>( (*it).resolvable() )
161 && ( ed_r == Edition() || ed_r == (*it)->edition() )
162 && ( arch_r == Arch() || arch_r == (*it)->arch() ) )
165 MIL << " ->" << *it << endl;
169 DBG << " ?" << *it << endl;
175 PoolItem getPi( const std::string & name_r )
177 return getPi<_Res>( name_r, Edition(), Arch() );
180 PoolItem getPi( const std::string & name_r, const Edition & ed_r )
182 return getPi<_Res>( name_r, ed_r, Arch() );
185 PoolItem getPi( const std::string & name_r, const Arch & arch_r )
187 return getPi<_Res>( name_r, Edition(), arch_r );
190 ///////////////////////////////////////////////////////////////////