]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-update-ims
test: Use a file to determine TEST_DEFAULT_GROUP
[apt.git] / test / integration / test-apt-update-ims
CommitLineData
63d0f853
MV
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
63d0f853
MV
6setupenvironment
7configarchitecture 'amd64'
8
ba6b79bd 9insertpackage 'unstable' 'unrelated' 'all' '0.5~squeeze1'
1dd20368 10insertpackage 'unstable' 'unrelated2' 'amd64' '0.5~squeeze1'
ba6b79bd 11insertsource 'unstable' 'unrelated' 'all' '0.5~squeeze1'
63d0f853 12
5a23c56d 13export APT_DONT_SIGN=""
846bc058 14setupaptarchive --no-update
34651385 15logcurrentarchivedirectory
63d0f853
MV
16changetowebserver
17
47450dea 18runtest() {
995a4bf6 19 local APTOPT=""
ba6b79bd 20 if [ -n "$1" ]; then
995a4bf6 21 APTOPT='--allow-insecure-repositories'
ba6b79bd 22 else
995a4bf6 23 APTOPT='--no-allow-insecure-repositories'
ba6b79bd 24 fi
4fa34122 25
ba6b79bd 26 rm -rf rootdir/var/lib/apt/lists/
63d0f853 27
ba6b79bd 28 local TEST="test${1:-success}"
0179cfa8 29 $TEST aptget update $APTOPT -o Debug::pkgAcquire::Worker=1
ba6b79bd
DK
30 if [ "$1" = 'failure' ]; then
31 # accept the outdated Release file so we can check Hit behaviour
995a4bf6 32 "test${2:-success}" aptget update -o Acquire::Min-ValidTime=9999999 $APTOPT
4fa34122 33 fi
ba6b79bd 34 listcurrentlistsdirectory > listsdir.lst
0179cfa8
DK
35 testsuccess grep '_Packages\(\.[0-9a-z]\+\)\?$' listsdir.lst
36 testsuccess grep '_Sources\(\.[0-9a-z]\+\)\?$' listsdir.lst
37 testsuccess grep '_Translation-en\(\.[0-9a-z]\+\)\?$' listsdir.lst
47450dea
MV
38
39 # ensure no leftovers in partial
ba6b79bd 40 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
47450dea
MV
41
42 # check that I-M-S header is kept in redirections
ba6b79bd 43 echo "$EXPECT" | sed -e 's#(invalid since [^)]\+)#(invalid since)#' > expected.output
87d6947d 44 $TEST aptget update -o Debug::pkgAcquire::Worker=0 -o Debug::Acquire::http=0 $APTOPT
ba6b79bd
DK
45 sed -i -e 's#(invalid since [^)]\+)#(invalid since)#' rootdir/tmp/${TEST}.output
46 testequal "$(cat expected.output)" cat rootdir/tmp/${TEST}.output
47 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
48
49 # ensure that we still do a hash check for other files on ims hit of Release
1eb1836f 50 if grep -q '^Hit:[0-9]\+ .* InRelease$' expected.output || ! grep -q '^Ign:[0-9]\+ .* Release\(\.gpg\)\?$' expected.output; then
995a4bf6 51 $TEST aptget update -o Debug::Acquire::gpgv=1 $APTOPT
ba6b79bd
DK
52 cp rootdir/tmp/${TEST}.output goodsign.output
53 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
5419a6ce 54 testsuccess grep '^Got GOODSIG ' goodsign.output
ba6b79bd 55 fi
47450dea
MV
56
57 # ensure no leftovers in partial
ba6b79bd 58 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
47450dea
MV
59}
60
ba6b79bd 61msgmsg 'InRelease'
6c0765c0
DK
62EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
63Reading package lists..."
ba6b79bd 64echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
1ce24318 65runtest
ba6b79bd 66echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
1ce24318
MV
67runtest
68
ba6b79bd 69msgmsg 'Release/Release.gpg'
6c0765c0 70EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
4dbfe436 71 404 Not Found
6c0765c0
DK
72Hit:2 http://localhost:${APTHTTPPORT} unstable Release
73Reading package lists..."
ab25bf1f 74find aptarchive -name 'InRelease' -delete
34651385 75logcurrentarchivedirectory
ba6b79bd 76echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
47450dea 77runtest
ba6b79bd 78echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
47450dea 79runtest
f3097647 80
ba6b79bd 81msgmsg 'Release only'
6c0765c0 82EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
4dbfe436 83 404 Not Found
6c0765c0
DK
84Hit:2 http://localhost:${APTHTTPPORT} unstable Release
85Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
4dbfe436 86 404 Not Found
9d653a6d 87Reading package lists...
f18f2338 88W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
d04e44ac 89N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
002b1bc4 90N: See apt-secure(8) manpage for repository creation and user configuration details."
ba6b79bd 91find aptarchive -name 'Release.gpg' -delete
34651385 92logcurrentarchivedirectory
ba6b79bd
DK
93echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
94runtest 'warning'
95echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
96runtest 'warning'
97
98
99# make the release file old
100find aptarchive -name '*Release' -exec sed -i \
9febc2b2 101 -e "s#^Date: .*\$#Date: $(date -ud '-2 weeks' '+%a, %d %b %Y %H:%M:%S %Z')#" \
ba6b79bd 102 -e '/^Valid-Until: / d' -e "/^Date: / a\
9febc2b2 103Valid-Until: $(date -ud '-1 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" '{}' \;
ba6b79bd 104signreleasefiles
34651385 105logcurrentarchivedirectory
ba6b79bd
DK
106
107msgmsg 'expired InRelease'
6c0765c0 108EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
95278287 109Reading package lists...
6c0765c0 110E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied."
ba6b79bd
DK
111echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
112runtest 'failure'
113echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
114runtest 'failure'
115
116msgmsg 'expired Release/Release.gpg'
6c0765c0 117EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
ba6b79bd 118 404 Not Found
6c0765c0 119Hit:2 http://localhost:${APTHTTPPORT} unstable Release
95278287 120Reading package lists...
6c0765c0 121E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
ba6b79bd 122find aptarchive -name 'InRelease' -delete
34651385 123logcurrentarchivedirectory
ba6b79bd
DK
124echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
125runtest 'failure'
126echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
127runtest 'failure'
f3097647 128
ba6b79bd 129msgmsg 'expired Release only'
6c0765c0 130EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
ba6b79bd 131 404 Not Found
6c0765c0
DK
132Hit:2 http://localhost:${APTHTTPPORT} unstable Release
133Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
ba6b79bd 134 404 Not Found
95278287 135Reading package lists...
f18f2338 136W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
d04e44ac 137N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
002b1bc4 138N: See apt-secure(8) manpage for repository creation and user configuration details.
6c0765c0 139E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
ab25bf1f 140find aptarchive -name 'Release.gpg' -delete
34651385 141logcurrentarchivedirectory
ba6b79bd
DK
142echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
143runtest 'failure' 'warning'
144echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
145runtest 'failure' 'warning'
f3097647 146
f3097647 147
ba6b79bd 148msgmsg 'no Release at all'
6c0765c0 149EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
ba6b79bd 150 404 Not Found
6c0765c0 151Ign:2 http://localhost:${APTHTTPPORT} unstable Release
ba6b79bd 152 404 Not Found
6c0765c0 153Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
9d2a8a73 154 404 Not Found
6c0765c0 155Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
9d2a8a73 156 404 Not Found
1dd20368
DK
157Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
158 404 Not Found
159Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
9d2a8a73 160 404 Not Found
6c0765c0 161Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
9d2a8a73 162 404 Not Found
6c0765c0 163Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
9d2a8a73 164 404 Not Found
1dd20368
DK
165Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
166 404 Not Found
167Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
9d2a8a73 168 404 Not Found
6c0765c0 169Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
9d2a8a73 170 404 Not Found
6c0765c0 171Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
9d2a8a73 172 404 Not Found
1dd20368
DK
173Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
174 404 Not Found
175Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
9d2a8a73 176 404 Not Found
6c0765c0
DK
177Hit:3 http://localhost:${APTHTTPPORT} unstable/main Sources
178Hit:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
1dd20368
DK
179Hit:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
180Hit:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
ba6b79bd 181Reading package lists...
f18f2338 182W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' does not have a Release file.
d04e44ac 183N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
002b1bc4 184N: See apt-secure(8) manpage for repository creation and user configuration details."
ba6b79bd 185find aptarchive -name '*Release*' -delete
34651385 186logcurrentarchivedirectory
ba6b79bd
DK
187echo 'Acquire::GzipIndexes "0";
188Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
189runtest 'warning'
190echo 'Acquire::GzipIndexes "1";
191Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
192runtest 'warning'