]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-apt-update-ims
test-apt-cdrom: Fix for gnupg 2.1.15
[apt.git] / test / integration / test-apt-update-ims
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6setupenvironment
7configarchitecture 'amd64'
8
9insertpackage 'unstable' 'unrelated' 'all' '0.5~squeeze1'
10insertpackage 'unstable' 'unrelated2' 'amd64' '0.5~squeeze1'
11insertsource 'unstable' 'unrelated' 'all' '0.5~squeeze1'
12
13export APT_DONT_SIGN=""
14setupaptarchive --no-update
15logcurrentarchivedirectory
16changetowebserver
17
18runtest() {
19 local APTOPT=""
20 if [ -n "$1" ]; then
21 APTOPT='--allow-insecure-repositories'
22 else
23 APTOPT='--no-allow-insecure-repositories'
24 fi
25
26 rm -rf rootdir/var/lib/apt/lists/
27
28 local TEST="test${1:-success}"
29 $TEST aptget update $APTOPT -o Debug::pkgAcquire::Worker=1
30 if [ "$1" = 'failure' ]; then
31 # accept the outdated Release file so we can check Hit behaviour
32 "test${2:-success}" aptget update -o Acquire::Min-ValidTime=9999999 $APTOPT
33 fi
34 listcurrentlistsdirectory > listsdir.lst
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
38
39 # ensure no leftovers in partial
40 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
41
42 # check that I-M-S header is kept in redirections
43 echo "$EXPECT" | sed -e 's#(invalid since [^)]\+)#(invalid since)#' > expected.output
44 $TEST aptget update -o Debug::pkgAcquire::Worker=0 -o Debug::Acquire::http=0 $APTOPT
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
50 if grep -q '^Hit:[0-9]\+ .* InRelease$' expected.output || ! grep -q '^Ign:[0-9]\+ .* Release\(\.gpg\)\?$' expected.output; then
51 $TEST aptget update -o Debug::Acquire::gpgv=1 $APTOPT
52 cp rootdir/tmp/${TEST}.output goodsign.output
53 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
54 testsuccess grep '^Got GOODSIG ' goodsign.output
55 fi
56
57 # ensure no leftovers in partial
58 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
59}
60
61msgmsg 'InRelease'
62EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
63Reading package lists..."
64echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
65runtest
66echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
67runtest
68
69msgmsg 'Release/Release.gpg'
70EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
71 404 Not Found
72Hit:2 http://localhost:${APTHTTPPORT} unstable Release
73Reading package lists..."
74find aptarchive -name 'InRelease' -delete
75logcurrentarchivedirectory
76echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
77runtest
78echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
79runtest
80
81msgmsg 'Release only'
82EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
83 404 Not Found
84Hit:2 http://localhost:${APTHTTPPORT} unstable Release
85Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
86 404 Not Found
87Reading package lists...
88W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
89N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
90N: See apt-secure(8) manpage for repository creation and user configuration details."
91find aptarchive -name 'Release.gpg' -delete
92logcurrentarchivedirectory
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 \
101 -e "s#^Date: .*\$#Date: $(date -ud '-2 weeks' '+%a, %d %b %Y %H:%M:%S %Z')#" \
102 -e '/^Valid-Until: / d' -e "/^Date: / a\
103Valid-Until: $(date -ud '-1 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" '{}' \;
104signreleasefiles
105logcurrentarchivedirectory
106
107msgmsg 'expired InRelease'
108EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
109Reading package lists...
110E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied."
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'
117EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
118 404 Not Found
119Hit:2 http://localhost:${APTHTTPPORT} unstable Release
120Reading package lists...
121E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
122find aptarchive -name 'InRelease' -delete
123logcurrentarchivedirectory
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'
128
129msgmsg 'expired Release only'
130EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
131 404 Not Found
132Hit:2 http://localhost:${APTHTTPPORT} unstable Release
133Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
134 404 Not Found
135Reading package lists...
136W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
137N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
138N: See apt-secure(8) manpage for repository creation and user configuration details.
139E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
140find aptarchive -name 'Release.gpg' -delete
141logcurrentarchivedirectory
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'
146
147
148msgmsg 'no Release at all'
149EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
150 404 Not Found
151Ign:2 http://localhost:${APTHTTPPORT} unstable Release
152 404 Not Found
153Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
154 404 Not Found
155Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
156 404 Not Found
157Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
158 404 Not Found
159Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
160 404 Not Found
161Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
162 404 Not Found
163Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
164 404 Not Found
165Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
166 404 Not Found
167Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
168 404 Not Found
169Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
170 404 Not Found
171Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
172 404 Not Found
173Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
174 404 Not Found
175Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
176 404 Not Found
177Hit:3 http://localhost:${APTHTTPPORT} unstable/main Sources
178Hit:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
179Hit:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
180Hit:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
181Reading package lists...
182W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' does not have a Release file.
183N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
184N: See apt-secure(8) manpage for repository creation and user configuration details."
185find aptarchive -name '*Release*' -delete
186logcurrentarchivedirectory
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'