ref: refs/heads/master commit c1170f6710058480cba7abb30e2a4c12facc643f Author: Michael Andres <ma@suse.de> Date: Wed Nov 25 16:37:04 2009 +0100 Selecatble interface for picking specific package versions if multiversion install is on. --- zypp/ui/Selectable.cc | 8 +++++++ zypp/ui/Selectable.h | 26 +++++++++++++++++++++++ zypp/ui/SelectableImpl.cc | 16 ++++++++++++++ zypp/ui/SelectableImpl.h | 51 ++++++++++++++++++++++++++++++-------------- 4 files changed, 85 insertions(+), 16 deletions(-) diff --git a/zypp/ui/Selectable.cc b/zypp/ui/Selectable.cc index 491e02b..04d0534 100644 --- a/zypp/ui/Selectable.cc +++ b/zypp/ui/Selectable.cc @@ -135,6 +135,14 @@ namespace zypp bool Selectable::multiversionInstall() const { return _pimpl->multiversionInstall(); } + bool Selectable::pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r ) + { return _pimpl->pickInstall( pi_r, causer_r, yesno_r ); } + + bool Selectable::pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r ) + { return _pimpl->pickDelete( pi_r, causer_r, yesno_r ); } + + //////////////////////////////////////////////////////////////////////// + bool Selectable::isUndetermined() const { return _pimpl->isUndetermined(); } diff --git a/zypp/ui/Selectable.h b/zypp/ui/Selectable.h index 7b0b3d0..82f97dd 100644 --- a/zypp/ui/Selectable.h +++ b/zypp/ui/Selectable.h @@ -267,11 +267,37 @@ namespace zypp */ bool isUnmaintained() const; + /** \name Multiversion install. + * + * Using \ref pickInstall or \ref pickDelete with non-multiversionInstall items + * is possible, but additional constraints will apply. E.g. selecting one item for + * install will deselect any other. + */ + //@{ /** Whether different versions of this package can be installed at the same time. * Per default \c false. \see also \ref ZConfig::multiversion. */ bool multiversionInstall() const; + /** Select a specific available item for installation. + */ + bool pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true ); + + /** Deselect a specific available item from installation. + */ + bool pickNoInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER ) + { return pickInstall( pi_r, causer_r, false ); } + + /** Select a specific installed item for deletion. + */ + bool pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true ); + + /** Deselect a specific installed item from deletion. + */ + bool pickNoDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER ) + { return pickDelete( pi_r, causer_r, false ); } + //@} + /** \name Classification of available patches (pseudo installed items). * A patch is either \c not \c relevant, \c satisfied or \c broken. * The same applies to other pseudo installed kinds. diff --git a/zypp/ui/SelectableImpl.cc b/zypp/ui/SelectableImpl.cc index 58377ad..ab82c6a 100644 --- a/zypp/ui/SelectableImpl.cc +++ b/zypp/ui/SelectableImpl.cc @@ -323,6 +323,22 @@ namespace zypp return _candidate = newCandidate; } + bool Selectable::Impl::pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r ) + { + if ( pi_r.satSolvable().ident() != ident() || pi_r.satSolvable().isSystem() ) + return false; // not my PoolItem or an installed one + + return pi_r.status().setTransact( yesno_r, causer_r ); + } + + bool Selectable::Impl::pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r ) + { + if ( pi_r.satSolvable().ident() != ident() || ! pi_r.satSolvable().isSystem() ) + return false; // not my PoolItem or not installed + + return pi_r.status().setTransact( yesno_r, causer_r ); + } + ResStatus::TransactByValue Selectable::Impl::modifiedBy() const { PoolItem cand( candidateObj() ); diff --git a/zypp/ui/SelectableImpl.h b/zypp/ui/SelectableImpl.h index b30d772..e5167a2 100644 --- a/zypp/ui/SelectableImpl.h +++ b/zypp/ui/SelectableImpl.h @@ -91,12 +91,13 @@ namespace zypp /** */ bool setStatus( const Status state_r, ResStatus::TransactByValue causer_r ); - /** Installed object. */ + /** Installed object (transacting ot highest version). */ PoolItem installedObj() const { - if (!installedEmpty()) - return *_installedItems.begin(); + if ( installedEmpty() ) return PoolItem(); + PoolItem ret( transactingInstalled() ); + return ret ? ret : *_installedItems.begin(); } /** Best among available objects. @@ -140,9 +141,10 @@ namespace zypp */ PoolItem updateCandidateObj() const { - if ( installedEmpty() || ! _defaultCandidate ) + if ( multiversionInstall() || installedEmpty() || ! _defaultCandidate ) return _defaultCandidate; - // Here: installed and _defaultCandidate are non NULL. + // Here: installed and _defaultCandidate are non NULL and it's not a + // multiversion install. // update candidate must come from the highest priority repo if ( _defaultCandidate->repoInfo().priority() != (*availableBegin())->repoInfo().priority() ) @@ -186,13 +188,9 @@ namespace zypp PoolItem theObj() const { PoolItem ret( candidateObj() ); - if (ret) - return ret; - - if ( ! _installedItems.empty() ) - return (*_installedItems.begin()); - - return PoolItem(); + if ( ret ) + return ret; + return installedObj(); } //////////////////////////////////////////////////////////////////////// @@ -231,6 +229,12 @@ namespace zypp bool multiversionInstall() const { return theObj().satSolvable().multiversionInstall(); } + bool pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r ); + + bool pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r ); + + //////////////////////////////////////////////////////////////////////// + bool isUndetermined() const { PoolItem cand( candidateObj() ); @@ -264,10 +268,19 @@ namespace zypp { if ( candidateObj() ) candidateObj().status().setLicenceConfirmed( val_r ); } private: + PoolItem transactingInstalled() const + { + for_( it, installedBegin(), installedEnd() ) + { + if ( (*it).status().transacts() ) + return (*it); + } + return PoolItem(); + } + PoolItem transactingCandidate() const { - for ( available_const_iterator it = availableBegin(); - it != availableEnd(); ++it ) + for_( it, availableBegin(), availableEnd() ) { if ( (*it).status().transacts() ) return (*it); @@ -277,7 +290,7 @@ namespace zypp PoolItem defaultCandidate() const { - if ( !installedEmpty() ) + if ( ! ( multiversionInstall() || installedEmpty() ) ) { // prefer the installed objects arch and vendor bool solver_allowVendorChange( ZConfig::instance().solver_allowVendorChange() ); @@ -356,10 +369,16 @@ namespace zypp str << " (I 0) {}" << endl << " "; else { + PoolItem icand( obj.installedObj() ); str << " (I " << obj.installedSize() << ") {" << endl; for_( it, obj.installedBegin(), obj.installedEnd() ) { - str << " " << *it << endl; + char t = ' '; + if ( *it == icand ) + { + t = 'i'; + } + str << " " << t << " " << *it << endl; } str << "} "; } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org