]> git.saurik.com Git - apt.git/blame - test/integration/test-bug-595691-empty-and-broken-archive-files
merged lp:~mvo/apt/apt-get-changelog
[apt.git] / test / integration / test-bug-595691-empty-and-broken-archive-files
CommitLineData
6874a1a8
DK
1#!/bin/sh
2set -e
3
9962ae93 4TESTDIR=$(readlink -f $(dirname $0))
6874a1a8
DK
5. $TESTDIR/framework
6setupenvironment
7configarchitecture "i386"
8
9buildaptarchive
10setupflataptarchive
11
12testaptgetupdate() {
4260fd39 13 rm -rf rootdir/var/lib/apt rootdir/var/cache/apt
6874a1a8 14 aptget update 2>> testaptgetupdate.diff >> testaptgetupdate.diff || true
1054d76b 15 sed -i -e '/^Fetched / d' -e 's#\[[0-9]* [kMGTPY]*B\]#\[\]#' testaptgetupdate.diff
6874a1a8
DK
16 GIVEN="$1"
17 shift
18 msgtest "Test for correctness of" "apt-get update with $*"
19 if [ -z "$GIVEN" ]; then
20 echo -n "" | checkdiff - testaptgetupdate.diff && msgpass || msgfail
21 else
22 echo "$GIVEN" | checkdiff - testaptgetupdate.diff && msgpass || msgfail
23 fi
24 rm testaptgetupdate.diff
25}
26
4260fd39
DK
27createemptyarchive() {
28 find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
29 if [ "en" = "$1" ]; then
30 echo -n "" | $COMPRESSOR > aptarchive/Packages.$COMPRESS
31 fi
32 touch aptarchive/Packages
33 echo -n "" | $COMPRESSOR > aptarchive/${1}.$COMPRESS
34 aptftparchive release aptarchive/ > aptarchive/Release
35 signreleasefiles
36 rm -f aptarchive/Packages
37}
6874a1a8 38
4260fd39
DK
39createemptyfile() {
40 find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
41 if [ "en" = "$1" ]; then
42 echo -n "" | $COMPRESSOR > aptarchive/Packages.$COMPRESS
43 fi
44 touch aptarchive/Packages aptarchive/${1}.$COMPRESS
45 aptftparchive release aptarchive/ > aptarchive/Release
46 signreleasefiles
47 rm -f aptarchive/Packages
48}
6874a1a8 49
4260fd39
DK
50setupcompressor() {
51 COMPRESSOR="$1"
52 case $COMPRESSOR in
53 gzip) COMPRESS="gz";;
54 bzip2) COMPRESS="bz2";;
55 lzma) COMPRESS="lzma";;
56 esac
57 echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
58Dir::Bin::gzip \"/does/not/exist\";
59Dir::Bin::bzip2 \"/does/not/exist\";
60Dir::Bin::lzma \"/does/not/exist\";" > rootdir/etc/apt/apt.conf.d/00compressor
61 if [ -e "/bin/${COMPRESSOR}" ]; then
62 echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor
63 elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
64 echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor
65 else
66 msgtest "Test for availability of compressor" "${COMPRESSOR}"
67 msgfail
68 exit 1
69 fi
70}
6874a1a8 71
4260fd39
DK
72testoverfile() {
73 setupcompressor "$1"
6874a1a8 74
4260fd39
DK
75 createemptyfile 'en'
76 testaptgetupdate "Get:1 file: Release.gpg []
77Get:2 file: Release []
78Ign file:$(readlink -f aptarchive)/ Translation-en
79Reading package lists..." "empty file en.$COMPRESS over file"
80
81 createemptyarchive 'en'
82 testaptgetupdate "Get:1 file: Release.gpg []
83Get:2 file: Release []
84Reading package lists..." "empty archive en.$COMPRESS over file"
85
86 createemptyarchive 'Packages'
87 # FIXME: Why omits the file transport the Packages Get line?
88 #Get:3 file: Packages []
89 testaptgetupdate "Ign file:$(readlink -f aptarchive)/ Translation-en
90Get:1 file: Release.gpg []
91Get:2 file: Release []
92Reading package lists..." "empty archive Packages.$COMPRESS over file"
93
94 createemptyfile 'Packages'
95 testaptgetupdate "Ign file:$(readlink -f aptarchive)/ Translation-en
96Get:1 file: Release.gpg []
97Get:2 file: Release []
98Err file: Packages
99 Undetermined Error
100W: Failed to fetch file:$(readlink -f aptarchive/Packages.$COMPRESS) Undetermined Error
6874a1a8 101
4260fd39
DK
102E: Some index files failed to download, they have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over file"
103}
6874a1a8 104
4260fd39
DK
105testoverhttp() {
106 setupcompressor "$1"
6874a1a8 107
4260fd39
DK
108 createemptyfile 'en'
109 testaptgetupdate "Get:1 http://localhost Release.gpg []
110Get:2 http://localhost/ Translation-en
111Get:3 http://localhost Release []
112Ign http://localhost/ Translation-en
113Get:4 http://localhost Packages []
114Reading package lists..." "empty file en.$COMPRESS over http"
115
116 createemptyarchive 'en'
117 testaptgetupdate "Get:1 http://localhost Release.gpg []
118Get:2 http://localhost/ Translation-en []
119Get:3 http://localhost Release []
120Get:4 http://localhost Packages []
121Reading package lists..." "empty archive en.$COMPRESS over http"
122
123 createemptyarchive 'Packages'
124 testaptgetupdate "Get:1 http://localhost Release.gpg []
6874a1a8 125Ign http://localhost/ Translation-en
6874a1a8 126Get:2 http://localhost Release []
6874a1a8 127Get:3 http://localhost Packages []
4260fd39 128Reading package lists..." "empty archive Packages.$COMPRESS over http"
6874a1a8 129
4260fd39
DK
130 createemptyfile 'Packages'
131 #FIXME: we should response with a good error message instead
132 testaptgetupdate "Get:1 http://localhost Release.gpg []
6874a1a8 133Ign http://localhost/ Translation-en
4260fd39
DK
134Get:2 http://localhost Release []
135Get:3 http://localhost Packages
6874a1a8
DK
136Err http://localhost Packages
137 Undetermined Error
4260fd39
DK
138W: Failed to fetch http://localhost:8080/Packages.$COMPRESS Undetermined Error
139
140E: Some index files failed to download, they have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http"
141}
142
143for COMPRESSOR in 'gzip' 'bzip2' 'lzma'; do testoverfile $COMPRESSOR; done
144
145# do the same again with http instead of file
146changetowebserver
6874a1a8 147
4260fd39 148for COMPRESSOR in 'gzip' 'bzip2' 'lzma'; do testoverhttp $COMPRESSOR; done