except save/restore which is Targets job.
}
}
-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) );
-}
/******************************************************************
**
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 ) );
}
}
- if ( 0 )
+ if ( 1 )
{
Measure x( "INIT TARGET" );
{
- getZYpp()->initializeTarget( sysRoot );
+ {
+ zypp::base::LogControl::TmpLineWriter shutUp;
+ getZYpp()->initializeTarget( sysRoot );
+ }
getZYpp()->target()->load();
}
}
USR << "pool: " << pool << endl;
///////////////////////////////////////////////////////////////////
+
if ( 0 )
{
Measure x( "Upgrade" );
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
- 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;
///////////////////////////////////////////////////////////////////
+#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;
bool got_match = false;
if (_has_next)
{
- DBG << "last: " << _sid << endl;
+ XXX << "last: " << _sid << endl;
while (_has_next && !(got_match = matchSolvable()));
}
_sid = 0;
}
- DBG << "next: " << _sid << endl;
+ XXX << "next: " << _sid << endl;
}
bool PoolQueryIterator::matchSolvable()
//
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;
}
// 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 )
{}
PoolItem ResPool::find( const sat::Solvable & slv_r ) const
{ return _pimpl->find( slv_r ); }
+
ResPool::size_type ResPool::knownRepositoriesSize() const
{ return _pimpl->knownRepositoriesSize(); }
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(); }
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;
};
///////////////////////////////////////////////////////////////////
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 ); }
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();
{
pi.status().setLock( true, ResStatus::USER );
}
- else if ( softLockAppliesTo( s ) )
+ else if ( autoSoftLockAppliesTo( s ) )
{
pi.status().setSoftLock( ResStatus::USER );
}
return _id2item;
}
-
///////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////
private:
mutable shared_ptr<ResPoolProxy> _poolProxy;
+
+ private:
+ /** Set of solvable idents that should be soft locked per default. */
+ AutoSoftLocks _autoSoftLocks;
};
///////////////////////////////////////////////////////////////////
/* 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;