4 TESTDIR
=$(readlink -f $(dirname $0))
8 configarchitecture
'native'
10 cat > aptarchive
/Sources
<<EOF
14 Maintainer: Joe Sixpack <joe@example.org>
17 9604ba9427a280db542279d9ed78400b 3 pkg-md5-ok_1.0.dsc
18 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-ok_1.0.tar.gz
20 Package: pkg-sha256-ok
23 Maintainer: Joe Sixpack <joe@example.org>
26 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-ok_1.0.dsc
27 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-ok_1.0.tar.gz
29 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-ok_1.0.dsc
30 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-ok_1.0.tar.gz
32 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-sha256-ok_1.0.dsc
33 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-sha256-ok_1.0.tar.gz
35 Package: pkg-sha256-bad
36 Binary: pkg-sha256-bad
38 Maintainer: Joe Sixpack <joe@example.org>
41 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-bad_1.0.dsc
42 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-bad_1.0.tar.gz
44 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-bad_1.0.dsc
45 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-bad_1.0.tar.gz
47 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-sha256-bad_1.0.dsc
48 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-sha256-bad_1.0.tar.gz
53 Maintainer: Joe Sixpack <joe@example.org>
56 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-md5-bad_1.0.dsc
57 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-md5-bad_1.0.tar.gz
62 Maintainer: Joe Sixpack <joe@example.org>
65 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-no-md5_1.0.dsc
66 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-no-md5_1.0.tar.gz
68 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-no-md5_1.0.dsc
69 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-no-md5_1.0.tar.gz
74 Maintainer: Joe Sixpack <joe@example.org>
77 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-mixed-ok_1.0.tar.gz
79 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-mixed-ok_1.0.dsc
81 Package: pkg-mixed-sha1-bad
82 Binary: pkg-mixed-sha1-bad
84 Maintainer: Joe Sixpack <joe@example.org>
87 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-mixed-sha1-bad_1.0.dsc
89 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-mixed-sha1-bad_1.0.tar.gz
91 Package: pkg-mixed-sha2-bad
92 Binary: pkg-mixed-sha2-bad
94 Maintainer: Joe Sixpack <joe@example.org>
97 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-mixed-sha2-bad_1.0.dsc
99 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-mixed-sha2-bad_1.0.tar.gz
101 Package: pkg-md5-disagree
102 Binary: pkg-md5-disagree
104 Maintainer: Joe Sixpack <joe@example.org>
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
112 Package: pkg-md5-agree
113 Binary: pkg-md5-agree
115 Maintainer: Joe Sixpack <joe@example.org>
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
123 Package: pkg-sha256-disagree
124 Binary: pkg-sha256-disagree
126 Maintainer: Joe Sixpack <joe@example.org>
129 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-disagree_1.0.dsc
130 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-disagree_1.0.tar.gz
132 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-disagree_1.0.dsc
133 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-disagree_1.0.tar.gz
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
141 # create fetchable files
142 for 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' \
146 echo -n 'dsc' > aptarchive
/${x}_1.0.dsc
147 echo -n 'tar' > aptarchive
/${x}_1.0.
tar.gz
150 setupaptarchive
--no-update
152 testsuccess aptget update
157 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
158 testsuccessequal
"Reading package lists...
159 Building dependency tree...
160 Need to get 6 B of source archives.
161 Get:1 http://localhost:8080 $1 1.0 (dsc) [3 B]
162 Get:2 http://localhost:8080 $1 1.0 (tar) [3 B]
163 Download complete and in download only mode" aptget
source -d "$@"
164 msgtest
'Files were successfully downloaded for' "$1"
165 testsuccess
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
166 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
170 echo -n 'dsc' > ${1}_1.0.dsc
171 echo -n 'tar' > ${1}_1.0.
tar.gz
172 testsuccessequal
"Reading package lists...
173 Building dependency tree...
174 Skipping already downloaded file '${1}_1.0.dsc'
175 Skipping already downloaded file '${1}_1.0.tar.gz'
176 Need to get 0 B of source archives.
177 Download complete and in download only mode" aptget
source -d "$@"
178 msgtest
'Files already downloaded are kept for' "$1"
179 testsuccess
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
180 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
184 #FIXME: Maybe we should fail in this case instead of skipping
185 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
186 testsuccessequal
"Reading package lists...
187 Building dependency tree...
188 Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication
189 Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication
190 Need to get 0 B of source archives.
191 Download complete and in download only mode" aptget
source -d "$@"
192 msgtest
'Files are not downloaded for' "$1"
193 testfailure
--nomsg test -e ${1}_1.0.dsc
-o -e ${1}_1.0.
tar.gz
197 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
198 testfailureequal
"Reading package lists...
199 Building dependency tree...
200 Need to get 6 B of source archives.
201 Get:1 http://localhost:8080 $1 1.0 (dsc) [3 B]
202 Err:1 http://localhost:8080 $1 1.0 (dsc)
204 Get:2 http://localhost:8080 $1 1.0 (tar) [3 B]
205 Err:2 http://localhost:8080 $1 1.0 (tar)
207 E: Failed to fetch http://localhost:8080/${1}_1.0.dsc Hash Sum mismatch
209 E: Failed to fetch http://localhost:8080/${1}_1.0.tar.gz Hash Sum mismatch
211 E: Failed to fetch some archives." aptget
source -d "$@"
212 msgtest
'Files were not download as they have hashsum mismatches for' "$1"
213 testfailure
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
215 if [ "$2" != '--allow-unauthenticated' ]; then
216 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
217 testsuccessequal
"Reading package lists...
218 Building dependency tree...
219 Skipping download of file '${1}_1.0.dsc' as requested hashsum is not available for authentication
220 Skipping download of file '${1}_1.0.tar.gz' as requested hashsum is not available for authentication
221 Need to get 0 B of source archives.
222 Download complete and in download only mode" aptget
source -d "$@" -o Acquire
::ForceHash
=ROT26
223 msgtest
'Files were not download as hash is unavailable for' "$1"
224 testfailure
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
227 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
228 testsuccessequal
"Reading package lists...
229 Building dependency tree...
230 Need to get 6 B of source archives.
231 Get:1 http://localhost:8080 $1 1.0 (dsc) [3 B]
232 Get:2 http://localhost:8080 $1 1.0 (tar) [3 B]
233 Download complete and in download only mode" aptget
source --allow-unauthenticated -d "$@" -o Acquire
::ForceHash
=ROT26
234 msgtest
'Files were downloaded unauthenticated as user allowed it' "$1"
235 testsuccess
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
238 testnohash pkg
-md5-ok
240 testkeep pkg
-sha256-ok
242 # pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is
243 # checking the best available hash (as it should), this will trigger
245 testmismatch pkg
-sha256-bad
246 testok pkg
-sha256-bad -o Acquire
::ForceHash
=MD5Sum
248 testnohash pkg
-md5-bad
249 testmismatch pkg
-md5-bad --allow-unauthenticated
251 # not having MD5 sum doesn't mean the file doesn't exist at all …
253 testok pkg
-no-md5 -o Acquire
::ForceHash
=SHA256
254 testsuccessequal
"Reading package lists...
255 Building dependency tree...
256 Skipping download of file 'pkg-no-md5_1.0.dsc' as requested hashsum is not available for authentication
257 Skipping download of file 'pkg-no-md5_1.0.tar.gz' as requested hashsum is not available for authentication
258 Need to get 0 B of source archives.
259 Download complete and in download only mode" aptget
source -d pkg
-no-md5 -o Acquire
::ForceHash
=MD5Sum
260 msgtest
'Files were not download as MD5 is not available for this package' 'pkg-no-md5'
261 testfailure
--nomsg test -e pkg
-no-md5_1.0.dsc
-a -e pkg
-no-md5_1.0.
tar.gz
263 # deal with cases in which we haven't for all files the same checksum type
264 # mostly pathologic as this shouldn't happen, but just to be sure
266 testfailureequal
'Reading package lists...
267 Building dependency tree...
268 Need to get 6 B of source archives.
269 Get:1 http://localhost:8080 pkg-mixed-sha1-bad 1.0 (tar) [3 B]
270 Get:2 http://localhost:8080 pkg-mixed-sha1-bad 1.0 (dsc) [3 B]
271 Err:2 http://localhost:8080 pkg-mixed-sha1-bad 1.0 (dsc)
273 E: Failed to fetch http://localhost:8080/pkg-mixed-sha1-bad_1.0.dsc Hash Sum mismatch
275 E: Failed to fetch some archives.' aptget
source -d pkg
-mixed-sha1-bad
276 msgtest
'Only tar file is downloaded as the dsc has hashsum mismatch' 'pkg-mixed-sha1-bad'
277 testsuccess
--nomsg test ! -e pkg
-mixed-sha1-bad_1.0.dsc
-a -e pkg
-mixed-sha1-bad_1.0.
tar.gz
278 testfailureequal
'Reading package lists...
279 Building dependency tree...
280 Need to get 6 B of source archives.
281 Get:1 http://localhost:8080 pkg-mixed-sha2-bad 1.0 (tar) [3 B]
282 Err:1 http://localhost:8080 pkg-mixed-sha2-bad 1.0 (tar)
284 Get:2 http://localhost:8080 pkg-mixed-sha2-bad 1.0 (dsc) [3 B]
285 E: Failed to fetch http://localhost:8080/pkg-mixed-sha2-bad_1.0.tar.gz Hash Sum mismatch
287 E: Failed to fetch some archives.' aptget
source -d pkg
-mixed-sha2-bad
288 msgtest
'Only dsc file is downloaded as the tar has hashsum mismatch' 'pkg-mixed-sha2-bad'
289 testsuccess
--nomsg test -e pkg
-mixed-sha2-bad_1.0.dsc
-a ! -e pkg
-mixed-sha2-bad_1.0.
tar.gz
291 # it gets even more pathologic: multiple entries for one file, some even disagreeing!
292 testnohash pkg
-md5-agree
293 testfailureequal
'Reading package lists...
294 Building dependency tree...
295 E: Error parsing checksum in Files of source package pkg-md5-disagree' aptget
source -d pkg
-md5-disagree
296 testfailureequal
'Reading package lists...
297 Building dependency tree...
298 E: Error parsing checksum in Checksums-SHA256 of source package pkg-sha256-disagree' aptget
source -d pkg
-sha256-disagree