]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-update-ims
do delay the test for http, too, to make it more reliable
[apt.git] / test / integration / test-apt-update-ims
1 #!/bin/sh
2 set -e
3
4 TESTDIR=$(readlink -f $(dirname $0))
5 . $TESTDIR/framework
6 setupenvironment
7 configarchitecture 'amd64'
8
9 insertpackage 'unstable' 'unrelated' 'all' '0.5~squeeze1'
10 insertsource 'unstable' 'unrelated' 'all' '0.5~squeeze1'
11
12 setupaptarchive --no-update
13 changetowebserver
14
15 runtest() {
16 if [ -n "$1" ]; then
17 configallowinsecurerepositories 'true'
18 else
19 configallowinsecurerepositories 'false'
20 fi
21
22 rm -rf rootdir/var/lib/apt/lists/
23
24 local TEST="test${1:-success}"
25 $TEST aptget update
26 if [ "$1" = 'failure' ]; then
27 # accept the outdated Release file so we can check Hit behaviour
28 "test${2:-success}" aptget update -o Acquire::Min-ValidTime=99999999999
29 fi
30 listcurrentlistsdirectory > listsdir.lst
31 testsuccess grep '_Packages\(\.gz\)\?$' listsdir.lst
32 testsuccess grep '_Sources\(\.gz\)\?$' listsdir.lst
33 testsuccess grep '_Translation-en\(\.gz\)\?$' listsdir.lst
34
35 # ensure no leftovers in partial
36 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
37
38 # check that I-M-S header is kept in redirections
39 echo "$EXPECT" | sed -e 's#(invalid since [^)]\+)#(invalid since)#' > expected.output
40 $TEST aptget update -o Debug::pkgAcquire::Worker=0 -o Debug::Acquire::http=0
41 sed -i -e 's#(invalid since [^)]\+)#(invalid since)#' rootdir/tmp/${TEST}.output
42 testequal "$(cat expected.output)" cat rootdir/tmp/${TEST}.output
43 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
44
45 # ensure that we still do a hash check for other files on ims hit of Release
46 if grep -q '^Hit:[0-9]\+ .* InRelease$' expected.output || ! grep -q '^Ign:[0-9]\+ .* Release\(\.gpg\)\?$' expected.output; then
47 $TEST aptget update -o Debug::Acquire::gpgv=1
48 cp rootdir/tmp/${TEST}.output goodsign.output
49 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
50 testsuccess grep '^Got GOODSIG, key ID:GOODSIG' goodsign.output
51 fi
52
53 # ensure no leftovers in partial
54 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
55 }
56
57 msgmsg 'InRelease'
58 EXPECT='Hit:1 http://localhost:8080 unstable InRelease
59 Reading package lists...'
60 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
61 runtest
62 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
63 runtest
64
65 msgmsg 'Release/Release.gpg'
66 EXPECT='Ign:1 http://localhost:8080 unstable InRelease
67 404 Not Found
68 Hit:2 http://localhost:8080 unstable Release
69 Reading package lists...'
70 find aptarchive -name 'InRelease' -delete
71 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
72 runtest
73 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
74 runtest
75
76 msgmsg 'Release only'
77 EXPECT="Ign:1 http://localhost:8080 unstable InRelease
78 404 Not Found
79 Hit:2 http://localhost:8080 unstable Release
80 Ign:3 http://localhost:8080 unstable Release.gpg
81 404 Not Found
82 Reading package lists...
83 W: The data from 'http://localhost:8080 unstable Release' is not signed. Packages from that repository can not be authenticated."
84 find aptarchive -name 'Release.gpg' -delete
85 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
86 runtest 'warning'
87 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
88 runtest 'warning'
89
90
91 # make the release file old
92 find aptarchive -name '*Release' -exec sed -i \
93 -e "s#^Date: .*\$#Date: $(date -d '-2 weeks' '+%a, %d %b %Y %H:%M:%S %Z')#" \
94 -e '/^Valid-Until: / d' -e "/^Date: / a\
95 Valid-Until: $(date -d '-1 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" '{}' \;
96 signreleasefiles
97
98 msgmsg 'expired InRelease'
99 EXPECT='Hit:1 http://localhost:8080 unstable InRelease
100 E: Release file for http://localhost:8080/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied.'
101 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
102 runtest 'failure'
103 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
104 runtest 'failure'
105
106 msgmsg 'expired Release/Release.gpg'
107 EXPECT='Ign:1 http://localhost:8080 unstable InRelease
108 404 Not Found
109 Hit:2 http://localhost:8080 unstable Release
110 E: Release file for http://localhost:8080/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied.'
111 find aptarchive -name 'InRelease' -delete
112 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
113 runtest 'failure'
114 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
115 runtest 'failure'
116
117 msgmsg 'expired Release only'
118 EXPECT="Ign:1 http://localhost:8080 unstable InRelease
119 404 Not Found
120 Hit:2 http://localhost:8080 unstable Release
121 Ign:3 http://localhost:8080 unstable Release.gpg
122 404 Not Found
123 W: The data from 'http://localhost:8080 unstable Release' is not signed. Packages from that repository can not be authenticated.
124 E: Release file for http://localhost:8080/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
125 find aptarchive -name 'Release.gpg' -delete
126 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
127 runtest 'failure' 'warning'
128 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
129 runtest 'failure' 'warning'
130
131
132 msgmsg 'no Release at all'
133 EXPECT="Ign:1 http://localhost:8080 unstable InRelease
134 404 Not Found
135 Ign:2 http://localhost:8080 unstable Release
136 404 Not Found
137 Ign:3 http://localhost:8080 unstable/main Sources
138 404 Not Found
139 Ign:4 http://localhost:8080 unstable/main amd64 Packages
140 404 Not Found
141 Ign:5 http://localhost:8080 unstable/main Translation-en
142 404 Not Found
143 Ign:3 http://localhost:8080 unstable/main Sources
144 404 Not Found
145 Ign:4 http://localhost:8080 unstable/main amd64 Packages
146 404 Not Found
147 Ign:5 http://localhost:8080 unstable/main Translation-en
148 404 Not Found
149 Ign:3 http://localhost:8080 unstable/main Sources
150 404 Not Found
151 Ign:4 http://localhost:8080 unstable/main amd64 Packages
152 404 Not Found
153 Ign:5 http://localhost:8080 unstable/main Translation-en
154 404 Not Found
155 Hit:3 http://localhost:8080 unstable/main Sources
156 Hit:4 http://localhost:8080 unstable/main amd64 Packages
157 Hit:5 http://localhost:8080 unstable/main Translation-en
158 Reading package lists...
159 W: The repository 'http://localhost:8080 unstable Release' does not have a Release file. This is deprecated, please contact the owner of the repository."
160 find aptarchive -name '*Release*' -delete
161 echo 'Acquire::GzipIndexes "0";
162 Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
163 runtest 'warning'
164 echo 'Acquire::GzipIndexes "1";
165 Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
166 runtest 'warning'