瀏覽代碼

fix priority sorting by prefering higher in MarkInstall

Used to work until a certain (here unnamed) person came along and used
the wrong operator causing low-priority packages to be sorted above
high-priority packages while choosing a provider in commit
 2b5c35c7bb915dbd46fefd7c79f05364ba22f93b from Nov 2011
David Kalnischkies 13 年之前
父節點
當前提交
6933585826
共有 3 個文件被更改,包括 38 次插入1 次删除
  1. 1 1
      apt-pkg/depcache.cc
  2. 1 0
      debian/changelog
  3. 36 0
      test/integration/test-prefer-higher-priority-providers

+ 1 - 1
apt-pkg/depcache.cc

@@ -1004,7 +1004,7 @@ struct CompareProviders {
       }
       // higher priority seems like a good idea
       if (AV->Priority != BV->Priority)
-	 return AV->Priority < BV->Priority;
+	 return AV->Priority > BV->Priority;
       // prefer native architecture
       if (strcmp(A.Arch(), B.Arch()) != 0)
       {

+ 1 - 0
debian/changelog

@@ -6,6 +6,7 @@ apt (0.9.8.3) UNRELEASED; urgency=low
   * rewrite pkgOrderList::DepRemove to stop incorrect immediate setting
     (Closes: 645713)
   * prefer Essentials over Removals in ordering score
+  * fix priority sorting by prefering higher in MarkInstall
 
  -- David Kalnischkies <kalnischkies@gmail.com>  Sun, 09 Jun 2013 15:06:24 +0200
 

+ 36 - 0
test/integration/test-prefer-higher-priority-providers

@@ -0,0 +1,36 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'native'
+
+insertpackage 'unstable' 'foo' 'all' '1' 'Provides: stuff' 'important'
+insertpackage 'unstable' 'bar' 'all' '1' 'Provides: stuff' 'optional'
+insertpackage 'unstable' 'baz' 'all' '1' 'Provides: stuff' 'extra'
+insertpackage 'unstable' 'awesome' 'all' '1' 'Depends: stuff'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+  foo
+The following NEW packages will be installed:
+  awesome foo
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1 unstable [all])
+Inst awesome (1 unstable [all])
+Conf foo (1 unstable [all])
+Conf awesome (1 unstable [all])' aptget install awesome -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+  awesome foo
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1 unstable [all])
+Inst awesome (1 unstable [all])
+Conf foo (1 unstable [all])
+Conf awesome (1 unstable [all])' aptget install awesome foo -s