![](https://seccdn.libravatar.org/avatar/1a5a039cbdb74b7bb361ba2e9d30cb91.jpg?s=120&d=mm&r=g)
Author: mlandres Date: Thu Apr 24 18:58:20 2008 New Revision: 9809 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9809&view=rev Log: Enabled Pool to handle automatic soft-locks, except save/restore which is Targets job. Modified: trunk/libzypp/devel/devel.ma/NewPool.cc trunk/libzypp/devel/devel.ma/Tools.h trunk/libzypp/zypp/PoolQuery.cc trunk/libzypp/zypp/ResPool.cc trunk/libzypp/zypp/ResPool.h trunk/libzypp/zypp/ResStatus.h trunk/libzypp/zypp/pool/PoolImpl.h trunk/libzypp/zypp/pool/PoolTraits.h Modified: trunk/libzypp/devel/devel.ma/NewPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=9809&r1=9808&r2=9809&view=diff ============================================================================== --- trunk/libzypp/devel/devel.ma/NewPool.cc (original) +++ trunk/libzypp/devel/devel.ma/NewPool.cc Thu Apr 24 18:58:20 2008 @@ -495,35 +495,20 @@ } } -bool myfilter( const PoolItem & pi ) +void sslk( const std::string & t = std::string() ) { - if ( pi->name() == "ruby" ) - return true; - return false; -} - -struct Foo : private debug::TraceCAD<Foo> -{}; - -namespace zypp -{ - namespace sat + ResPool pool( ResPool::instance() ); + ostream & outs( SEC ); + outs << t << ": {" << endl; + for_( it, pool.begin(), pool.end() ) { + if ( it->status().isSoftLocked() ) + outs << " " << *it << endl; } + outs << '}' << endl; } -void ditest( Capability cap_r ) -{ - DBG << " (" << cap_r.id() << ") " << endl; - DBG << " " << cap_r << endl; - DBG << " " << dump(cap_r) << endl; -} -void ditest( const std::string & str_r ) -{ - MIL << str_r << endl; - ditest( Capability(str_r) ); -} /****************************************************************** ** @@ -542,6 +527,14 @@ USR << "pool: " << pool << endl; sat::Pool satpool( sat::Pool::instance() ); + typedef ResPool::AutoSoftLocks AutoSoftLocks; + typedef ResPool::autoSoftLocks_iterator autoSoftLocks_iterator; + + AutoSoftLocks s; + //s.insert( IdString("xorg-x11") ); + pool.setAutoSoftLocks( s ); + sslk( "START" ); + if ( 1 ) { RepoManager repoManager( makeRepoManager( sysRoot ) ); @@ -600,11 +593,14 @@ } } - if ( 0 ) + if ( 1 ) { Measure x( "INIT TARGET" ); { - getZYpp()->initializeTarget( sysRoot ); + { + zypp::base::LogControl::TmpLineWriter shutUp; + getZYpp()->initializeTarget( sysRoot ); + } getZYpp()->target()->load(); } } @@ -613,6 +609,7 @@ USR << "pool: " << pool << endl; /////////////////////////////////////////////////////////////////// + if ( 0 ) { Measure x( "Upgrade" ); @@ -622,43 +619,35 @@ /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// - ditest("foo"); - ditest("foo.baa"); - ditest("foo.i386"); - ditest("foo.baa < 13"); - ditest("foo.foo.baa < 13"); - ditest("foo.foo.i386 < 13"); - ditest(""); + sslk( "AFTER LOAD" ); - /////////////////////////////////////////////////////////////////// - INT << "===[END]============================================" << endl << endl; - zypp::base::LogControl::instance().logNothing(); - return 0; + //s.clear(); + s.insert( IdString("pattern:office") ); + pool.setAutoSoftLocks( s ); + sslk( "AFTER RESET" ); - if ( 0 ) { - Measure x( "PROXY" ); - pool.proxy(); - } + AutoSoftLocks n; + pool.getActiveSoftLocks( s ); + INT << s << endl; - if ( 0 ) { - Measure x( "ALL PATTERNS" ); + PoolItem( sat::Solvable(10340) ).status().setTransact( true, ResStatus::USER ); + PoolItem( sat::Solvable(3500) ).status().setTransact( true, ResStatus::USER ); + vdumpPoolStats( USR << "Transacting:"<< endl, + make_filter_begin<resfilter::ByTransact>(pool), + make_filter_end<resfilter::ByTransact>(pool) ) << endl; + pool.getActiveSoftLocks( s ); + INT << s << endl; - for_( it, pool.byKindBegin<Pattern>(), pool.byKindEnd<Pattern>() ) - { - Measure x( string(" ") + (*it)->name() ); - Pattern::Contents c( asKind<Pattern>(*it)->contents() ); - { - Measure x( " poolitem" ); - dumpRange( WAR, c.poolItemBegin(), c.poolItemEnd() ) << endl; - } - { - Measure x( " selectable" ); - dumpRange( ERR, c.selectableBegin(), c.selectableEnd() ) << endl; - } - break; - } - } + + /////////////////////////////////////////////////////////////////// + + //vdumpPoolStats( USR << "Pool:"<< endl, pool.byKindBegin<Package>(), pool.byKindEnd<Package>() ) << endl; + + /////////////////////////////////////////////////////////////////// + INT << "===[END]============================================" << endl << endl; + zypp::base::LogControl::instance().logNothing(); + return 0; SEC << zypp::getZYpp()->diskUsage() << endl; Modified: trunk/libzypp/devel/devel.ma/Tools.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Tools.h?rev=9809&r1=9808&r2=9809&view=diff ============================================================================== --- trunk/libzypp/devel/devel.ma/Tools.h (original) +++ trunk/libzypp/devel/devel.ma/Tools.h Thu Apr 24 18:58:20 2008 @@ -32,6 +32,10 @@ /////////////////////////////////////////////////////////////////// +#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 ) + +/////////////////////////////////////////////////////////////////// + void waitForInput() { int i; Modified: trunk/libzypp/zypp/PoolQuery.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.cc?rev=9809&r1=9808&r2=9809&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolQuery.cc (original) +++ trunk/libzypp/zypp/PoolQuery.cc Thu Apr 24 18:58:20 2008 @@ -570,7 +570,7 @@ bool got_match = false; if (_has_next) { - DBG << "last: " << _sid << endl; + XXX << "last: " << _sid << endl; while (_has_next && !(got_match = matchSolvable())); } @@ -581,7 +581,7 @@ _sid = 0; } - DBG << "next: " << _sid << endl; + XXX << "next: " << _sid << endl; } bool PoolQueryIterator::matchSolvable() Modified: trunk/libzypp/zypp/ResPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResPool.cc?rev=9809&r1=9808&r2=9809&view=diff ============================================================================== --- trunk/libzypp/zypp/ResPool.cc (original) +++ trunk/libzypp/zypp/ResPool.cc Thu Apr 24 18:58:20 2008 @@ -31,7 +31,7 @@ // ResPool ResPool::instance() { - static ResPool _val( pool::PoolTraits::Impl_constPtr( new pool::PoolImpl ) ); + static ResPool _val( pool::PoolTraits::Impl_Ptr( new pool::PoolImpl ) ); return _val; } @@ -40,7 +40,7 @@ // METHOD NAME : ResPool::ResPool // METHOD TYPE : Ctor // - ResPool::ResPool( pool::PoolTraits::Impl_constPtr impl_r ) + ResPool::ResPool( pool::PoolTraits::Impl_Ptr impl_r ) : _pimpl( impl_r ) {} @@ -66,6 +66,7 @@ PoolItem ResPool::find( const sat::Solvable & slv_r ) const { return _pimpl->find( slv_r ); } + ResPool::size_type ResPool::knownRepositoriesSize() const { return _pimpl->knownRepositoriesSize(); } @@ -75,6 +76,25 @@ ResPool::repository_iterator ResPool::knownRepositoriesEnd() const { return _pimpl->knownRepositoriesEnd(); } + + bool ResPool::autoSoftLocksEmpty() const + { return _pimpl->autoSoftLocks().empty(); } + + ResPool::size_type ResPool::autoSoftLocksSize() const + { return _pimpl->autoSoftLocks().size(); } + + ResPool::autoSoftLocks_iterator ResPool::autoSoftLocksBegin() const + { return _pimpl->autoSoftLocks().begin(); } + + ResPool::autoSoftLocks_iterator ResPool::autoSoftLocksEnd() const + { return _pimpl->autoSoftLocks().end(); } + + void ResPool::setAutoSoftLocks( const AutoSoftLocks & newLocks_r ) + { _pimpl->setAutoSoftLocks( newLocks_r ); } + + void ResPool::getActiveSoftLocks( AutoSoftLocks & activeLocks_r ) + { _pimpl->getActiveSoftLocks( activeLocks_r ); } + const pool::PoolTraits::ItemContainerT & ResPool::store() const { return _pimpl->store(); } Modified: trunk/libzypp/zypp/ResPool.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResPool.h?rev=9809&r1=9808&r2=9809&view=diff ============================================================================== --- trunk/libzypp/zypp/ResPool.h (original) +++ trunk/libzypp/zypp/ResPool.h Thu Apr 24 18:58:20 2008 @@ -299,15 +299,49 @@ bool isAvailableLocale( const Locale & locale_r ) const; //@} + public: + /** \name Handle automatic soft-locks. + * + * Solvables with and ident listed here are per default created with + * a setSoftLock applied. I.e. the \ref Resolver should not automatically + * select them, if they are just recommended. + * + * This list is considered when adding new repos to the pool. It is + * \b not the list of currently softLocked items. + * + * Mainly used to re-apply soft-locks remembered during the last commit. + */ + //@{ + typedef pool::PoolTraits::AutoSoftLocks AutoSoftLocks; + typedef pool::PoolTraits::autoSoftLocks_iterator autoSoftLocks_iterator; + + bool autoSoftLocksEmpty() const; + size_type autoSoftLocksSize() const; + autoSoftLocks_iterator autoSoftLocksBegin() const; + autoSoftLocks_iterator autoSoftLocksEnd() const; + + /** Set a new soft-lock list. + * The soft-locks of existing PoolItems are adjusted according + * to the list. (usually called on target load) + */ + void setAutoSoftLocks( const AutoSoftLocks & newLocks_r ); + + /** Suggest a new soft-lock list based on the current selection. + * Based on the the current soft-lock list. Items tagged to be + * installed are removed, and those tagged to be deleted are added. + * (usually remembered on commit). + */ + void getActiveSoftLocks( AutoSoftLocks & activeLocks_r ); + //@} private: const pool::PoolTraits::ItemContainerT & store() const; const pool::PoolTraits::Id2ItemT & id2item() const; private: /** Ctor */ - ResPool( pool::PoolTraits::Impl_constPtr impl_r ); - /** Const access to implementation. */ - pool::PoolTraits::Impl_constPtr _pimpl; + ResPool( pool::PoolTraits::Impl_Ptr impl_r ); + /** Access to implementation. */ + RW_pointer<pool::PoolTraits::Impl> _pimpl; }; /////////////////////////////////////////////////////////////////// Modified: trunk/libzypp/zypp/ResStatus.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResStatus.h?rev=9809&r1=9808&r2=9809&view=diff ============================================================================== --- trunk/libzypp/zypp/ResStatus.h (original) +++ trunk/libzypp/zypp/ResStatus.h Thu Apr 24 18:58:20 2008 @@ -241,6 +241,9 @@ bool isLocked() const { return fieldValueIs<TransactField>( LOCKED ); } + bool isSoftLocked( TransactByValue causer_r = USER ) const + { return isKept() && fieldValueIs<TransactByField>( causer_r ); } + bool isKept() const { return fieldValueIs<TransactField>( KEEP_STATE ); } Modified: trunk/libzypp/zypp/pool/PoolImpl.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/pool/PoolImpl.h?rev=9809&r1=9808&r2=9809&view=diff ============================================================================== --- trunk/libzypp/zypp/pool/PoolImpl.h (original) +++ trunk/libzypp/zypp/pool/PoolImpl.h Thu Apr 24 18:58:20 2008 @@ -143,11 +143,69 @@ return false; } - bool softLockAppliesTo( sat::Solvable solv_r ) const + public: + typedef PoolTraits::AutoSoftLocks AutoSoftLocks; + typedef PoolTraits::autoSoftLocks_iterator autoSoftLocks_iterator; + + const AutoSoftLocks & autoSoftLocks() const + { return _autoSoftLocks; } + + bool autoSoftLockAppliesTo( sat::Solvable solv_r ) const + { return( _autoSoftLocks.find( solv_r.ident() ) != _autoSoftLocks.end() ); } + + void setAutoSoftLocks( const AutoSoftLocks & newLocks_r ) { - return false; + MIL << "Apply " << newLocks_r.size() << " AutoSoftLocks: " << newLocks_r << endl; + _autoSoftLocks = newLocks_r; + // now adjust the pool status + for_( it, begin(), end() ) + { + if ( ! it->status().isKept() ) + continue; + + if ( newLocks_r.find( it->satSolvable().ident() ) != newLocks_r.end() ) + it->status().setSoftLock( ResStatus::USER ); + else + it->status().resetTransact( ResStatus::USER ); + } } + void getActiveSoftLocks( AutoSoftLocks & activeLocks_r ) + { + activeLocks_r = _autoSoftLocks; // currentsoft-locks + AutoSoftLocks todel; // + names to be deleted + AutoSoftLocks toins; // - names to be installed + + for_( it, begin(), end() ) + { + ResStatus & status( it->status() ); + if ( ! status.isByUser() ) + continue; + + switch ( status.getTransactValue() ) + { + case ResStatus::KEEP_STATE: + activeLocks_r.insert( it->satSolvable().ident() ); + break; + case ResStatus::LOCKED: + // NOOP + break; + case ResStatus::TRANSACT: + (status.isInstalled() ? todel : toins).insert( it->satSolvable().ident() ); + break; + } + } + for_( it, todel.begin(), todel.end() ) + { + activeLocks_r.insert( *it ); + } + for_( it, toins.begin(), toins.end() ) + { + activeLocks_r.erase( *it ); + } + } + + public: const ContainerT & store() const { checkSerial(); @@ -180,7 +238,7 @@ { pi.status().setLock( true, ResStatus::USER ); } - else if ( softLockAppliesTo( s ) ) + else if ( autoSoftLockAppliesTo( s ) ) { pi.status().setSoftLock( ResStatus::USER ); } @@ -213,7 +271,6 @@ return _id2item; } - /////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////// @@ -243,6 +300,10 @@ private: mutable shared_ptr<ResPoolProxy> _poolProxy; + + private: + /** Set of solvable idents that should be soft locked per default. */ + AutoSoftLocks _autoSoftLocks; }; /////////////////////////////////////////////////////////////////// Modified: trunk/libzypp/zypp/pool/PoolTraits.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/pool/PoolTraits.h?rev=9809&r1=9808&r2=9809&view=diff ============================================================================== --- trunk/libzypp/zypp/pool/PoolTraits.h (original) +++ trunk/libzypp/zypp/pool/PoolTraits.h Thu Apr 24 18:58:20 2008 @@ -141,6 +141,10 @@ /* list of known Repositories */ typedef sat::Pool::RepositoryIterator repository_iterator; + /* soft locks */ + typedef std::tr1::unordered_set<IdString> AutoSoftLocks; + typedef AutoSoftLocks::const_iterator autoSoftLocks_iterator; + typedef PoolImpl Impl; typedef shared_ptr<PoolImpl> Impl_Ptr; typedef shared_ptr<const PoolImpl> Impl_constPtr; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org