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