Author: mlandres
Date: Tue Apr 29 18:19:41 2008
New Revision: 9890
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9890&view=rev
Log:
backup
Modified:
trunk/libzypp/devel/devel.ma/NewPool.cc
trunk/libzypp/zypp/ResPool.cc
trunk/libzypp/zypp/ResPool.h
trunk/libzypp/zypp/ResStatus.cc
trunk/libzypp/zypp/ResStatus.h
trunk/libzypp/zypp/pool/PoolImpl.h
trunk/libzypp/zypp/pool/PoolTraits.h
trunk/libzypp/zypp/target/TargetImpl.cc
Modified: trunk/libzypp/devel/devel.ma/NewPool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=9890&r1=9889&r2=9890&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/NewPool.cc (original)
+++ trunk/libzypp/devel/devel.ma/NewPool.cc Tue Apr 29 18:19:41 2008
@@ -454,33 +454,112 @@
namespace zypp
{
-// poolItemIterator
- template <class _Filter>
- class PoolFilter
+ /** Helper class to collect (not only) \ref PoolQuery results.
+ *
+ * \note Unfortunately \ref PoolQuery::begin might throw. Exceptions
+ * are caught and the query is treated as empty.
+ *
+ * \ref PoolQueryResult maintains a set of \ref sat::Solvable. You can
+ * add/remove solvables to/from the set defined by:
+ *
+ * \li a single \ref sat::Solvable
+ * \li a \ref PoolQuery
+ * \li an other \ref PoolQueryResult
+ * \li any iterator pair with \c value_type \ref sat::Solvable or \ref PoolQuery
+ * or \ref PoolQueryResult (any type that fits \c operator+=)
+ */
+ class PoolQueryResult : public sat::SolvIterMixinsat::Solvable::const_iterator>
{
- typedef filter_iterator<_Filter,ResPool::const_iterator> iterator;
+ public:
+ typedef std::tr1::unordered_setsat::Solvable ResultSet;
+ typedef ResultSet::size_type size_type;
+ typedef ResultSet::const_iterator const_iterator;
public:
- PoolFilter()
+ PoolQueryResult()
{}
- PoolFilter( const _Filter & filter_r )
- : _filter( filter_r )
- {}
+ explicit PoolQueryResult( sat::Solvable result_r )
+ { _result.insert( result_r ); }
+
+ explicit PoolQueryResult( const PoolQuery & query_r )
+ { operator+=( query_r ); }
+
+ template<class _QueryResultIter>
+ PoolQueryResult( _QueryResultIter begin_r, _QueryResultIter end_r )
+ {
+ for_( it, begin_r, end_r )
+ {
+ operator+=( *it );
+ }
+ }
+
+ public:
+ /***/
+ bool empty() const
+ { return _result.empty(); }
+ /***/
+ size_type size() const
+ { return _result.size(); }
+ /***/
+ const_iterator begin() const
+ { return _result.begin(); }
+ /***/
+ const_iterator end() const
+ { return _result.end(); }
- iterator begin() const
- { return ResPool::instance().filterBegin(_filter); }
+ public:
+ /**
+ */
+ PoolQueryResult & operator+=( const PoolQueryResult & query_r )
+ {
+ if ( ! query_r.empty() )
+ _result.insert( query_r.begin(), query_r.end() );
+ return *this;
+ }
+ /** \overload */
+ PoolQueryResult & operator+=( const PoolQuery & query_r )
+ { return operator+=( PoolQueryResult( query_r ) ); }
+ /** \overload */
+ PoolQueryResult & operator+=( sat::Solvable result_r )
+ { _result.insert( result_r ); return *this; }
+
+ /**
+ */
+ PoolQueryResult & operator-=( const PoolQueryResult & query_r );
+ /** \overload */
+ PoolQueryResult & operator-=( const PoolQuery & query_r )
+ { return operator-=( PoolQueryResult( query_r ) ); }
+ /** \overload */
+ PoolQueryResult & operator-=( sat::Solvable result_r )
+ { return operator+=( PoolQueryResult( result_r ) ); }
- iterator end() const
- { return ResPool::instance().filterEnd(_filter); }
+ public:
+ /**
+ */
+ PoolQueryResult operator+( const PoolQueryResult & query_r ) const
+ { return PoolQueryResult(*this) += query_r; }
+ /** \overload */
+ PoolQueryResult operator+( const PoolQuery & query_r ) const
+ { return PoolQueryResult(*this) += query_r; }
+ /** \overload */
+ PoolQueryResult operator+( sat::Solvable result_r ) const
+ { return PoolQueryResult(*this) += result_r; }
+
+ /**
+ */
+ PoolQueryResult operator-( const PoolQueryResult & query_r ) const
+ { return PoolQueryResult(*this) -= query_r; }
+ /** \overload */
+ PoolQueryResult operator-( const PoolQuery & query_r ) const
+ { return PoolQueryResult(*this) -= query_r; }
+ /** \overload */
+ PoolQueryResult operator-( sat::Solvable result_r ) const
+ { return PoolQueryResult(*this) -= result_r; }
private:
- _Filter _filter;
+ ResultSet _result;
};
-
- template <class _Filter>
- PoolFilter<_Filter> makePoolFilter( const _Filter & filter_r )
- { return PoolFilter<_Filter>( filter_r ); }
}
void tt( const std::string & name_r, ResKind kind_r = ResKind::package )
@@ -502,12 +581,36 @@
outs << t << ": {" << endl;
for_( it, pool.begin(), pool.end() )
{
- if ( it->status().isSoftLocked() )
+ if ( it->status().isLocked() )
outs << " " << *it << endl;
}
outs << '}' << endl;
}
+void ssup()
+{
+ ResPool pool( ResPool::instance() );
+
+ ResPool::HardLockQueries newLocks;
+
+ {
+ PoolQuery q;
+ q.addAttribute( sat::SolvAttr::name, "kde3*" );
+ q.setMatchGlob();
+ dumpRange( DBG, q.begin(), q.end() ) << endl;
+ newLocks.push_back( q );
+ }
+ {
+ PoolQuery q;
+ q.addAttribute( sat::SolvAttr::name, "kde4*" );
+ q.setMatchGlob();
+ dumpRange( DBG, q.begin(), q.end() ) << endl;
+ newLocks.push_back( q );
+ }
+
+ pool.setHardLockQueries( newLocks );
+
+}
/******************************************************************
@@ -521,10 +624,14 @@
++argv;
zypp::base::LogControl::instance().logToStdErr();
INT << "===[START]==========================================" << endl;
+ ZConfig::instance();
ResPool pool( ResPool::instance() );
sat::Pool satpool( sat::Pool::instance() );
+ ssup();
+ //sslk( "START" );
+
if ( 1 )
{
RepoManager repoManager( makeRepoManager( sysRoot ) );
@@ -579,6 +686,8 @@
}
USR << "pool: " << pool << endl;
+
+ sslk( nrepo.alias() );
}
}
}
@@ -592,6 +701,7 @@
getZYpp()->initializeTarget( sysRoot );
}
getZYpp()->target()->load();
+ sslk( "TARGET" );
}
}
@@ -609,6 +719,13 @@
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
+
+
+ ///////////////////////////////////////////////////////////////////
+ INT << "===[END]============================================" << endl << endl;
+ zypp::base::LogControl::instance().logNothing();
+ return 0;
+
SEC << zypp::getZYpp()->diskUsage() << endl;
if ( 0 )
Modified: trunk/libzypp/zypp/ResPool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResPool.cc?rev=9890&r1=9889&r2=9890&view=diff
==============================================================================
--- trunk/libzypp/zypp/ResPool.cc (original)
+++ trunk/libzypp/zypp/ResPool.cc Tue Apr 29 18:19:41 2008
@@ -95,6 +95,26 @@
void ResPool::getActiveSoftLocks( AutoSoftLocks & activeLocks_r )
{ _pimpl->getActiveSoftLocks( activeLocks_r ); }
+
+ bool ResPool::hardLockQueriesEmpty() const
+ { return _pimpl->hardLockQueries().empty(); }
+
+ ResPool::size_type ResPool::hardLockQueriesSize() const
+ { return _pimpl->hardLockQueries().size(); }
+
+ ResPool::hardLockQueries_iterator ResPool::hardLockQueriesBegin() const
+ { return _pimpl->hardLockQueries().begin(); }
+
+ ResPool::hardLockQueries_iterator ResPool::hardLockQueriesEnd() const
+ { return _pimpl->hardLockQueries().end(); }
+
+ void ResPool::setHardLockQueries( const HardLockQueries & newLocks_r )
+ { _pimpl->setHardLockQueries( newLocks_r ); }
+
+ void ResPool::getHardLockQueries( HardLockQueries & activeLocks_r )
+ { _pimpl->getHardLockQueries( 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=9890&r1=9889&r2=9890&view=diff
==============================================================================
--- trunk/libzypp/zypp/ResPool.h (original)
+++ trunk/libzypp/zypp/ResPool.h Tue Apr 29 18:19:41 2008
@@ -333,6 +333,35 @@
*/
void getActiveSoftLocks( AutoSoftLocks & activeLocks_r );
//@}
+
+ public:
+ /** \name Handle hard locks (e.g set from /etc/zypp/locks).
+ *
+ * As this kind of lock is query based, it's quite expensive.
+ *
+ * These queries are re-evaluated when adding new repos to the pool.
+ */
+ //@{
+ typedef pool::PoolTraits::HardLockQueries HardLockQueries;
+ typedef pool::PoolTraits::hardLockQueries_iterator hardLockQueries_iterator;
+
+ bool hardLockQueriesEmpty() const;
+ size_type hardLockQueriesSize() const;
+ hardLockQueries_iterator hardLockQueriesBegin() const;
+ hardLockQueries_iterator hardLockQueriesEnd() const;
+
+ /** Set a new set of queries.
+ * The hard-locks of existing PoolItems are adjusted according
+ * to the queries. (usually called on target load)
+ */
+ void setHardLockQueries( const HardLockQueries & newLocks_r );
+
+ /** Suggest a new set of queries based on the current selection.
+ * (usually remembered on commit).
+ */
+ void getHardLockQueries( HardLockQueries & activeLocks_r );
+ //@}
+
private:
const pool::PoolTraits::ItemContainerT & store() const;
const pool::PoolTraits::Id2ItemT & id2item() const;
Modified: trunk/libzypp/zypp/ResStatus.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResStatus.cc?rev=9890&r1=9889&r2=9890&view=diff
==============================================================================
--- trunk/libzypp/zypp/ResStatus.cc (original)
+++ trunk/libzypp/zypp/ResStatus.cc Tue Apr 29 18:19:41 2008
@@ -58,7 +58,7 @@
ResStatus::ResStatus (enum StateValue s, enum ValidateValue v, enum TransactValue t, enum InstallDetailValue i, enum RemoveDetailValue r, enum SolverStateValue ssv)
: _bitfield (s)
{
- fieldValueAssign<ValidateField>(v);
+ fieldValueAssign<ValidateField>(v);
fieldValueAssign<TransactField>(t);
if (t == TRANSACT) {
if (s == INSTALLED) fieldValueAssign<TransactDetailField>(r);
@@ -99,8 +99,10 @@
str << (obj.isRecommended() ? "r" : "" );
- str << (obj.isSuggested() ? "s" : "" );
-
+ str << (obj.isSuggested() ? "s" : "" );
+#ifdef HARDLOCKTEST
+ str << (obj.isUserLockQueryMatch() ? "L" : "_" );
+#endif
return str;
}
Modified: trunk/libzypp/zypp/ResStatus.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResStatus.h?rev=9890&r1=9889&r2=9890&view=diff
==============================================================================
--- trunk/libzypp/zypp/ResStatus.h (original)
+++ trunk/libzypp/zypp/ResStatus.h Tue Apr 29 18:19:41 2008
@@ -20,6 +20,11 @@
namespace zypp
{ /////////////////////////////////////////////////////////////////
+ namespace resstatus
+ {
+ class UserLockQueryManip;
+ }
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : ResStatus
@@ -67,6 +72,7 @@
typedef bit::Range SolverStateField;
typedef bit::Range LicenceConfirmedField;
typedef bit::Range WeakField;
+ typedef bit::Range UserLockQueryField; // internal
// enlarge FieldType if more bit's needed. It's not yet
// checked by the compiler.
//@}
@@ -142,6 +148,12 @@
RECOMMENDED = bit::RangeValue::value,
SUGGESTED_AND_RECOMMENDED = bit::RangeValue::value
};
+
+ enum UserLockQuery // internal
+ {
+ USERLOCK_NOMATCH = bit::RangeValue::value,
+ USERLOCK_MATCH = bit::RangeValue::value
+ };
//@}
public:
@@ -284,6 +296,19 @@
bool isToBeUninstalledSoft () const
{ return isToBeUninstalled() && fieldValueIs<TransactDetailField>( SOFT_REMOVE ); }
+ private:
+
+ /** \name Internal hard lock maintainance */
+ //@{
+ friend class resstatus::UserLockQueryManip;
+
+ bool isUserLockQueryMatch() const
+ { return fieldValueIs<UserLockQueryField>( USERLOCK_MATCH ); }
+
+ void setUserLockQueryMatch( bool match_r )
+ { fieldValueAssign<UserLockQueryField>( match_r ? USERLOCK_MATCH : USERLOCK_NOMATCH ); }
+ //@}
+
public:
//------------------------------------------------------------------------
Modified: trunk/libzypp/zypp/pool/PoolImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/pool/PoolImpl.h?rev=9890&r1=9889&r2=9890&view=diff
==============================================================================
--- trunk/libzypp/zypp/pool/PoolImpl.h (original)
+++ trunk/libzypp/zypp/pool/PoolImpl.h Tue Apr 29 18:19:41 2008
@@ -21,6 +21,7 @@
#include "zypp/pool/PoolTraits.h"
#include "zypp/ResPoolProxy.h"
+#include "zypp/PoolQuery.h"
#include "zypp/sat/Pool.h"
@@ -138,9 +139,31 @@
//
///////////////////////////////////////////////////////////////////
public:
- bool hardLockAppliesTo( sat::Solvable solv_r ) const
+ typedef PoolTraits::HardLockQueries HardLockQueries;
+ typedef PoolTraits::hardLockQueries_iterator hardLockQueries_iterator;
+
+ const HardLockQueries & hardLockQueries() const
+ { return _hardLockQueries; }
+
+ void reapplyHardLocks() const
+ {
+#ifdef HARDLOCKTEST
+ SEC << "reapplyHardLocks " << endl;
+#endif
+ }
+
+ void setHardLockQueries( const HardLockQueries & newLocks_r )
{
- return false;
+ MIL << "Apply " << newLocks_r.size() << " HardLockQueries" << endl;
+ _hardLockQueries = newLocks_r;
+ // now adjust the pool status
+ // TBD
+ }
+
+ void getHardLockQueries( HardLockQueries & activeLocks_r )
+ {
+ activeLocks_r = _hardLockQueries; // current queries
+ // TBD
}
public:
@@ -163,7 +186,7 @@
if ( ! it->status().isKept() )
continue;
- if ( newLocks_r.find( it->satSolvable().ident() ) != newLocks_r.end() )
+ if ( autoSoftLockAppliesTo( it->satSolvable() ) )
it->status().setSoftLock( ResStatus::USER );
else
it->status().resetTransact( ResStatus::USER );
@@ -172,7 +195,7 @@
void getActiveSoftLocks( AutoSoftLocks & activeLocks_r )
{
- activeLocks_r = _autoSoftLocks; // currentsoft-locks
+ activeLocks_r = _autoSoftLocks; // current soft-locks
AutoSoftLocks todel; // + names to be deleted
AutoSoftLocks toins; // - names to be installed
@@ -180,7 +203,7 @@
{
ResStatus & status( it->status() );
if ( ! status.isByUser() )
- continue;
+ continue; // ignore non-uer requests
switch ( status.getTransactValue() )
{
@@ -212,7 +235,12 @@
if ( _storeDirty )
{
sat::Pool pool( satpool() );
+ bool addedItems = false;
+#ifdef HARDLOCKTEST
+#warning REMOVE FAKE REMOVE FAKE REMOVE FAKE REMOVE FAKE
+ addedItems = true;
+#endif
if ( pool.capacity() != _store.capacity() )
{
_store.resize( pool.capacity() );
@@ -233,19 +261,24 @@
{
// new PoolItem to add
pi = PoolItem::makePoolItem( s ); // the only way to create a new one!
- // and a few checks...
- if ( hardLockAppliesTo( s ) )
- {
- pi.status().setLock( true, ResStatus::USER );
- }
- else if ( autoSoftLockAppliesTo( s ) )
+ // and on the fly check for wek locks...
+ if ( autoSoftLockAppliesTo( s ) )
{
pi.status().setSoftLock( ResStatus::USER );
}
+ if ( !addedItems )
+ addedItems = true;
}
}
}
_storeDirty = false;
+
+ // Now, as the pool is adjusted, we must reapply those query
+ // based hard locks...
+ if ( addedItems )
+ {
+ reapplyHardLocks();
+ }
}
return _store;
}
@@ -304,6 +337,8 @@
private:
/** Set of solvable idents that should be soft locked per default. */
AutoSoftLocks _autoSoftLocks;
+ /** Set of queries that define hardlocks. */
+ HardLockQueries _hardLockQueries;
};
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/pool/PoolTraits.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/pool/PoolTraits.h?rev=9890&r1=9889&r2=9890&view=diff
==============================================================================
--- trunk/libzypp/zypp/pool/PoolTraits.h (original)
+++ trunk/libzypp/zypp/pool/PoolTraits.h Tue Apr 29 18:19:41 2008
@@ -27,6 +27,8 @@
namespace zypp
{ /////////////////////////////////////////////////////////////////
+ class PoolQuery;
+
///////////////////////////////////////////////////////////////////
namespace pool
{ /////////////////////////////////////////////////////////////////
@@ -138,13 +140,17 @@
typedef transform_iterator
byIdent_iterator;
- /* list of known Repositories */
+ /** list of known Repositories */
typedef sat::Pool::RepositoryIterator repository_iterator;
- /* soft locks */
+ /** soft locks */
typedef std::tr1::unordered_set<IdString> AutoSoftLocks;
typedef AutoSoftLocks::const_iterator autoSoftLocks_iterator;
+ /** hard locks from etc/zypp/locks */
+ typedef std::list<PoolQuery> HardLockQueries;
+ typedef HardLockQueries::const_iterator hardLockQueries_iterator;
+
typedef PoolImpl Impl;
typedef shared_ptr<PoolImpl> Impl_Ptr;
typedef shared_ptr<const PoolImpl> Impl_constPtr;
Modified: trunk/libzypp/zypp/target/TargetImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.cc?rev=9890&r1=9889&r2=9890&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/TargetImpl.cc (original)
+++ trunk/libzypp/zypp/target/TargetImpl.cc Tue Apr 29 18:19:41 2008
@@ -117,7 +117,7 @@
// path: directory where to look
// name,version,release: Script name must match 'name-version.release-' prefix
//
-#warning nedds to be reimplemented excetion safe
+#warning needs to be reimplemented exception safe
void RunUpdateScript(Pathname path, std::string name, std::string version, std::string release)
{
// open the scripts directory
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org