]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-ubuntu-bug-1098738-apt-get-source-md5sum
Use native architecture instead of amd64 for build-dep-purge test
[apt.git] / test / integration / test-ubuntu-bug-1098738-apt-get-source-md5sum
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6
7setupenvironment
8configarchitecture 'native'
9
10cat > aptarchive/Sources <<EOF
11Package: pkg-md5-ok
12Binary: pkg-md5-ok
13Version: 1.0
14Maintainer: Joe Sixpack <joe@example.org>
15Architecture: all
16Files:
17 9604ba9427a280db542279d9ed78400b 3 pkg-md5-ok_1.0.dsc
18 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-ok_1.0.tar.gz
19
20Package: pkg-sha256-ok
21Binary: pkg-sha256-ok
22Version: 1.0
23Maintainer: Joe Sixpack <joe@example.org>
24Architecture: all
25Files:
26 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-ok_1.0.dsc
27 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-ok_1.0.tar.gz
28Checksums-Sha1:
29 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-ok_1.0.dsc
30 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-ok_1.0.tar.gz
31Checksums-Sha256:
32 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-sha256-ok_1.0.dsc
33 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-sha256-ok_1.0.tar.gz
34
35Package: pkg-sha256-bad
36Binary: pkg-sha256-bad
37Version: 1.0
38Maintainer: Joe Sixpack <joe@example.org>
39Architecture: all
40Files:
41 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-bad_1.0.dsc
42 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-bad_1.0.tar.gz
43Checksums-Sha1:
44 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-bad_1.0.dsc
45 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-bad_1.0.tar.gz
46Checksums-Sha256:
47 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-sha256-bad_1.0.dsc
48 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-sha256-bad_1.0.tar.gz
49
50Package: pkg-md5-bad
51Binary: pkg-md5-bad
52Version: 1.0
53Maintainer: Joe Sixpack <joe@example.org>
54Architecture: all
55Files:
56 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-md5-bad_1.0.dsc
57 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-md5-bad_1.0.tar.gz
58
59Package: pkg-no-md5
60Binary: pkg-no-md5
61Version: 1.0
62Maintainer: Joe Sixpack <joe@example.org>
63Architecture: all
64Checksums-Sha1:
65 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-no-md5_1.0.dsc
66 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-no-md5_1.0.tar.gz
67Checksums-Sha256:
68 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-no-md5_1.0.dsc
69 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-no-md5_1.0.tar.gz
70
71Package: pkg-mixed-ok
72Binary: pkg-mixed-ok
73Version: 1.0
74Maintainer: Joe Sixpack <joe@example.org>
75Architecture: all
76Checksums-Sha1:
77 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-mixed-ok_1.0.tar.gz
78Checksums-Sha256:
79 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-mixed-ok_1.0.dsc
80
81Package: pkg-mixed-sha1-bad
82Binary: pkg-mixed-sha1-bad
83Version: 1.0
84Maintainer: Joe Sixpack <joe@example.org>
85Architecture: all
86Checksums-Sha1:
87 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-mixed-sha1-bad_1.0.dsc
88Checksums-Sha256:
89 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-mixed-sha1-bad_1.0.tar.gz
90
91Package: pkg-mixed-sha2-bad
92Binary: pkg-mixed-sha2-bad
93Version: 1.0
94Maintainer: Joe Sixpack <joe@example.org>
95Architecture: all
96Checksums-Sha1:
97 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-mixed-sha2-bad_1.0.dsc
98Checksums-Sha256:
99 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-mixed-sha2-bad_1.0.tar.gz
100
101Package: pkg-md5-disagree
102Binary: pkg-md5-disagree
103Version: 1.0
104Maintainer: Joe Sixpack <joe@example.org>
105Architecture: all
106Files:
107 9604ba9427a280db542279d9ed78400b 3 pkg-md5-disagree_1.0.dsc
108 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-disagree_1.0.tar.gz
109 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-md5-disagree_1.0.dsc
110 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-md5-disagree_1.0.tar.gz
111
112Package: pkg-md5-agree
113Binary: pkg-md5-agree
114Version: 1.0
115Maintainer: Joe Sixpack <joe@example.org>
116Architecture: all
117Files:
118 9604ba9427a280db542279d9ed78400b 3 pkg-md5-agree_1.0.dsc
119 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-agree_1.0.tar.gz
120 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-agree_1.0.tar.gz
121 9604ba9427a280db542279d9ed78400b 3 pkg-md5-agree_1.0.dsc
122
123Package: pkg-sha256-disagree
124Binary: pkg-sha256-disagree
125Version: 1.0
126Maintainer: Joe Sixpack <joe@example.org>
127Architecture: all
128Files:
129 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-disagree_1.0.dsc
130 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-disagree_1.0.tar.gz
131Checksums-Sha1:
132 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-disagree_1.0.dsc
133 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-disagree_1.0.tar.gz
134Checksums-Sha256:
135 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-sha256-disagree_1.0.dsc
136 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-sha256-disagree_1.0.tar.gz
137 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-sha256-disagree_1.0.dsc
138 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-sha256-disagree_1.0.tar.gz
139EOF
140
141# create fetchable files
142for x in 'pkg-md5-ok' 'pkg-sha256-ok' 'pkg-sha256-bad' 'pkg-no-md5' \
143 'pkg-mixed-ok' 'pkg-mixed-sha1-bad' 'pkg-mixed-sha2-bad' \
144 'pkg-md5-agree' 'pkg-md5-disagree' 'pkg-sha256-disagree' \
145 'pkg-md5-bad'; do
146 echo -n 'dsc' > aptarchive/${x}_1.0.dsc
147 echo -n 'tar' > aptarchive/${x}_1.0.tar.gz
148done
149
150setupaptarchive --no-update
151changetowebserver
152testsuccess aptget update
153
154cd downloaded
155
156testok() {
157 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
158 testsuccessequal "Reading package lists...
159Need to get 6 B of source archives.
160Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
161Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
162Download complete and in download only mode" aptget source -d "$@"
163 msgtest 'Files were successfully downloaded for' "$1"
164 testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
165 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
166}
167
168testkeep() {
169 echo -n 'dsc' > ${1}_1.0.dsc
170 echo -n 'tar' > ${1}_1.0.tar.gz
171 testsuccessequal "Reading package lists...
172Skipping already downloaded file '${1}_1.0.dsc'
173Skipping already downloaded file '${1}_1.0.tar.gz'
174Need to get 0 B of source archives.
175Download complete and in download only mode" aptget source -d "$@"
176 msgtest 'Files already downloaded are kept for' "$1"
177 testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
178 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
179}
180
181testnohash() {
182 #FIXME: Maybe we should fail in this case instead of skipping
183 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
184 testsuccessequal "Reading package lists...
185Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication
186Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication
187Need to get 0 B of source archives.
188Download complete and in download only mode" aptget source -d "$@"
189 msgtest 'Files are not downloaded for' "$1"
190 testfailure --nomsg test -e ${1}_1.0.dsc -o -e ${1}_1.0.tar.gz
191}
192
193testmismatch() {
194 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
195 testfailureequal "Reading package lists...
196Need to get 6 B of source archives.
197Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
198Err:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc)
199 Hash Sum mismatch
200Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
201Err:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar)
202 Hash Sum mismatch
203E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.dsc Hash Sum mismatch
204
205E: Failed to fetch http://localhost:${APTHTTPPORT}/${1}_1.0.tar.gz Hash Sum mismatch
206
207E: Failed to fetch some archives." aptget source -d "$@"
208 msgtest 'Files were not download as they have hashsum mismatches for' "$1"
209 testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
210
211 if [ "$2" != '--allow-unauthenticated' ]; then
212 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
213 testsuccessequal "Reading package lists...
214Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication
215Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication
216Need to get 0 B of source archives.
217Download complete and in download only mode" aptget source -d "$@" -o Acquire::ForceHash=ROT26
218 msgtest 'Files were not download as hash is unavailable for' "$1"
219 testfailure --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
220 fi
221
222 rm -f ${1}_1.0.dsc ${1}_1.0.tar.gz
223 testsuccessequal "Reading package lists...
224Need to get 6 B of source archives.
225Get:1 http://localhost:${APTHTTPPORT} $1 1.0 (dsc) [3 B]
226Get:2 http://localhost:${APTHTTPPORT} $1 1.0 (tar) [3 B]
227Download complete and in download only mode" aptget source --allow-unauthenticated -d "$@" -o Acquire::ForceHash=ROT26
228 msgtest 'Files were downloaded unauthenticated as user allowed it' "$1"
229 testsuccess --nomsg test -e ${1}_1.0.dsc -a -e ${1}_1.0.tar.gz
230}
231
232testnohash pkg-md5-ok
233testok pkg-sha256-ok
234testkeep pkg-sha256-ok
235
236# pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is
237# checking the best available hash (as it should), this will trigger
238# a hash mismatch.
239testmismatch pkg-sha256-bad
240testok pkg-sha256-bad -o Acquire::ForceHash=MD5Sum
241
242testnohash pkg-md5-bad
243testmismatch pkg-md5-bad --allow-unauthenticated
244
245# not having MD5 sum doesn't mean the file doesn't exist at all …
246testok pkg-no-md5
247testok pkg-no-md5 -o Acquire::ForceHash=SHA256
248testsuccessequal "Reading package lists...
249Skipping download of file 'pkg-no-md5_1.0.dsc' as requested hashsum is not available for authentication
250Skipping download of file 'pkg-no-md5_1.0.tar.gz' as requested hashsum is not available for authentication
251Need to get 0 B of source archives.
252Download complete and in download only mode" aptget source -d pkg-no-md5 -o Acquire::ForceHash=MD5Sum
253msgtest 'Files were not download as MD5 is not available for this package' 'pkg-no-md5'
254testfailure --nomsg test -e pkg-no-md5_1.0.dsc -a -e pkg-no-md5_1.0.tar.gz
255
256# deal with cases in which we haven't for all files the same checksum type
257# mostly pathologic as this shouldn't happen, but just to be sure
258testok pkg-mixed-ok
259testfailureequal "Reading package lists...
260Need to get 6 B of source archives.
261Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (tar) [3 B]
262Get:2 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (dsc) [3 B]
263Err:2 http://localhost:${APTHTTPPORT} pkg-mixed-sha1-bad 1.0 (dsc)
264 Hash Sum mismatch
265E: Failed to fetch http://localhost:${APTHTTPPORT}/pkg-mixed-sha1-bad_1.0.dsc Hash Sum mismatch
266
267E: Failed to fetch some archives." aptget source -d pkg-mixed-sha1-bad
268msgtest 'Only tar file is downloaded as the dsc has hashsum mismatch' 'pkg-mixed-sha1-bad'
269testsuccess --nomsg test ! -e pkg-mixed-sha1-bad_1.0.dsc -a -e pkg-mixed-sha1-bad_1.0.tar.gz
270testfailureequal "Reading package lists...
271Need to get 6 B of source archives.
272Get:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar) [3 B]
273Err:1 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (tar)
274 Hash Sum mismatch
275Get:2 http://localhost:${APTHTTPPORT} pkg-mixed-sha2-bad 1.0 (dsc) [3 B]
276E: Failed to fetch http://localhost:${APTHTTPPORT}/pkg-mixed-sha2-bad_1.0.tar.gz Hash Sum mismatch
277
278E: Failed to fetch some archives." aptget source -d pkg-mixed-sha2-bad
279msgtest 'Only dsc file is downloaded as the tar has hashsum mismatch' 'pkg-mixed-sha2-bad'
280testsuccess --nomsg test -e pkg-mixed-sha2-bad_1.0.dsc -a ! -e pkg-mixed-sha2-bad_1.0.tar.gz
281
282# it gets even more pathologic: multiple entries for one file, some even disagreeing!
283testnohash pkg-md5-agree
284testfailureequal 'Reading package lists...
285E: Error parsing checksum in Files of source package pkg-md5-disagree' aptget source -d pkg-md5-disagree
286testfailureequal 'Reading package lists...
287E: Error parsing checksum in Checksums-SHA256 of source package pkg-sha256-disagree' aptget source -d pkg-sha256-disagree