ref: refs/heads/ma-misc
commit a4b970939b95a4a2d617ad56f72174653dfdfa48
Author: Michael Andres
Date: Thu Oct 15 20:47:01 2009 +0200
ResStatus: add isOrphaned: test whether package is orphaned (not provided by any repo)
---
zypp/ResStatus.cc | 1 +
zypp/ResStatus.h | 46 +++++++++++------------
zypp/solver/detail/SATResolver.cc | 76 ++++++++++++-------------------------
3 files changed, 48 insertions(+), 75 deletions(-)
diff --git a/zypp/ResStatus.cc b/zypp/ResStatus.cc
index 083e16c..23bc8cd 100644
--- a/zypp/ResStatus.cc
+++ b/zypp/ResStatus.cc
@@ -88,6 +88,7 @@ namespace zypp
( obj.isToBeUninstalledDueToUpgrade() ? "U" :
( obj.isToBeInstalledSoft() ? "S" : "_" ) ) );
+ str << (obj.isOrphaned() ? "o" : "" );
str << (obj.isRecommended() ? "r" : "" );
str << (obj.isSuggested() ? "s" : "" );
diff --git a/zypp/ResStatus.h b/zypp/ResStatus.h
index 7ff527f..c962640 100644
--- a/zypp/ResStatus.h
+++ b/zypp/ResStatus.h
@@ -71,7 +71,7 @@ namespace zypp
typedef bit::Range TransactByField;
typedef bit::Range TransactDetailField;
typedef bit::Range LicenceConfirmedField;
- typedef bit::Range WeakField;
+ typedef bit::Range WeakField;
typedef bit::Range UserLockQueryField; // internal
// enlarge FieldType if more bit's needed. It's not yet
// checked by the compiler.
@@ -135,12 +135,12 @@ namespace zypp
LICENCE_CONFIRMED = bit::RangeValue::value
};
- enum WeakValue
+ enum WeakValue // Unlike the other fields those are BITS that may be or'ed!
{
NO_WEAK = bit::RangeValue::value,
- SUGGESTED = bit::RangeValue::value,
- RECOMMENDED = bit::RangeValue::value,
- SUGGESTED_AND_RECOMMENDED = bit::RangeValue::value
+ SUGGESTED = bit::RangeValue::value,
+ RECOMMENDED = bit::RangeValue::value,
+ ORPHANED = bit::RangeValue::value
};
enum UserLockQuery // internal
@@ -178,30 +178,28 @@ namespace zypp
{ fieldValueAssign<LicenceConfirmedField>( toVal_r ? LICENCE_CONFIRMED : LICENCE_UNCONFIRMED ); }
public:
-
bool isRecommended() const
- { return fieldValueIs<WeakField>( RECOMMENDED ); }
+ { return _bitfield.test( RECOMMENDED ); }
bool isSuggested() const
- { return fieldValueIs<WeakField>( SUGGESTED ); }
+ { return _bitfield.test( SUGGESTED ); }
+
+ bool isOrphaned() const
+ { return _bitfield.test( ORPHANED ); }
- bool resetWeak() const
- { return fieldValueIs<WeakField>( NO_WEAK ); }
+ void resetWeak()
+ { return fieldValueAssign<WeakField>( NO_WEAK ); }
void setRecommended( bool toVal_r = true )
- { if (isSuggested())
- fieldValueAssign<WeakField>( toVal_r ? SUGGESTED_AND_RECOMMENDED : SUGGESTED );
- else
- fieldValueAssign<WeakField>( toVal_r ? RECOMMENDED : NO_WEAK );
- }
+ { _bitfield.set( RECOMMENDED, toVal_r ); }
void setSuggested( bool toVal_r = true )
- { if (isRecommended())
- fieldValueAssign<WeakField>( toVal_r ? SUGGESTED_AND_RECOMMENDED : RECOMMENDED );
- else
- fieldValueAssign<WeakField>( toVal_r ? SUGGESTED : NO_WEAK );
- }
+ { _bitfield.set( SUGGESTED, toVal_r ); }
+
+ void setOrphaned( bool toVal_r = true )
+ { _bitfield.set( ORPHANED, toVal_r ); }
+ public:
ValidateValue validate() const
{ return (ValidateValue)_bitfield.value<ValidateField>(); }
@@ -660,23 +658,23 @@ namespace zypp
*/
template<class _Field>
bool fieldValueIs( FieldType val_r ) const
- { return _bitfield.isEqual<_Field>( val_r ); }
+ { return _bitfield.isEqual<_Field>( val_r ); }
/** Set the corresponding Field to value \a val_r.
*/
template<class _Field>
void fieldValueAssign( FieldType val_r )
- { _bitfield.assign<_Field>( val_r ); }
+ { _bitfield.assign<_Field>( val_r ); }
/** compare two values.
*/
template<class _Field>
bool isGreaterThan( FieldType val_r )
- { return _bitfield.value<_Field>() > val_r; }
+ { return _bitfield.value<_Field>() > val_r; }
template<class _Field>
bool isLessThan( FieldType val_r )
- { return _bitfield.value<_Field>() < val_r; }
+ { return _bitfield.value<_Field>() < val_r; }
private:
friend class resstatus::StatusBackup;
diff --git a/zypp/solver/detail/SATResolver.cc b/zypp/solver/detail/SATResolver.cc
index 8751ed6..849c8ab 100644
--- a/zypp/solver/detail/SATResolver.cc
+++ b/zypp/solver/detail/SATResolver.cc
@@ -93,6 +93,13 @@ inline std::string itemToString( const PoolItem & item )
return ret;
}
+inline PoolItem getPoolItem( Id id_r )
+{
+ PoolItem ret( (sat::Solvable( id_r )) );
+ if ( !ret && id_r )
+ INT << "id " << id_r << " not found in ZYPP pool." << endl;
+ return ret;
+}
//---------------------------------------------------------------------------
@@ -431,20 +438,15 @@ SATResolver::solving(const CapabilitySet & requires_caps,
_result_items_to_remove.clear();
/* solvables to be installed */
- for (int i = 0; i < _solv->decisionq.count; i++)
+ for ( int i = 0; i < _solv->decisionq.count; ++i )
{
- Id p;
- p = _solv->decisionq.elements[i];
- if (p < 0 || !sat::Solvable(p) || sat::Solvable(p).isSystem())
+ sat::Solvable slv( _solv->decisionq.elements[i] );
+ if ( !slv || slv.isSystem() )
continue;
- PoolItem poolItem((sat::Solvable(p)));
- if (poolItem) {
- SATSolutionToPool (poolItem, ResStatus::toBeInstalled, ResStatus::SOLVER);
- _result_items_to_install.push_back (poolItem);
- } else {
- ERR << "id " << p << " not found in ZYPP pool." << endl;
- }
+ PoolItem poolItem( slv );
+ SATSolutionToPool (poolItem, ResStatus::toBeInstalled, ResStatus::SOLVER);
+ _result_items_to_install.push_back (poolItem);
}
/* solvables to be erased */
@@ -486,56 +488,28 @@ SATResolver::solving(const CapabilitySet & requires_caps,
}
}
}
+
/* solvables which are recommended */
- for (int i = 0; i < _solv->recommendations.count; i++)
+ for ( int i = 0; i < _solv->recommendations.count; ++i )
{
- Id p;
- p = _solv->recommendations.elements[i];
- if (p < 0 || !sat::Solvable(p))
- continue;
-
- PoolItem poolItem = _pool.find (sat::Solvable(p));
- if (poolItem) {
- poolItem.status().setRecommended(true);
- _XDEBUG("SATSolutionToPool(" << poolItem << ") recommended !");
- } else {
- ERR << "id " << p << " not found in ZYPP pool." << endl;
- }
+ PoolItem poolItem( getPoolItem( _solv->recommendations.elements[i] ) );
+ poolItem.status().setRecommended( true );
}
/* solvables which are suggested */
- for (int i = 0; i < _solv->suggestions.count; i++)
+ for ( int i = 0; i < _solv->suggestions.count; ++i )
{
- Id p;
- p = _solv->suggestions.elements[i];
- if (p < 0 || !sat::Solvable(p))
- continue;
-
- PoolItem poolItem = _pool.find (sat::Solvable(p));
- if (poolItem) {
- poolItem.status().setSuggested(true);
- _XDEBUG("SATSolutionToPool(" << poolItem << ") suggested !");
- } else {
- ERR << "id " << p << " not found in ZYPP pool." << endl;
- }
+ PoolItem poolItem( getPoolItem( _solv->suggestions.elements[i] ) );
+ poolItem.status().setSuggested( true );
}
_problem_items.clear();
- /* solvables which are no longer supported */
- for (int i = 0; i < _solv->orphaned.count; i++)
+ /* solvables which are orphaned */
+ for ( int i = 0; i < _solv->orphaned.count; ++i )
{
- Id p;
- p = _solv->orphaned.elements[i];
- if (p < 0 || !sat::Solvable(p))
- continue;
-
- PoolItem poolItem = _pool.find (sat::Solvable(p));
- if (poolItem) {
- _problem_items.push_back(poolItem);
- _XDEBUG( poolItem << " orphaned !");
- } else {
- ERR << "id " << p << " not found in ZYPP pool." << endl;
- }
+ PoolItem poolItem( getPoolItem( _solv->orphaned.elements[i] ) );
+ poolItem.status().setOrphaned( true );
+ _problem_items.push_back( poolItem );
}
/* Write validation state back to pool */
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org