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