]>
Commit | Line | Data |
---|---|---|
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 | testaptgetupdate() { | |
14 | rm -rf rootdir/var/lib/apt rootdir/var/cache/apt | |
15 | aptget update 2>> testaptgetupdate.diff >> testaptgetupdate.diff || true | |
16 | sed -i -e '/^Fetched / d' -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 | ||
28 | createemptyarchive() { | |
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 | generatereleasefiles | |
36 | signreleasefiles | |
37 | rm -f aptarchive/Packages | |
38 | } | |
39 | ||
40 | createemptyfile() { | |
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 | generatereleasefiles | |
47 | signreleasefiles | |
48 | rm -f aptarchive/Packages | |
49 | } | |
50 | ||
51 | setupcompressor() { | |
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}\"; }; | |
59 | Dir::Bin::uncompressed \"/does/not/exist\"; | |
60 | Dir::Bin::gzip \"/does/not/exist\"; | |
61 | Dir::Bin::bzip2 \"/does/not/exist\"; | |
62 | Dir::Bin::lzma \"/does/not/exist\";" > rootdir/etc/apt/apt.conf.d/00compressor | |
63 | if [ -e "/bin/${COMPRESSOR}" ]; then | |
64 | echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor | |
65 | elif [ -e "/usr/bin/${COMPRESSOR}" ]; then | |
66 | echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor | |
67 | else | |
68 | msgtest "Test for availability of compressor" "${COMPRESSOR}" | |
69 | msgfail | |
70 | exit 1 | |
71 | fi | |
72 | } | |
73 | ||
74 | testoverfile() { | |
75 | setupcompressor "$1" | |
76 | ||
77 | createemptyfile 'en' | |
78 | testaptgetupdate "Get:1 file: InRelease [] | |
79 | Ign file: Translation-en | |
80 | Reading package lists..." "empty file en.$COMPRESS over file" | |
81 | ||
82 | createemptyarchive 'en' | |
83 | testaptgetupdate "Get:1 file: InRelease [] | |
84 | Reading 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 "Get:1 file: InRelease [] | |
90 | Ign file: Translation-en | |
91 | Reading package lists..." "empty archive Packages.$COMPRESS over file" | |
92 | ||
93 | createemptyfile 'Packages' | |
94 | testaptgetupdate "Get:1 file: InRelease [] | |
95 | Ign file: Translation-en | |
96 | Err file: Packages | |
97 | Empty files can't be valid archives | |
98 | W: Failed to fetch ${COMPRESSOR}:$(readlink -f aptarchive/Packages.$COMPRESS) Empty files can't be valid archives | |
99 | ||
100 | E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over file" | |
101 | } | |
102 | ||
103 | testoverhttp() { | |
104 | setupcompressor "$1" | |
105 | ||
106 | createemptyfile 'en' | |
107 | testaptgetupdate "Get:1 http://localhost InRelease [] | |
108 | Get:2 http://localhost Packages [] | |
109 | Get:3 http://localhost Translation-en | |
110 | Ign http://localhost Translation-en | |
111 | Reading package lists..." "empty file en.$COMPRESS over http" | |
112 | ||
113 | createemptyarchive 'en' | |
114 | testaptgetupdate "Get:1 http://localhost InRelease [] | |
115 | Get:2 http://localhost Packages [] | |
116 | Get:3 http://localhost Translation-en [] | |
117 | Reading package lists..." "empty archive en.$COMPRESS over http" | |
118 | ||
119 | createemptyarchive 'Packages' | |
120 | testaptgetupdate "Get:1 http://localhost InRelease [] | |
121 | Get:2 http://localhost Packages [] | |
122 | Ign http://localhost Translation-en | |
123 | Reading package lists..." "empty archive Packages.$COMPRESS over http" | |
124 | ||
125 | createemptyfile 'Packages' | |
126 | #FIXME: we should response with a good error message instead | |
127 | testaptgetupdate "Get:1 http://localhost InRelease [] | |
128 | Get:2 http://localhost Packages | |
129 | Ign http://localhost Translation-en | |
130 | Err http://localhost Packages | |
131 | Empty files can't be valid archives | |
132 | W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:8080_Packages) Empty files can't be valid archives | |
133 | ||
134 | E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http" | |
135 | } | |
136 | ||
137 | for COMPRESSOR in 'gzip' 'bzip2' 'lzma'; do testoverfile $COMPRESSOR; done | |
138 | ||
139 | # do the same again with http instead of file | |
140 | changetowebserver | |
141 | ||
142 | for COMPRESSOR in 'gzip' 'bzip2' 'lzma'; do testoverhttp $COMPRESSOR; done |