]> git.saurik.com Git - apt.git/commitdiff
restore pinning to min/max value of short
authorDavid Kalnischkies <david@kalnischkies.de>
Mon, 25 Apr 2016 14:30:43 +0000 (16:30 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Mon, 25 Apr 2016 14:30:43 +0000 (16:30 +0200)
Broken in the previous commit (69cea1ef2cfda3c4da79fd756a8edaf2be26998e).
Adding a test and a comment to avoid future embarrassment.

Git-Dch: Ignore
Reported-By: Julian Andres Klode on IRC
apt-pkg/policy.cc
test/integration/test-policy-pinning

index 7c57f9deaa12dd2b59f888b3cc93ee1bed7ac496..7059b0a7927efc3eae60346fdf59159d2aaadbec 100644 (file)
@@ -374,7 +374,8 @@ APT_PURE signed short pkgPolicy::GetPriority(pkgCache::VerIterator const &Ver, b
    if (!ConsiderFiles)
       return 0;
 
-   signed short priority = std::numeric_limits<signed short>::min();
+   // priorities are short ints, but we want to pick a value outside the valid range here
+   auto priority = std::numeric_limits<signed int>::min();
    for (pkgCache::VerFileIterator file = Ver.FileList(); file.end() == false; file++)
    {
       /* If this is the status file, and the current version is not the
@@ -385,7 +386,7 @@ APT_PURE signed short pkgPolicy::GetPriority(pkgCache::VerIterator const &Ver, b
       if (file.File().Flagged(pkgCache::Flag::NotSource) && Ver.ParentPkg().CurrentVer() != Ver)
         priority = std::max(priority, static_cast<decltype(priority)>(-1));
       else
-        priority = std::max(priority, GetPriority(file.File()));
+        priority = std::max(priority, static_cast<decltype(priority)>(GetPriority(file.File())));
    }
 
    return priority == std::numeric_limits<decltype(priority)>::min() ? 0 : priority;
index 8f4850c4d5463b82bc648bfee7d94937d25fa2cc..30238bd87056d027462a32631aca212e45e5f646 100755 (executable)
@@ -273,7 +273,6 @@ Pin-Priority: -32768
 " > rootdir/etc/apt/preferences
 testsuccess aptget install -s coolstuff -o PinPriority=-32768
 
-
 # Check for 32-bit integers
 echo "Package: coolstuff
 Pin: release n=backports
@@ -306,6 +305,26 @@ E: Cannot convert 2147483648 to integer: out of range
 E: ${tmppath}/rootdir/etc/apt/preferences: Value 2147483648 is outside the range of valid pin priorities (-32768 to 32767)" \
  aptget install -s coolstuff -o PinPriority=2147483648
 
+# Check that short-max/min is a valid pin
+currentpin() {
+echo "Package: *
+Pin: release n=backports
+Pin-Priority: $1
+" > rootdir/etc/apt/preferences
+testsuccessequal "coolstuff:
+  Installed: 2.0~bpo1
+  Candidate: $2
+  Version table:
+     2.0~bpo2 $1
+       $1 file:${tmppath}/aptarchive backports/main all Packages
+ *** 2.0~bpo1 100
+        100 ${tmppath}/rootdir/var/lib/dpkg/status
+     1.0 500
+        500 file:${tmppath}/aptarchive stable/main all Packages" apt policy coolstuff
+}
+currentpin '32767' '2.0~bpo2'
+currentpin '-32768' '2.0~bpo1'
+
 # Check for 0
 echo "Package: coolstuff
 Pin: release n=backports