From 3f0a0de1d4cb18e90ab6d66651011c3d6551594c Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Mon, 20 Nov 2006 12:56:02 +0000 Subject: [PATCH] update -t package: keep the same architecture (#222140). --- VERSION | 2 +- package/zypper.changes | 6 ++++++ src/zmart-misc.cc | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 600294e..c40a6ff 100644 --- a/VERSION +++ b/VERSION @@ -10,5 +10,5 @@ dnl phase) dnl ================================================== m4_define([ZYPPER_MAJOR], [0]) m4_define([ZYPPER_MINOR], [6]) -m4_define([ZYPPER_PATCH], [11]) +m4_define([ZYPPER_PATCH], [12]) dnl ================================================== diff --git a/package/zypper.changes b/package/zypper.changes index 2fdea93..273728c 100644 --- a/package/zypper.changes +++ b/package/zypper.changes @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Mon Nov 20 13:55:28 CET 2006 - mvidner@suse.cz + +- update -t package: keep the same architecture (#222140). +- 0.6.12 + +------------------------------------------------------------------- Wed Nov 15 16:48:13 CET 2006 - mvidner@suse.cz - Resurrected /usr/bin/installation_sources, as a shell wrapper for diff --git a/src/zmart-misc.cc b/src/zmart-misc.cc index 775d042..2e0e0f6 100644 --- a/src/zmart-misc.cc +++ b/src/zmart-misc.cc @@ -499,6 +499,51 @@ void list_patch_updates () cout << tbl; } +// collect items, select best edition. +class LookForArchUpdate : public zypp::resfilter::PoolItemFilterFunctor +{ +public: + PoolItem_Ref uninstalled; + + bool operator()( PoolItem_Ref provider ) + { + if (!provider.status().isLocked() // is not locked (taboo) + && (!uninstalled // first match + // or a better edition than candidate + || uninstalled->edition().compare( provider->edition() ) < 0)) + { + uninstalled = provider; // store + } + return true; // keep going + } +}; + +// Find best (according to edition) uninstalled item +// with same kind/name/arch as item. +// Similar to zypp::solver::detail::Helper::findUpdateItem +// but that allows changing the arch (#222140). +static +PoolItem_Ref +findArchUpdateItem (const ResPool & pool, PoolItem_Ref item) +{ + LookForArchUpdate info; + + invokeOnEach( pool.byNameBegin( item->name() ), + pool.byNameEnd( item->name() ), + // get uninstalled, equal kind and arch, better edition + functor::chain ( + functor::chain ( + functor::chain ( + resfilter::ByUninstalled (), + resfilter::ByKind( item->kind() ) ), + resfilter::byArch >( item->arch() ) ), + resfilter::byEdition >( item->edition() )), + functor::functorRef (info) ); + + _XDEBUG("findArchUpdateItem(" << item << ") => " << info.uninstalled); + return info.uninstalled; +} + typedef set Candidates; void find_updates( const ResObject::Kind &kind, Candidates &candidates ) @@ -513,7 +558,7 @@ void find_updates( const ResObject::Kind &kind, Candidates &candidates ) if (it->status().isUninstalled()) continue; // (actually similar to ProvideProcess?) - PoolItem_Ref candidate = solver::detail::Helper::findUpdateItem (pool, *it); + PoolItem_Ref candidate = findArchUpdateItem (pool, *it); if (!candidate.resolvable()) continue; -- 2.7.4