]> git.saurik.com Git - apt.git/blob - test/integration/test-bug-595691-empty-and-broken-archive-files
run update post-invokes even on (partial) failures
[apt.git] / test / integration / test-bug-595691-empty-and-broken-archive-files
1 #!/bin/sh
2 set -e
3
4 TESTDIR="$(readlink -f "$(dirname "$0")")"
5 . "$TESTDIR/framework"
6 setupenvironment
7 configarchitecture "i386"
8
9 buildaptarchive
10 touch aptarchive/Packages
11 setupflataptarchive
12
13 failureupdate() {
14 rm -rf rootdir/var/lib/apt
15 testfailure aptget update --allow-insecure-repositories
16 testsuccess grep "^E: Failed to fetch store:${1} Empty files can't be valid archives$" rootdir/tmp/testfailure.output
17 }
18 successupdate() {
19 rm -rf rootdir/var/lib/apt
20 testwarning aptget update --allow-insecure-repositories
21 }
22
23 createemptyarchive() {
24 find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
25 touch aptarchive/Packages
26 echo -n "" | $COMPRESSOR_CMD > aptarchive/${1}.$COMPRESS
27 find aptarchive -name '*Release*' -delete
28 rm -f aptarchive/Packages
29 }
30
31 createemptyfile() {
32 find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
33 touch aptarchive/Packages aptarchive/${1}.$COMPRESS
34 find aptarchive -name '*Release*' -delete
35 rm -f aptarchive/Packages
36 }
37
38 testoverfile() {
39 local APTARCHIVE="$(readlink -f ./aptarchive)"
40 forcecompressor "$1"
41
42 msgmsg 'archive over file' "Packages.$COMPRESS"
43 createemptyarchive 'Packages'
44 successupdate
45 createemptyfile 'Packages'
46 failureupdate "$(readlink -f rootdir/var/lib/apt/lists/partial/$(echo "$APTARCHIVE" | sed -e 's#/#_#g')_Packages.${COMPRESS})"
47 }
48
49 testoverhttp() {
50 forcecompressor "$1"
51
52 msgmsg 'archive over http' "Packages.$COMPRESS"
53 createemptyarchive 'Packages'
54 successupdate
55 createemptyfile 'Packages'
56 failureupdate "$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:${APTHTTPPORT}_Packages.${COMPRESS})"
57 }
58
59 forallsupportedcompressors testoverfile
60
61 # do the same again with http instead of file
62 changetowebserver
63
64 forallsupportedcompressors testoverhttp