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 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-no-md5_1.0.dsc
57 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-no-md5_1.0.tar.gz
59 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-no-md5_1.0.dsc
60 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-no-md5_1.0.tar.gz
65 Maintainer: Joe Sixpack <joe@example.org>
68 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-mixed-ok_1.0.tar.gz
70 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-mixed-ok_1.0.dsc
72 Package: pkg-mixed-sha1-bad
73 Binary: pkg-mixed-sha1-bad
75 Maintainer: Joe Sixpack <joe@example.org>
78 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-mixed-sha1-bad_1.0.dsc
80 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-mixed-sha1-bad_1.0.tar.gz
82 Package: pkg-mixed-sha2-bad
83 Binary: pkg-mixed-sha2-bad
85 Maintainer: Joe Sixpack <joe@example.org>
88 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-mixed-sha2-bad_1.0.dsc
90 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-mixed-sha2-bad_1.0.tar.gz
92 Package: pkg-md5-disagree
93 Binary: pkg-md5-disagree
95 Maintainer: Joe Sixpack <joe@example.org>
98 9604ba9427a280db542279d9ed78400b 3 pkg-md5-disagree_1.0.dsc
99 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-disagree_1.0.tar.gz
100 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-md5-disagree_1.0.dsc
101 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-md5-disagree_1.0.tar.gz
103 Package: pkg-md5-agree
104 Binary: pkg-md5-agree
106 Maintainer: Joe Sixpack <joe@example.org>
109 9604ba9427a280db542279d9ed78400b 3 pkg-md5-agree_1.0.dsc
110 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-agree_1.0.tar.gz
111 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-md5-agree_1.0.tar.gz
112 9604ba9427a280db542279d9ed78400b 3 pkg-md5-agree_1.0.dsc
114 Package: pkg-sha256-disagree
115 Binary: pkg-sha256-disagree
117 Maintainer: Joe Sixpack <joe@example.org>
120 9604ba9427a280db542279d9ed78400b 3 pkg-sha256-disagree_1.0.dsc
121 db5570bf61464b46e2bde31ed61a7dc6 3 pkg-sha256-disagree_1.0.tar.gz
123 324f464e6151a92cf57b26ef95dcfcf2059a8c44 3 pkg-sha256-disagree_1.0.dsc
124 680254bad1d7ca0d65ec46aaa315d363abf6a50a 3 pkg-sha256-disagree_1.0.tar.gz
126 943d3bf22ac661fb0f59bc4ff68cc12b04ff17a838dfcc2537008eb9c7f3770a 3 pkg-sha256-disagree_1.0.dsc
127 90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb 3 pkg-sha256-disagree_1.0.tar.gz
128 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 pkg-sha256-disagree_1.0.dsc
129 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3 pkg-sha256-disagree_1.0.tar.gz
132 # create fetchable files
133 for x
in 'pkg-md5-ok' 'pkg-sha256-ok' 'pkg-sha256-bad' 'pkg-no-md5' \
134 'pkg-mixed-ok' 'pkg-mixed-sha1-bad' 'pkg-mixed-sha2-bad' \
135 'pkg-md5-agree' 'pkg-md5-disagree' 'pkg-sha256-disagree'; do
136 echo -n 'dsc' > aptarchive
/${x}_1.0.dsc
137 echo -n 'tar' > aptarchive
/${x}_1.0.
tar.gz
142 testsuccess aptget update
145 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
146 testequal
"Reading package lists...
147 Building dependency tree...
148 Need to get 6 B of source archives.
149 Get:1 http://localhost:8080/ $1 1.0 (dsc) [3 B]
150 Get:2 http://localhost:8080/ $1 1.0 (tar) [3 B]
151 Download complete and in download only mode" aptget
source -d "$@"
152 msgtest
'Files were successfully downloaded for' "$1"
153 testsuccess
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
154 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
158 echo -n 'dsc' > ${1}_1.0.dsc
159 echo -n 'tar' > ${1}_1.0.
tar.gz
160 testequal
"Reading package lists...
161 Building dependency tree...
162 Skipping already downloaded file '${1}_1.0.dsc'
163 Skipping already downloaded file '${1}_1.0.tar.gz'
164 Need to get 0 B of source archives.
165 Download complete and in download only mode" aptget
source -d "$@"
166 msgtest
'Files already downloaded are kept for' "$1"
167 testsuccess
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
168 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
172 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
173 testequal
"Reading package lists...
174 Building dependency tree...
175 Need to get 6 B of source archives.
176 Get:1 http://localhost:8080/ $1 1.0 (dsc) [3 B]
177 Get:2 http://localhost:8080/ $1 1.0 (tar) [3 B]
178 E: Failed to fetch http://localhost:8080/${1}_1.0.dsc Hash Sum mismatch
180 E: Failed to fetch http://localhost:8080/${1}_1.0.tar.gz Hash Sum mismatch
182 E: Failed to fetch some archives." aptget
source -d "$@"
183 msgtest
'Files were not download as they have hashsum mismatches for' "$1"
184 testfailure
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
186 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
187 testequal
"Reading package lists...
188 Building dependency tree...
189 Skipping download of file 'pkg-sha256-bad_1.0.dsc' as requested hashsum is not available for authentication
190 Skipping download of file 'pkg-sha256-bad_1.0.tar.gz' as requested hashsum is not available for authentication
191 Need to get 0 B of source archives.
192 Download complete and in download only mode" aptget
source -d "$@" -o Acquire
::ForceHash
=ROT26
193 msgtest
'Files were not download as hash is unavailable for' "$1"
194 testfailure
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
196 rm -f ${1}_1.0.dsc
${1}_1.0.
tar.gz
197 testequal
"Reading package lists...
198 Building dependency tree...
199 Need to get 6 B of source archives.
200 Get:1 http://localhost:8080/ $1 1.0 (dsc) [3 B]
201 Get:2 http://localhost:8080/ $1 1.0 (tar) [3 B]
202 Download complete and in download only mode" aptget
source --allow-unauthenticated -d "$@" -o Acquire
::ForceHash
=ROT26
203 msgtest
'Files were downloaded unauthenticated as user allowed it' "$1"
204 testsuccess
--nomsg test -e ${1}_1.0.dsc
-a -e ${1}_1.0.
tar.gz
210 testkeep pkg
-sha256-ok
212 # pkg-sha256-bad has a bad SHA sum, but good MD5 sum. If apt is
213 # checking the best available hash (as it should), this will trigger
215 testmismatch pkg
-sha256-bad
216 testmismatch pkg
-sha256-bad
217 testok pkg
-sha256-bad -o Acquire
::ForceHash
=MD5Sum
219 # not having MD5 sum doesn't mean the file doesn't exist at all …
221 testok pkg
-no-md5 -o Acquire
::ForceHash
=SHA256
222 testequal
"Reading package lists...
223 Building dependency tree...
224 Skipping download of file 'pkg-no-md5_1.0.dsc' as requested hashsum is not available for authentication
225 Skipping download of file 'pkg-no-md5_1.0.tar.gz' as requested hashsum is not available for authentication
226 Need to get 0 B of source archives.
227 Download complete and in download only mode" aptget
source -d pkg
-no-md5 -o Acquire
::ForceHash
=MD5Sum
228 msgtest
'Files were not download as MD5 is not available for this package' 'pkg-no-md5'
229 testfailure
--nomsg test -e pkg
-no-md5_1.0.dsc
-a -e pkg
-no-md5_1.0.
tar.gz
231 # deal with cases in which we haven't for all files the same checksum type
232 # mostly pathologic as this shouldn't happen, but just to be sure
234 testequal
'Reading package lists...
235 Building dependency tree...
236 Need to get 6 B of source archives.
237 Get:1 http://localhost:8080/ pkg-mixed-sha1-bad 1.0 (tar) [3 B]
238 Get:2 http://localhost:8080/ pkg-mixed-sha1-bad 1.0 (dsc) [3 B]
239 E: Failed to fetch http://localhost:8080/pkg-mixed-sha1-bad_1.0.dsc Hash Sum mismatch
241 E: Failed to fetch some archives.' aptget
source -d pkg
-mixed-sha1-bad
242 msgtest
'Only tar file is downloaded as the dsc has hashsum mismatch' 'pkg-mixed-sha1-bad'
243 testsuccess
--nomsg test ! -e pkg
-mixed-sha1-bad_1.0.dsc
-a -e pkg
-mixed-sha1-bad_1.0.
tar.gz
244 testequal
'Reading package lists...
245 Building dependency tree...
246 Need to get 6 B of source archives.
247 Get:1 http://localhost:8080/ pkg-mixed-sha2-bad 1.0 (tar) [3 B]
248 Get:2 http://localhost:8080/ pkg-mixed-sha2-bad 1.0 (dsc) [3 B]
249 E: Failed to fetch http://localhost:8080/pkg-mixed-sha2-bad_1.0.tar.gz Hash Sum mismatch
251 E: Failed to fetch some archives.' aptget
source -d pkg
-mixed-sha2-bad
252 msgtest
'Only dsc file is downloaded as the tar has hashsum mismatch' 'pkg-mixed-sha2-bad'
253 testsuccess
--nomsg test -e pkg
-mixed-sha2-bad_1.0.dsc
-a ! -e pkg
-mixed-sha2-bad_1.0.
tar.gz
255 # it gets even more pathologic: multiple entries for one file, some even disagreeing!
257 testequal
'Reading package lists...
258 Building dependency tree...
259 E: Error parsing checksum in Files of source package pkg-md5-disagree' aptget
source -d pkg
-md5-disagree
260 testequal
'Reading package lists...
261 Building dependency tree...
262 E: Error parsing checksum in Checksums-SHA256 of source package pkg-sha256-disagree' aptget
source -d pkg
-sha256-disagree