#include <ctime>
-
#include <iostream>
-#include <list>
-#include <map>
-#include <set>
-
-#include "Measure.h"
-#include "Printing.h"
#include "Tools.h"
-#include <zypp/Digest.h>
-#include <zypp/KeyRing.h>
-
-#include <zypp/base/Logger.h>
-#include <zypp/base/LogControl.h>
-#include <zypp/base/String.h>
-#include <zypp/base/Exception.h>
#include <zypp/base/PtrTypes.h>
-#include <zypp/base/Iterator.h>
-#include <zypp/base/Algorithm.h>
-#include <zypp/base/Functional.h>
-#include <zypp/base/ProvideNumericId.h>
+#include <zypp/base/Exception.h>
#include <zypp/base/ProvideNumericId.h>
+#include "zypp/ZYppFactory.h"
+#include "zypp/ResPoolProxy.h"
+#include <zypp/SourceManager.h>
+#include <zypp/SourceFactory.h>
+
#include "zypp/NVRAD.h"
#include "zypp/ResPool.h"
#include "zypp/ResFilters.h"
#include "zypp/Language.h"
#include "zypp/NameKindProxy.h"
-#include <zypp/SourceManager.h>
-#include <zypp/SourceFactory.h>
-#include <zypp/source/susetags/SuseTagsImpl.h>
-
-#include "zypp/ZYppFactory.h"
-#include "zypp/ResPoolProxy.h"
-#include "zypp/ResPoolProxy.h"
-#include "zypp/target/rpm/RpmDb.h"
using namespace std;
using namespace zypp;
///////////////////////////////////////////////////////////////////
static const Pathname sysRoot( "/Local/ROOT" );
-static const Url instSrc( "dir:/Local/SLES10" );
-//static const Url instSrc( "dir:/Local/FACTORY" );
///////////////////////////////////////////////////////////////////
};
-inline bool keyDef( bool def )
-{ return def; }
-
-struct DigestReceive : public zypp::callback::ReceiveReport<zypp::DigestReport>
+inline bool selectForTransact( const NameKindProxy & nkp )
{
- virtual bool askUserToAcceptNoDigest( const zypp::Pathname & file )
- {
- bool def = zypp::DigestReport::askUserToAcceptNoDigest( file );
- SEC << "AcceptNoDigest " << file << " (" << def << ')' << endl;
- return keyDef( def );
- }
-};
-struct KeyRingReceive : public zypp::callback::ReceiveReport<zypp::KeyRingReport>
-{
- virtual bool askUserToTrustKey( const std::string & keyid,
- const std::string & keyname,
- const std::string & keydetails )
- {
- bool def = zypp::KeyRingReport::askUserToTrustKey( keyid, keyname, keydetails );
- SEC << "TrustKey " << keyid << ' ' << keyname << ' ' << keydetails << " (" << def << ')' << endl;
- return keyDef( def );
- }
-
- virtual bool askUserToAcceptUnknownKey( const zypp::Pathname & path,
- const std::string & keyid,
- const std::string & keyname )
- {
- bool def = zypp::KeyRingReport::askUserToAcceptUnknownKey( path, keyid, keyname );
- SEC << "AcceptUnknownKey " << path << ' ' << keyid << ' ' << keyname << " (" << def << ')' << endl;
- return keyDef( def );
- }
-
- virtual bool askUserToAcceptUnsignedFile( const zypp::Pathname & file )
- {
- bool def = zypp::KeyRingReport::askUserToAcceptUnsignedFile( file );
- SEC << "AcceptUnsignedFile " << file << " (" << def << ')' << endl;
- return keyDef( def );
- }
-
- virtual bool askUserToAcceptVerificationFailed( const zypp::Pathname & file,
- const std::string & keyid,
- const std::string & keyname )
- {
- bool def = zypp::KeyRingReport::askUserToAcceptVerificationFailed( file, keyid, keyname );
- SEC << "AcceptVerificationFailed " << file << ' ' << keyid << ' ' << keyname << " (" << def << ')' << endl;
- return keyDef( def );
- }
-};
-
-struct KeyRingCallbacks
-{
- KeyRingCallbacks()
- {
- _digestReceive.connect();
- _keyRingReceive.connect();
- }
- ~KeyRingCallbacks()
- {
- _digestReceive.disconnect();
- _keyRingReceive.disconnect();
- }
-
- DigestReceive _digestReceive;
- KeyRingReceive _keyRingReceive;
+ if ( nkp.availableEmpty() )
+ return false;
-};
-static KeyRingCallbacks cbs;
-
-void checkSource( const Url & url )
-{
- Source_Ref src( createSource( url ) );
+ return nkp.availableBegin()->status().setTransact( true, ResStatus::USER );
}
-void checkSource( const std::string & urlstr )
-{ checkSource( Url(urlstr) ); }
-
/******************************************************************
**
{
//zypp::base::LogControl::instance().logfile( "xxx" );
INT << "===[START]==========================================" << endl;
- ResPool pool( getZYpp()->pool() );
-
- checkSource( "ftp://ftp.gwdg.de/pub/linux/misc/suser-guru/rpm/10.0" );
- return 0;
-
- if ( 0 )
- {
- Measure x( "initTarget " + sysRoot.asString() );
- getZYpp()->initTarget( sysRoot );
- getZYpp()->addResolvables( getZYpp()->target()->resolvables(), true );
- INT << "Added target: " << pool << endl;
- }
- if ( 0 ) {
- SourceManager::sourceManager()->restore( sysRoot );
- if ( SourceManager::sourceManager()->allSources().empty() )
- {
- Source_Ref src( createSource( instSrc ) );
- SourceManager::sourceManager()->addSource( src );
- SourceManager::sourceManager()->store( sysRoot, true );
- }
-
- Source_Ref src( *SourceManager::sourceManager()->Source_begin() );
- getZYpp()->addResolvables( src.resolvables() );
- INT << "Added source: " << pool << endl;
- }
+ ResPool pool( getZYpp()->pool() );
+ getZYpp()->initTarget( sysRoot );
+ getZYpp()->addResolvables( getZYpp()->target()->resolvables(), true );
+ INT << "Added target: " << pool << endl;
- Source_Ref src2( createSource( "dir:/Local/SUSE-Linux-10.1-Build_830-i386/CD1" ) );
- Source_Ref src1( createSource( "dir:/Local/SUSE-Linux-10.1-Build_830-Addon-BiArch/CD1" ) );
- INT << "Pool: " << pool << endl;
+ Source_Ref src1( createSource( "dir:/mounts/machcd2/CDs/SLES-10-CD-i386-Beta10/CD1" ) );
+ Source_Ref src2( createSource( "dir:/mounts/machcd2/kukuk/sles10-sp-i386/CD1" ) );
getZYpp()->addResolvables( src1.resolvables() );
- INT << "Added source1: " << pool << endl;
getZYpp()->addResolvables( src2.resolvables() );
- INT << "Added source2: " << pool << endl;
+ INT << "Pool: " << pool << endl;
- vdumpPoolStats( INT,
- make_filter_begin<resfilter::ByTransact>(pool),
- make_filter_end<resfilter::ByTransact>(pool) ) << endl;
- MIL << endl;
- std::for_each( pool.begin(), pool.end(), SetTransactValue( ResStatus::TRANSACT, ResStatus::USER ) );
- vdumpPoolStats( INT,
- make_filter_begin<resfilter::ByTransact>(pool),
- make_filter_end<resfilter::ByTransact>(pool) ) << endl;
- MIL << endl;
- std::for_each( pool.begin(), pool.end(), StatusReset() );
- vdumpPoolStats( INT,
+ selectForTransact( nameKindProxy<Pattern>( pool, "default" ) );
+ selectForTransact( nameKindProxy<Pattern>( pool, "x11" ) );
+ selectForTransact( nameKindProxy<Pattern>( pool, "kde" ) );
+ selectForTransact( nameKindProxy<Pattern>( pool, "OOo" ) );
+
+ vdumpPoolStats( INT << "Transacting: ",
make_filter_begin<resfilter::ByTransact>(pool),
make_filter_end<resfilter::ByTransact>(pool) ) << endl;
- MIL << endl;
-
- return 0;
-
- NameKindProxy s( nameKindProxy<Selection>( pool, "default" ) );
- MIL << s << endl;
- if ( ! s.availableEmpty() )
- {
- PoolItem def( * s.availableBegin() );
- def.status().setTransact( true, ResStatus::USER );
- }
bool eres, rres;
{
}
MIL << "est " << eres << " slv " << rres << endl;
-
- for_each( pool.byKindBegin<Package>(), pool.byKindEnd<Package>(),
- PoolItemSelect() );
- INT << "FIN: " << pool << endl;
- vdumpPoolStats( INT,
+ vdumpPoolStats( INT << "Transacting: ",
make_filter_begin<resfilter::ByTransact>(pool),
make_filter_end<resfilter::ByTransact>(pool) ) << endl;
- if ( 1 )
- {
- PoolItemList errors_r;
- PoolItemList remaining_r;
- PoolItemList srcremaining_r;
- commit( pool, 0, errors_r, remaining_r, srcremaining_r, false );
- dumpPoolStats( WAR << "remaining_r ", remaining_r.begin(), remaining_r.end() ) << endl;
- dumpPoolStats( WAR << "srcremaining_r ", srcremaining_r.begin(), srcremaining_r.end() ) << endl;
+ ZYppCommitPolicy policy;
+ policy.rpmNoSignature();
+ if ( 0 )
+ {
+ ZYppCommitResult res( getZYpp()->commit( policy ) );
}
else
{
- CollectTransacting toTransact;
- std::for_each( make_filter_begin<resfilter::ByTransact>(pool),
- make_filter_end<resfilter::ByTransact>(pool),
- functor::functorRef<void,PoolItem>(toTransact) );
- MIL << toTransact;
+ for ( unsigned mnr = 1; mnr < 6; ++mnr )
+ {
+ policy.restrictToMedia( mnr );
+ ZYppCommitResult res( getZYpp()->commit( policy ) );
+ }
}
-#if 0
- Source_Ref src( *SourceManager::sourceManager()->Source_begin() );
- const std::list<Pathname> srcKeys( src.publicKeys() );
- MIL << src << endl;
- DBG << srcKeys << endl;
-
- target::rpm::RpmDb rpm;
- rpm.initDatabase( sysRoot );
- std::set<Edition> rpmKeys( rpm.pubkeys() );
- MIL << rpm << endl;
- DBG << rpmKeys << endl;
-
- ResPool pool( getZYpp()->pool() );
- getZYpp()->addResolvables( src.resolvables() );
- SEC << pool << endl;
-
- rpm.closeDatabase();
-#endif
-
INT << "===[END]============================================" << endl << endl;
return 0;
}
#include <zypp/base/Functional.h>
///////////////////////////////////////////////////////////////////
-#if 0
-///////////////////////////////////////////////////////////////////
-struct FormatStream
-{
- explicit
- FormatStream( std::ostream & stream_r )
- : _stream( stream_r )
- {}
-
- FormatStream & operator<<( std::ostream & (*fnc)( std::ostream & ) )
- { _stream << fnc; return *this; }
-
- template<class _Tp>
- FormatStream & operator<<( const _Tp & obj )
- { _stream << "@(" << obj << ")@"; return *this; }
-
- std::ostream & _stream;
-};
-///////////////////////////////////////////////////////////////////
-#undef XXX
-#undef DBG
-#undef MIL
-#undef WAR
-#undef ERR
-#undef SEC
-#undef INT
-#undef USR
-
-#define XXX FormatStream(_XXX( ZYPP_BASE_LOGGER_LOGGROUP ))
-#define DBG FormatStream(_DBG( ZYPP_BASE_LOGGER_LOGGROUP ))
-#define MIL FormatStream(_MIL( ZYPP_BASE_LOGGER_LOGGROUP ))
-#define WAR FormatStream(_WAR( ZYPP_BASE_LOGGER_LOGGROUP ))
-#define ERR FormatStream(_ERR( ZYPP_BASE_LOGGER_LOGGROUP ))
-#define SEC FormatStream(_SEC( ZYPP_BASE_LOGGER_LOGGROUP ))
-#define INT FormatStream(_INT( ZYPP_BASE_LOGGER_LOGGROUP ))
-#define USR FormatStream(_USR( ZYPP_BASE_LOGGER_LOGGROUP ))
-///////////////////////////////////////////////////////////////////
-#endif
-///////////////////////////////////////////////////////////////////
-
template<class _Tp>
struct PrintOn : public std::unary_function<_Tp, bool>
#include <ctime>
-
#include <iostream>
-#include <list>
-#include <map>
-#include <set>
-
-#include "Measure.h"
-#include "Printing.h"
+#include <fstream>
#include "Tools.h"
-#include <zypp/base/String.h>
-#include <zypp/base/Exception.h>
+#include <zypp/base/IOStream.h>
#include <zypp/base/PtrTypes.h>
-#include <zypp/base/Iterator.h>
-#include <zypp/base/Algorithm.h>
-#include <zypp/base/Functional.h>
-#include <zypp/base/ProvideNumericId.h>
+#include <zypp/base/Exception.h>
#include <zypp/base/ProvideNumericId.h>
+#include "zypp/ZYppFactory.h"
+#include "zypp/ResPoolProxy.h"
+#include <zypp/SourceManager.h>
+#include <zypp/SourceFactory.h>
+
#include "zypp/NVRAD.h"
#include "zypp/ResPool.h"
#include "zypp/ResFilters.h"
#include "zypp/Language.h"
#include "zypp/NameKindProxy.h"
-#include <zypp/SourceManager.h>
-#include <zypp/SourceFactory.h>
-#include <zypp/source/susetags/SuseTagsImpl.h>
-
-#include "zypp/ZYppFactory.h"
-#include "zypp/ResPoolProxy.h"
-#include "zypp/ResPoolProxy.h"
-#include "zypp/target/rpm/RpmDb.h"
using namespace std;
using namespace zypp;
///////////////////////////////////////////////////////////////////
static const Pathname sysRoot( "/Local/ROOT" );
-static const Url instSrc( "dir:/Local/SLES10" );
-//static const Url instSrc( "dir:/Local/FACTORY" );
///////////////////////////////////////////////////////////////////
-namespace container
+struct DebugStats
{
- 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
- {
- SetTrue( _Condition cond_r )
- : _cond( cond_r )
- {}
-
- template<class _Tp>
- bool operator()( _Tp t ) const
- {
- _cond( t );
- return true;
- }
-
- _Condition _cond;
- };
-
-template<class _Condition>
- inline SetTrue<_Condition> setTrue_c( _Condition cond_r )
+ bool operator()( const ResObject::constPtr & ptr )
{
- return SetTrue<_Condition>( cond_r );
+ Source_Ref::NumericId srcid = ptr->source().numericId();
+ unsigned mediaid = mediaId( ptr )
+ USR << "S" << srcid
+ << "/M" << mediaid
+ << " " << ptr
+ << 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 )
+ unsigned mediaId( const ResObject::constPtr ptr & ptr ) const
{
- for ( _Iterator it = begin_r; it != end_r; ++it )
- {
- if ( filter_r( *it ) )
- {
- fnc_r( *it );
- }
- }
- return fnc_r;
+ Package::constPtr pkg( asKind<Package>(ptr) );
+ return pkg ? pkg->mediaId() : 0;
}
-///////////////////////////////////////////////////////////////////
+
+ public:
+ typedef std::map<ResolvableTraits::KindType,Counter<unsigned> > KindMap;
+ Counter<unsigned> _total;
+ KindMap _perKind;
+};
+
template <class _Iterator>
std::ostream & vdumpPoolStats( std::ostream & str,
_Iterator begin_r, _Iterator end_r )
{
- pool::PoolStats stats;
- // std::for_each( begin_r, end_r,
-//
- // functor::chain( setTrue_c(PrintPoolItem()),
- // setTrue_c(functor::functorRef<void,ResObject::constPtr>(stats)) )
+ DebugStats stats;
+ std::for_each( begin_r, end_r,
+
+ functor::chain( setTrue_c(PrintPoolItem()),
+ setTrue_c(functor::functorRef<void,ResObject::constPtr>(stats)) )
- // );
+ );
return str << stats;
}
-struct PoolItemSelect
+///////////////////////////////////////////////////////////////////
+
+inline bool selectForTransact( const NameKindProxy & nkp )
{
- void operator()( const PoolItem & pi ) const
- {
- if ( pi->source().numericId() == 2 )
- pi.status().setTransact( true, ResStatus::USER );
- }
-};
+ if ( nkp.availableEmpty() )
+ return false;
+
+ return nkp.availableBegin()->status().setTransact( true, ResStatus::USER );
+}
/******************************************************************
**
if ( 0 )
{
- Measure x( "initTarget " + sysRoot.asString() );
getZYpp()->initTarget( sysRoot );
getZYpp()->addResolvables( getZYpp()->target()->resolvables(), true );
INT << "Added target: " << pool << endl;
}
- if ( 0 ) {
- SourceManager::sourceManager()->restore( sysRoot );
- if ( SourceManager::sourceManager()->allSources().empty() )
- {
- Source_Ref src( createSource( instSrc ) );
- SourceManager::sourceManager()->addSource( src );
- SourceManager::sourceManager()->store( sysRoot, true );
- }
-
- Source_Ref src( *SourceManager::sourceManager()->Source_begin() );
- getZYpp()->addResolvables( src.resolvables() );
- INT << "Added source: " << pool << endl;
- }
-
- Source_Ref src1( createSource( "dir:/Local/SUSE-Linux-10.1-Build_830-Addon-BiArch/CD1" ) );
- Source_Ref src2( createSource( "dir:/Local/SUSE-Linux-10.1-Build_830-i386/CD1" ) );
- INT << "Pool: " << pool << endl;
- getZYpp()->addResolvables( src1.resolvables() );
- INT << "Added source1: " << pool << endl;
- getZYpp()->addResolvables( src2.resolvables() );
- INT << "Added source2: " << pool << endl;
-
-
-
-
-#if 0
- Source_Ref src( *SourceManager::sourceManager()->Source_begin() );
- const std::list<Pathname> srcKeys( src.publicKeys() );
- MIL << src << endl;
- DBG << srcKeys << endl;
-
- target::rpm::RpmDb rpm;
- rpm.initDatabase( sysRoot );
- std::set<Edition> rpmKeys( rpm.pubkeys() );
- MIL << rpm << endl;
- DBG << rpmKeys << endl;
+ if ( 0 )
+ {
+ Source_Ref src1( createSource( "dir:/mounts/machcd2/CDs/SLES-10-CD-i386-Beta10/CD1" ) );
+ Source_Ref src2( createSource( "dir:/mounts/machcd2/kukuk/sles10-sp-i386/CD1" ) );
+ getZYpp()->addResolvables( src1.resolvables() );
+ getZYpp()->addResolvables( src2.resolvables() );
+ INT << "Pool: " << pool << endl;
+ }
- ResPool pool( getZYpp()->pool() );
- getZYpp()->addResolvables( src.resolvables() );
- SEC << pool << endl;
+ selectForTransact( nameKindProxy<Pattern>( pool, "default" ) );
+ selectForTransact( nameKindProxy<Pattern>( pool, "x11" ) );
+ selectForTransact( nameKindProxy<Pattern>( pool, "kde" ) );
+ selectForTransact( nameKindProxy<Pattern>( pool, "OOo" ) );
- rpm.closeDatabase();
-#endif
+ vdumpPoolStats( INT << "Transacting: ",
+ make_filter_begin<resfilter::ByTransact>(pool),
+ make_filter_end<resfilter::ByTransact>(pool) ) << endl;
INT << "===[END]============================================" << endl << endl;
return 0;
}
-
$MAKE $PRG || exit 1
export ZYPP_LOGFILE=-
+export ZYPP_KEYRING_DEFAULT_ACCEPT_ALL=1
./$PRG "$@" 2> $LPIPE
-------------------------------------------------------------------
+Fri Apr 21 16:36:14 CEST 2006 - ma@suse.de
+
+- Removed deprecated oldstyle commit methods.
+
+-------------------------------------------------------------------
Fri Apr 21 15:58:14 CEST 2006 - mvidner@suse.cz
- when installing a xml-store resolvable (all except package,
Pathname Target::root() const
{ return _pimpl->root(); }
- int Target::commit(ResPool pool_r, int medianr, PoolItemList & errors_r
- , PoolItemList & remaining_r, PoolItemList & srcremaining_r, bool dry_run )
- { return _pimpl->commit(pool_r, medianr, errors_r, remaining_r, srcremaining_r, dry_run ); }
-
bool Target::providesFile (const std::string & name_str, const std::string & path_str) const
{ return _pimpl->providesFile (name_str, path_str); }
/** Refference to the RPM database */
target::rpm::RpmDb & rpmDb();
- /** Commit changes in the pool
- * \param medianr 0 = all/any media
- * > 0 means only the given media number
- * return number of successfully committed resolvables
- *
- * \todo Interface to commit should be ZYpp::commit( medianr ). This call
- * should be removed from the targets public interface, as soon as ZYpp::Impl
- * is able to call Target::Impl.
- */
- int commit( ResPool pool_r, int medianr,
- PoolItemList & errors_r,
- PoolItemList & remaining_r,
- PoolItemList & srcremaining_r,
- bool dry_run = false ) ZYPP_DEPRECATED;
-
/** If the package is installed and provides the file
Needed to evaluate split provides during Resolver::Upgrade() */
bool providesFile (const std::string & name_str, const std::string & path_str) const;
void setPartitions(const DiskUsageCounter::MountPointSet &mp);
- /** NOOP */
- ZYPP_DEPRECATED void reset() {}
public:
/**
* \throws Exception
*/
ZYppCommitResult commit( const ZYppCommitPolicy & policy_r );
- ZYPP_DEPRECATED ZYppCommitResult commit( int medianr_r, bool dry_run = false )
- {
- ZYppCommitPolicy policy;
- policy.restrictToMedia( medianr_r ).dryRun( dry_run );
- return commit( policy );
- }
-
-
public:
/** */
Resolver_Ptr resolver() const;