]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-bug-595691-empty-and-broken-archive-files
Only support Translation-* that are listed in the {In,}Release file
[apt.git] / test / integration / test-bug-595691-empty-and-broken-archive-files
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
6setupenvironment
7configarchitecture "i386"
8
9buildaptarchive
10touch aptarchive/Packages
11setupflataptarchive
12
13testaptgetupdate() {
14 rm -rf rootdir/var/lib/apt
15 aptget update 2>> testaptgetupdate.diff >> testaptgetupdate.diff || true
16 sed -i -e '/Ign /,+1d' -e '/Release/ d' -e 's#Get:[0-9]\+ #Get: #' -e 's#\[[0-9]* [kMGTPY]*B\]#\[\]#' testaptgetupdate.diff
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
28createemptyarchive() {
29 find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
30 if [ "en" = "$1" ]; then
31 echo -n "" | $COMPRESSOR_CMD > aptarchive/Packages.$COMPRESS
32 fi
33 touch aptarchive/Packages
34 echo -n "" | $COMPRESSOR_CMD > aptarchive/${1}.$COMPRESS
35 generatereleasefiles
36 signreleasefiles
37 rm -f aptarchive/Packages
38}
39
40createemptyfile() {
41 find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
42 if [ "en" = "$1" ]; then
43 echo -n "" | $COMPRESSOR_CMD > aptarchive/Packages.$COMPRESS
44 fi
45 touch aptarchive/Packages aptarchive/${1}.$COMPRESS
46 generatereleasefiles
47 signreleasefiles
48 rm -f aptarchive/Packages
49}
50
51testoverfile() {
52 forcecompressor "$1"
53
54 createemptyfile 'en'
55 testaptgetupdate 'Reading package lists...' "empty file en.$COMPRESS over file"
56
57 createemptyarchive 'en'
58 testaptgetupdate 'Reading package lists...' "empty archive en.$COMPRESS over file"
59
60 createemptyarchive 'Packages'
61 # FIXME: Why omits the file transport the Packages Get line?
62 #Get:3 file: Packages []
63 testaptgetupdate 'Reading package lists...' "empty archive Packages.$COMPRESS over file"
64
65 createemptyfile 'Packages'
66 testaptgetupdate "Err file: Packages
67 Empty files can't be valid archives
68W: Failed to fetch ${COMPRESSOR}:$(readlink -f aptarchive/Packages.$COMPRESS) Empty files can't be valid archives
69
70E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over file"
71}
72
73testoverhttp() {
74 forcecompressor "$1"
75
76 createemptyarchive 'Packages'
77 testaptgetupdate "Get: http://localhost:8080 Packages []
78Reading package lists..." "empty archive Packages.$COMPRESS over http"
79
80 createemptyfile 'Packages'
81 #FIXME: we should response with a good error message instead
82 testaptgetupdate "Get: http://localhost:8080 Packages
83Err http://localhost:8080 Packages
84 Empty files can't be valid archives
85W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:8080_Packages.${COMPRESS}) Empty files can't be valid archives
86
87E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http"
88}
89
90for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverfile $COMPRESSOR; done
91
92# do the same again with http instead of file
93changetowebserver
94
95for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverhttp $COMPRESSOR; done