update -t package: keep the same architecture (#222140).
authorMartin Vidner <mvidner@suse.cz>
Mon, 20 Nov 2006 12:56:02 +0000 (12:56 +0000)
committerMartin Vidner <mvidner@suse.cz>
Mon, 20 Nov 2006 12:56:02 +0000 (12:56 +0000)
VERSION
package/zypper.changes
src/zmart-misc.cc

diff --git a/VERSION b/VERSION
index 600294e..c40a6ff 100644 (file)
--- 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 ==================================================
index 2fdea93..273728c 100644 (file)
@@ -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
index 775d042..2e0e0f6 100644 (file)
@@ -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<CompareByEQ<Arch> >( item->arch() ) ),
+                 resfilter::byEdition<CompareByGT<Edition> >( item->edition() )),
+               functor::functorRef<bool,PoolItem> (info) );
+
+  _XDEBUG("findArchUpdateItem(" << item << ") => " << info.uninstalled);
+  return info.uninstalled;
+}
+
 typedef set<PoolItem_Ref> 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;