From fe0b8f1556e1afeaa8aa7c21bb3bb1afb62d1424 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Fri, 21 Apr 2006 14:37:14 +0000 Subject: [PATCH] - Removed deprecated oldstyle commit methods. --- devel/devel.ma/Parse.cc | 223 +++++++--------------------------------------- devel/devel.ma/Printing.h | 40 --------- devel/devel.ma/Test.cc | 176 ++++++++++++------------------------ devel/devel.ma/ma_test | 1 + package/libzypp.changes | 5 ++ zypp/Target.cc | 4 - zypp/Target.h | 15 ---- zypp/ZYpp.h | 10 --- 8 files changed, 96 insertions(+), 378 deletions(-) diff --git a/devel/devel.ma/Parse.cc b/devel/devel.ma/Parse.cc index 28f8029..af713d7 100644 --- a/devel/devel.ma/Parse.cc +++ b/devel/devel.ma/Parse.cc @@ -1,28 +1,16 @@ #include - #include -#include -#include -#include - -#include "Measure.h" -#include "Printing.h" #include "Tools.h" -#include -#include - -#include -#include -#include -#include #include -#include -#include -#include -#include +#include #include +#include "zypp/ZYppFactory.h" +#include "zypp/ResPoolProxy.h" +#include +#include + #include "zypp/NVRAD.h" #include "zypp/ResPool.h" #include "zypp/ResFilters.h" @@ -31,14 +19,6 @@ #include "zypp/Language.h" #include "zypp/NameKindProxy.h" -#include -#include -#include - -#include "zypp/ZYppFactory.h" -#include "zypp/ResPoolProxy.h" -#include "zypp/ResPoolProxy.h" -#include "zypp/target/rpm/RpmDb.h" using namespace std; using namespace zypp; @@ -48,8 +28,6 @@ using namespace zypp::functor; /////////////////////////////////////////////////////////////////// static const Pathname sysRoot( "/Local/ROOT" ); -static const Url instSrc( "dir:/Local/SLES10" ); -//static const Url instSrc( "dir:/Local/FACTORY" ); /////////////////////////////////////////////////////////////////// @@ -270,81 +248,13 @@ struct StatusReset : public SetTransactValue }; -inline bool keyDef( bool def ) -{ return def; } - -struct DigestReceive : public zypp::callback::ReceiveReport +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 -{ - 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) ); } - /****************************************************************** ** @@ -355,66 +265,27 @@ int main( int argc, char * argv[] ) { //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(pool), - make_filter_end(pool) ) << endl; - MIL << endl; - std::for_each( pool.begin(), pool.end(), SetTransactValue( ResStatus::TRANSACT, ResStatus::USER ) ); - vdumpPoolStats( INT, - make_filter_begin(pool), - make_filter_end(pool) ) << endl; - MIL << endl; - std::for_each( pool.begin(), pool.end(), StatusReset() ); - vdumpPoolStats( INT, + selectForTransact( nameKindProxy( pool, "default" ) ); + selectForTransact( nameKindProxy( pool, "x11" ) ); + selectForTransact( nameKindProxy( pool, "kde" ) ); + selectForTransact( nameKindProxy( pool, "OOo" ) ); + + vdumpPoolStats( INT << "Transacting: ", make_filter_begin(pool), make_filter_end(pool) ) << endl; - MIL << endl; - - return 0; - - NameKindProxy s( nameKindProxy( pool, "default" ) ); - MIL << s << endl; - if ( ! s.availableEmpty() ) - { - PoolItem def( * s.availableBegin() ); - def.status().setTransact( true, ResStatus::USER ); - } bool eres, rres; { @@ -424,52 +295,26 @@ int main( int argc, char * argv[] ) } MIL << "est " << eres << " slv " << rres << endl; - - for_each( pool.byKindBegin(), pool.byKindEnd(), - PoolItemSelect() ); - INT << "FIN: " << pool << endl; - vdumpPoolStats( INT, + vdumpPoolStats( INT << "Transacting: ", make_filter_begin(pool), make_filter_end(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(pool), - make_filter_end(pool), - functor::functorRef(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 srcKeys( src.publicKeys() ); - MIL << src << endl; - DBG << srcKeys << endl; - - target::rpm::RpmDb rpm; - rpm.initDatabase( sysRoot ); - std::set 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; } diff --git a/devel/devel.ma/Printing.h b/devel/devel.ma/Printing.h index 8ae48cb..b5520dc 100644 --- a/devel/devel.ma/Printing.h +++ b/devel/devel.ma/Printing.h @@ -13,46 +13,6 @@ #include /////////////////////////////////////////////////////////////////// -#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 - 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 struct PrintOn : public std::unary_function<_Tp, bool> diff --git a/devel/devel.ma/Test.cc b/devel/devel.ma/Test.cc index 9d51b93..4cf38c5 100644 --- a/devel/devel.ma/Test.cc +++ b/devel/devel.ma/Test.cc @@ -1,23 +1,18 @@ #include - #include -#include -#include -#include - -#include "Measure.h" -#include "Printing.h" +#include #include "Tools.h" -#include -#include +#include #include -#include -#include -#include -#include +#include #include +#include "zypp/ZYppFactory.h" +#include "zypp/ResPoolProxy.h" +#include +#include + #include "zypp/NVRAD.h" #include "zypp/ResPool.h" #include "zypp/ResFilters.h" @@ -26,14 +21,6 @@ #include "zypp/Language.h" #include "zypp/NameKindProxy.h" -#include -#include -#include - -#include "zypp/ZYppFactory.h" -#include "zypp/ResPoolProxy.h" -#include "zypp/ResPoolProxy.h" -#include "zypp/target/rpm/RpmDb.h" using namespace std; using namespace zypp; @@ -43,82 +30,59 @@ using namespace zypp::functor; /////////////////////////////////////////////////////////////////// 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 - bool isIn( const std::set<_Tp> & cont, const typename std::set<_Tp>::value_type & val ) - { return cont.find( val ) != cont.end(); } -} - -/////////////////////////////////////////////////////////////////// - -template - struct SetTrue - { - SetTrue( _Condition cond_r ) - : _cond( cond_r ) - {} - - template - bool operator()( _Tp t ) const - { - _cond( t ); - return true; - } - - _Condition _cond; - }; - -template - 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 - 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(ptr) ); + return pkg ? pkg->mediaId() : 0; } -/////////////////////////////////////////////////////////////////// + + public: + typedef std::map > KindMap; + Counter _total; + KindMap _perKind; +}; + template 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(stats)) ) + DebugStats stats; + std::for_each( begin_r, end_r, + + functor::chain( setTrue_c(PrintPoolItem()), + setTrue_c(functor::functorRef(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 ); +} /****************************************************************** ** @@ -134,57 +98,29 @@ int main( int argc, char * argv[] ) 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 srcKeys( src.publicKeys() ); - MIL << src << endl; - DBG << srcKeys << endl; - - target::rpm::RpmDb rpm; - rpm.initDatabase( sysRoot ); - std::set 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( pool, "default" ) ); + selectForTransact( nameKindProxy( pool, "x11" ) ); + selectForTransact( nameKindProxy( pool, "kde" ) ); + selectForTransact( nameKindProxy( pool, "OOo" ) ); - rpm.closeDatabase(); -#endif + vdumpPoolStats( INT << "Transacting: ", + make_filter_begin(pool), + make_filter_end(pool) ) << endl; INT << "===[END]============================================" << endl << endl; return 0; } - diff --git a/devel/devel.ma/ma_test b/devel/devel.ma/ma_test index 7fb5e36..fa0ede1 100755 --- a/devel/devel.ma/ma_test +++ b/devel/devel.ma/ma_test @@ -32,4 +32,5 @@ fi $MAKE $PRG || exit 1 export ZYPP_LOGFILE=- +export ZYPP_KEYRING_DEFAULT_ACCEPT_ALL=1 ./$PRG "$@" 2> $LPIPE diff --git a/package/libzypp.changes b/package/libzypp.changes index 0134f59..f7cb27a 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +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, diff --git a/zypp/Target.cc b/zypp/Target.cc index d897525..f98cef3 100644 --- a/zypp/Target.cc +++ b/zypp/Target.cc @@ -82,10 +82,6 @@ namespace zypp 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); } diff --git a/zypp/Target.h b/zypp/Target.h index e112e0d..a3fe93d 100644 --- a/zypp/Target.h +++ b/zypp/Target.h @@ -64,21 +64,6 @@ namespace zypp /** 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; diff --git a/zypp/ZYpp.h b/zypp/ZYpp.h index 3a9dbd6..20bb189 100644 --- a/zypp/ZYpp.h +++ b/zypp/ZYpp.h @@ -79,8 +79,6 @@ namespace zypp void setPartitions(const DiskUsageCounter::MountPointSet &mp); - /** NOOP */ - ZYPP_DEPRECATED void reset() {} public: /** * \throws Exception @@ -109,14 +107,6 @@ namespace zypp */ 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; -- 2.7.4