[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#718482: apt: CompareProviders ranks Priority above native architecture



Package: apt
Version: 0.9.9
Severity: normal
Tags: patch
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch saucy

I noticed my cross-building environments misbehaving as of apt 0.9.9.
Specifically, they sometimes choose packages of the wrong architecture.

Here's an example.  Install ubuntu-dev-tools, unpack
http://people.canonical.com/~cjwatson/tmp/saucy-amd64-arm64-apt-bug.tar.gz
in ~/.chdist/ (it will unpack to a single saucy-amd64-arm64-apt-bug/
subdirectory), adjust the paths in
~/.chdist/saucy-amd64-arm64-apt-bug/etc/apt/apt.conf, and run "chdist
apt-get saucy-amd64-arm64-apt-bug install autoconf".  You will see it
installing m4:arm64, which is clearly incorrect: the primary
architecture is amd64, m4 is Multi-Arch: foreign, and in any case I'm
not asking for anything from arm64 to be installed so there's no reason
apt should reach for the foreign architecture.

The problem here is that the Priority field in one of the Packages files
is incorrect due to a mishap with reprepro configuration, which you can
see if you run "grep-dctrl -PX m4
~/.chdist/saucy-amd64-arm64-apt-bug/var/lib/apt/lists/*_Packages": the
amd64 version is Priority: standard but the arm64 version is Priority:
optional (and has a stray "optional: interpreters" field).  I've asked
the maintainer of the repository in question to fix it up.

However, Priority is a rather weak property of a package because it's
typically applied via overrides, and it's easy for maintainers of
third-party repositories to misconfigure them so that overrides aren't
applied correctly.  It shouldn't be ranked ahead of choosing packages
from the native architecture.  In this case, I have no user-mode
emulation for arm64 set up, so choosing m4:arm64 simply won't work.

Here's a patch.

diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 2c6eb43..978a893 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -1007,9 +1007,6 @@ struct CompareProviders {
 	 else if ((B->Flags & pkgCache::Flag::Important) == pkgCache::Flag::Important)
 	    return true;
       }
-      // higher priority seems like a good idea
-      if (AV->Priority != BV->Priority)
-	 return AV->Priority > BV->Priority;
       // prefer native architecture
       if (strcmp(A.Arch(), B.Arch()) != 0)
       {
@@ -1024,6 +1021,9 @@ struct CompareProviders {
 	    else if (*a == B.Arch())
 	       return true;
       }
+      // higher priority seems like a good idea
+      if (AV->Priority != BV->Priority)
+	 return AV->Priority > BV->Priority;
       // unable to decide…
       return A->ID < B->ID;
    }

Thanks,

-- 
Colin Watson                                       [cjwatson@ubuntu.com]


Reply to: