summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/integration/Packages-policy-pinning12
-rw-r--r--test/integration/framework2
-rwxr-xr-xtest/integration/test-bug-595691-empty-and-broken-archive-files91
-rwxr-xr-xtest/integration/test-policy-pinning228
4 files changed, 332 insertions, 1 deletions
diff --git a/test/integration/Packages-policy-pinning b/test/integration/Packages-policy-pinning
new file mode 100644
index 000000000..a9334e9dd
--- /dev/null
+++ b/test/integration/Packages-policy-pinning
@@ -0,0 +1,12 @@
+Package: oldstuff
+Version: 1.0
+Architecture: i386
+Maintainer: Joe Sixpack <joe@example.org>
+Installed-Size: 100
+Filename: pool/oldstuff_1.0_i386.deb
+Size: 100000
+MD5sum: 311aeeadf78324aaff54c9b4e1f76671
+SHA1: 3c695e028f74d5c544deeddaaa1242desa81088c
+SHA256: b46fd1546151c545fe4bfa56a5cc0e7deaef23e2da3e4f129727fd660f28f050
+Description: some old but cool stuff
+ This package will disappear in the next mirror update
diff --git a/test/integration/framework b/test/integration/framework
index 8a5973d4b..59d2f0e85 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -211,7 +211,7 @@ buildpackage() {
fi
local BUILT="$(dpkg-buildpackage -uc -us -a$ARCH 2> /dev/null)"
local PKGS="$( echo "$BUILT" | grep '^dpkg-deb: building package' | cut -d'/' -f 2 | sed -e "s#'\.##")"
- local SRCS="$( echo "$BUILT" | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._-]*$')"
+ local SRCS="$( echo "$BUILT" | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._+~-]*$')"
cd - > /dev/null
for PKG in $PKGS; do
echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist
diff --git a/test/integration/test-bug-595691-empty-and-broken-archive-files b/test/integration/test-bug-595691-empty-and-broken-archive-files
new file mode 100755
index 000000000..234073759
--- /dev/null
+++ b/test/integration/test-bug-595691-empty-and-broken-archive-files
@@ -0,0 +1,91 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture "i386"
+
+buildaptarchive
+setupflataptarchive
+
+testaptgetupdate() {
+ aptget update 2>> testaptgetupdate.diff >> testaptgetupdate.diff || true
+ sed -i -e '/^Fetched / d' -e 's#\[[0-9]*[kMGTPY]*B\]#\[\]#' testaptgetupdate.diff
+ GIVEN="$1"
+ shift
+ msgtest "Test for correctness of" "apt-get update with $*"
+ if [ -z "$GIVEN" ]; then
+ echo -n "" | checkdiff - testaptgetupdate.diff && msgpass || msgfail
+ else
+ echo "$GIVEN" | checkdiff - testaptgetupdate.diff && msgpass || msgfail
+ fi
+ rm testaptgetupdate.diff
+}
+
+touch aptarchive/en.bz2
+
+testaptgetupdate "Ign file: Release.gpg
+Ign file:$(readlink -f aptarchive)/ Translation-en
+Get:1 file: Release []
+Reading package lists..." "empty file en.bz2 over file"
+
+rm aptarchive/en.bz2
+echo -n "" | bzip2 > aptarchive/en.bz2
+
+testaptgetupdate "Ign file: Release.gpg
+Get:1 file: Release []
+Reading package lists..." "empty archive en.bz2 over file"
+
+rm aptarchive/en.bz2
+
+# do the same again with http instead of file
+changetowebserver
+
+touch aptarchive/en.bz2
+
+testaptgetupdate "Ign http://localhost Release.gpg
+Get:1 http://localhost/ Translation-en
+Get:2 http://localhost Release []
+Ign http://localhost/ Translation-en
+Get:3 http://localhost Packages []
+Reading package lists..." "empty file en.bz2 over http"
+
+rm aptarchive/en.bz2
+echo -n "" | bzip2 > aptarchive/en.bz2
+
+testaptgetupdate "Ign http://localhost Release.gpg
+Get:1 http://localhost/ Translation-en []
+Get:2 http://localhost Release []
+Ign http://localhost Packages/DiffIndex
+Get:3 http://localhost Packages []
+Reading package lists..." "empty archive en.bz2 over http"
+
+rm aptarchive/en.bz2
+
+rm aptarchive/Packages
+touch aptarchive/Packages
+buildaptarchivefromfiles
+
+testaptgetupdate "Ign http://localhost Release.gpg
+Ign http://localhost/ Translation-en
+Get:1 http://localhost Release []
+Ign http://localhost Packages/DiffIndex
+Get:2 http://localhost Packages []
+Reading package lists..." "empty archive Packages over http"
+
+find aptarchive/ -name 'Packages*' -type f -delete
+touch aptarchive/Packages.bz2
+aptftparchive release aptarchive/ > aptarchive/Release
+
+#FIXME: we should response with a good error message instead
+testaptgetupdate "Ign http://localhost Release.gpg
+Ign http://localhost/ Translation-en
+Get:1 http://localhost Release []
+Ign http://localhost Packages/DiffIndex
+Get:2 http://localhost Packages
+Err http://localhost Packages
+ Undetermined Error
+W: Failed to fetch http://localhost:8080/Packages.bz2 Undetermined Error
+
+E: Some index files failed to download, they have been ignored, or old ones used instead." "empty file Packages over http"
diff --git a/test/integration/test-policy-pinning b/test/integration/test-policy-pinning
new file mode 100755
index 000000000..97447b330
--- /dev/null
+++ b/test/integration/test-policy-pinning
@@ -0,0 +1,228 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+buildaptarchive
+setupflataptarchive
+
+STATUS=$(readlink -f rootdir/var/lib/dpkg/status)
+APTARCHIVE=$(readlink -f aptarchive)
+
+testequalpolicy() {
+ local SP="$1"
+ local AP="$2"
+ shift 2
+ testequal "Package files:
+ $(echo "$SP" | awk '{ printf("%3s\n",$0) }') ${STATUS}
+ release a=now
+ $(echo "$AP" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ Packages
+ release c=
+Pinned packages:" aptcache policy $*
+}
+
+aptget update -qq
+testequalpolicy 100 500
+testequalpolicy 990 500 -t now
+
+sed -i aptarchive/Release -e 1i"NotAutomatic: yes"
+rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
+aptget update -qq
+
+testequalpolicy 100 1 -o Test=NotAutomatic
+testequalpolicy 990 1 -o Test=NotAutomatic -t now
+
+sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes"
+rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
+aptget update -qq
+
+testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
+testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
+
+sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
+rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
+aptget update -qq
+
+testequalpolicy 100 500 -o Test=Automatic
+testequalpolicy 990 500 -o Test=Automatic -t now
+
+buildsimplenativepackage "coolstuff" "all" "1.0" "stable"
+buildsimplenativepackage "coolstuff" "all" "2.0~bpo1" "backports"
+
+setupaptarchive
+
+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 SS=""
+ [ "$1" = "2.0~bpo1" ] && IB="***" && SB="
+ 100 $STATUS" || IB=" "
+ [ "$1" = "1.0" ] && IS="***" && SS="
+ 100 $STATUS" || IS=" "
+ local BPO1ARCHIVE=""
+ local BPO2ARCHIVE=""
+ if [ ! "$7" = "2.0~bpo2" ]; then
+ BPO1ARCHIVE=" $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ backports/main i386 Packages"
+ else
+ BPO2ARCHIVE="
+ 2.0~bpo2 $PB
+ $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ backports/main i386 Packages"
+ SB="$(echo "$SB" | tail -n 1)"
+ shift
+ fi
+ shift 6
+ testequal "coolstuff:
+ Installed: $INSTALLED
+ Candidate: $CANDIDATE
+ ${PINVERSION}Version table:${BPO2ARCHIVE}
+ $IB 2.0~bpo1 $PB
+${BPO1ARCHIVE}$SB
+ $IS 1.0 $PB
+ $(echo "$AS" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ stable/main i386 Packages$SS" \
+ aptcache policy coolstuff -o Policy=${INSTALLED}-${CANDIDATE}-${AB}-${AS}-${PB} $*
+}
+
+testequalpolicycoolstuff "" "2.0~bpo1" 500 500 0 ""
+testequalpolicycoolstuff "" "1.0" 500 990 0 "" -t stable
+testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -t backports
+echo "Package: *
+Pin: release n=backports
+Pin-Priority: 200" > rootdir/etc/apt/preferences
+testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=GlobalPin
+testequalpolicycoolstuff "" "1.0" 200 990 0 "" -o Test=GlobalPin -t stable
+testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=GlobalPin -t backports
+echo "Package: *
+Pin: release n=backports
+Pin-Priority: 600" > rootdir/etc/apt/preferences
+testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=GlobalPin
+testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=GlobalPin -t stable
+echo "Package: coolstuff
+Pin: release n=backports
+Pin-Priority: 200" > rootdir/etc/apt/preferences
+#FIXME: policy can't differentiate between two sources where one has a package specific pin in place
+# testequalpolicycoolstuff "" "1.0" 500 500 200 "2.0~bpo1" -o Test=PackagePin
+# testequalpolicycoolstuff "" "1.0" 990 500 200 "2.0~bpo1" -o Test=PackagePin -t backports
+testequalpolicycoolstuff "" "1.0" 500 990 200 "2.0~bpo1" -o Test=PackagePin -t stable
+echo "Package: coolstuff
+Pin: release n=backports
+Pin-Priority: 600" > rootdir/etc/apt/preferences
+testequalpolicycoolstuff "" "2.0~bpo1" 500 500 600 "2.0~bpo1" -o Test=PackagePin
+testequalpolicycoolstuff "" "1.0" 500 990 600 "2.0~bpo1" -o Test=PackagePin -t stable
+testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=PackagePin -t backports
+
+echo "Package: coolstuff
+Pin: release n=backports
+Pin-Priority: -1" > rootdir/etc/apt/preferences
+# testequalpolicycoolstuff "" "1.0" 500 500 -1 "2.0~bpo1" -o Test=PackagePin
+# testequalpolicycoolstuff "" "1.0" 990 500 -1 "2.0~bpo1" -o Test=PackagePin -t backports
+# testequalpolicycoolstuff "" "1.0" 500 990 -1 "2.0~bpo1" -o Test=PackagePin -t stable
+
+rm rootdir/etc/apt/preferences
+sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
+signreleasefiles
+rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
+aptget update -qq
+
+testequalpolicycoolstuff "" "1.0" 1 500 0 "" -o Test=NotAutomatic
+testequalpolicycoolstuff "" "1.0" 1 990 0 "" -o Test=NotAutomatic -t stable
+testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=NotAutomatic -t backports
+echo "Package: *
+Pin: release n=backports
+Pin-Priority: 200" > rootdir/etc/apt/preferences
+testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=NotAutomatic
+echo "Package: *
+Pin: release n=backports
+Pin-Priority: 600" > rootdir/etc/apt/preferences
+testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=NotAutomatic
+testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=NotAutomatic -t stable
+echo "Package: coolstuff
+Pin: release n=backports
+Pin-Priority: 200" > rootdir/etc/apt/preferences
+testequalpolicycoolstuff "" "1.0" 1 500 200 "2.0~bpo1" -o Test=NotAutomatic
+echo "Package: coolstuff
+Pin: release n=backports
+Pin-Priority: 600" > rootdir/etc/apt/preferences
+testequalpolicycoolstuff "" "2.0~bpo1" 1 500 600 "2.0~bpo1" -o Test=NotAutomatic
+testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=NotAutomatic -t backports
+testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t stable
+
+rm rootdir/etc/apt/preferences
+sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
+signreleasefiles
+rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
+aptget update -qq
+
+testequalpolicycoolstuff "" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
+testequalpolicycoolstuff "" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
+testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
+echo "Package: *
+Pin: release n=backports
+Pin-Priority: 200" > rootdir/etc/apt/preferences
+testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=ButAutomaticUpgrades
+echo "Package: *
+Pin: release n=backports
+Pin-Priority: 600" > rootdir/etc/apt/preferences
+testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=ButAutomaticUpgrades
+testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=ButAutomaticUpgrades -t stable
+echo "Package: coolstuff
+Pin: release n=backports
+Pin-Priority: 200" > rootdir/etc/apt/preferences
+testequalpolicycoolstuff "" "1.0" 100 500 200 "2.0~bpo1" -o Test=ButAutomaticUpgrades
+echo "Package: coolstuff
+Pin: release n=backports
+Pin-Priority: 600" > rootdir/etc/apt/preferences
+testequalpolicycoolstuff "" "2.0~bpo1" 100 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades
+testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t backports
+testequalpolicycoolstuff "" "1.0" 100 990 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t stable
+
+rm rootdir/etc/apt/preferences
+aptget install coolstuff -qq > /dev/null 2> /dev/null
+testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
+aptget dist-upgrade -qq > /dev/null 2> /dev/null
+testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
+testequalpolicycoolstuff "1.0" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
+testequalpolicycoolstuff "1.0" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
+
+aptget install coolstuff -t backports -qq > /dev/null 2> /dev/null
+testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
+aptget dist-upgrade -qq > /dev/null 2> /dev/null
+testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
+testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
+testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
+
+rm incoming/backports.main.pkglist incoming/backports.main.srclist
+buildsimplenativepackage "coolstuff" "all" "2.0~bpo2" "backports"
+setupaptarchive
+
+sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
+signreleasefiles
+rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
+aptget update -qq
+
+testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 0 "" "2.0~bpo2" -o Test=NotAutomatic
+testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 990 0 "" "2.0~bpo2" -o Test=NotAutomatic -t stable
+testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=NotAutomatic -t backports
+
+sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
+signreleasefiles
+rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
+aptget update -qq
+
+testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades
+testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 990 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t stable
+testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t backports