#!/bin/sh
set -e
-TESTDIR=$(readlink -f $(dirname $0))
-. $TESTDIR/framework
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
setupenvironment
configarchitecture "i386"
setupaptarchive
+testsuccessequal "coolstuff:
+ Installed: (none)
+ Candidate: 2.0~bpo1
+ Version table:
+ 2.0~bpo1 500
+ 500 file:${APTARCHIVE} backports/main all Packages
+ 1.0 500
+ 500 file:${APTARCHIVE} stable/main all Packages" apt policy '^cool.*'
+
testequalpolicycoolstuff() {
local INSTALLED="${1:-(none)}"
local CANDIDATE="${2:-(none)}"
local AB="$3"
local AS="$4"
local PB="$5"
- local PINVERSION="$6"
- if [ -n "$PINVERSION" ]; then
- PINVERSION="Package pin: $PINVERSION
- "
- fi
local IS=""
local IB=""
local SB=""
local BPO2ARCHIVE=""
if [ ! "$7" = "2.0~bpo2" ]; then
BPO1PIN="$AB"
- BPO1ARCHIVE=" $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main i386 Packages"
+ BPO1ARCHIVE=" $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main all Packages"
else
BPO2ARCHIVE="
2.0~bpo2 $AB
- $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main i386 Packages"
+ $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main all Packages"
SB="$(echo "$SB" | tail -n 1)"
shift
fi
testsuccessequal "coolstuff:
Installed: $INSTALLED
Candidate: $CANDIDATE
- ${PINVERSION}Version table:${BPO2ARCHIVE}
+ Version table:${BPO2ARCHIVE}
$IB 2.0~bpo1 $PB
${BPO1ARCHIVE}$SB
$IS 1.0 $AS
- $(echo "$AS" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} stable/main i386 Packages$SS" \
+ $(echo "$AS" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} stable/main all Packages$SS" \
aptcache policy coolstuff -o Policy=${INSTALLED}-${CANDIDATE}-${AB}-${AS}-${PB} $*
}
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 100 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 990 100 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t stable
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 100 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t backports
+
+
+tmppath=$(readlink -f .)
+
+# Check 16-bit integers
+echo "Package: coolstuff
+Pin: release n=backports
+Pin-Priority: 32767
+" > rootdir/etc/apt/preferences
+
+testsuccess aptget install -s coolstuff -o PinPriority=32767
+
+echo "Package: coolstuff
+Pin: release n=backports
+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
+Pin-Priority: 32768
+" > rootdir/etc/apt/preferences
+
+testfailureequal "Reading package lists...
+E: ${tmppath}/rootdir/etc/apt/preferences: Value 32768 is outside the range of valid pin priorities (-32768 to 32767)" \
+ aptget install -s coolstuff -o PinPriority=32768
+
+
+echo "Package: coolstuff
+Pin: release n=backports
+Pin-Priority: -32769
+" > rootdir/etc/apt/preferences
+
+testfailureequal "Reading package lists...
+E: ${tmppath}/rootdir/etc/apt/preferences: Value -32769 is outside the range of valid pin priorities (-32768 to 32767)" \
+ aptget install -s coolstuff -o PinPriority=-32769
+
+# Check for 64-bit integers
+
+echo "Package: coolstuff
+Pin: release n=backports
+Pin-Priority: 2147483648
+" > rootdir/etc/apt/preferences
+
+testfailureequal "Reading package lists...
+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
+Pin-Priority: 0
+" > rootdir/etc/apt/preferences
+
+testfailureequal "Reading package lists...
+E: No priority (or zero) specified for pin" \
+ aptget install -s coolstuff -o PinPriority=0
+
+# Check with comments
+echo "#Package: coolstuff
+#Pin: release n=backports
+#Pin-Priority: 0
+
+# Test
+
+Package: coolstuff
+Pin: release n=backports
+#Pin: release n=unstable
+#Pin-Priority: 999
+Pin-Priority: 999
+#Pin-Priority: 999" > rootdir/etc/apt/preferences
+
+testsuccessequal "coolstuff:
+ Installed: 2.0~bpo1
+ Candidate: 2.0~bpo2
+ Version table:
+ 2.0~bpo2 999
+ 100 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" aptcache policy coolstuff