]>
Commit | Line | Data |
---|---|---|
6874a1a8 DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
9962ae93 | 4 | TESTDIR=$(readlink -f $(dirname $0)) |
6874a1a8 DK |
5 | . $TESTDIR/framework |
6 | setupenvironment | |
7 | configarchitecture "i386" | |
8 | ||
9 | buildaptarchive | |
db4b5f77 | 10 | touch aptarchive/Packages |
6874a1a8 DK |
11 | setupflataptarchive |
12 | ||
13 | testaptgetupdate() { | |
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 |
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 | aptftparchive release aptarchive/ > aptarchive/Release | |
36 | signreleasefiles | |
37 | rm -f aptarchive/Packages | |
38 | } | |
6874a1a8 | 39 | |
4260fd39 DK |
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 | aptftparchive release aptarchive/ > aptarchive/Release | |
47 | signreleasefiles | |
48 | rm -f aptarchive/Packages | |
49 | } | |
6874a1a8 | 50 | |
4260fd39 DK |
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::gzip \"/does/not/exist\"; | |
60 | Dir::Bin::bzip2 \"/does/not/exist\"; | |
61 | Dir::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 |
73 | testoverfile() { |
74 | setupcompressor "$1" | |
6874a1a8 | 75 | |
4260fd39 DK |
76 | createemptyfile 'en' |
77 | testaptgetupdate "Get:1 file: Release.gpg [] | |
78 | Get:2 file: Release [] | |
79 | Ign file:$(readlink -f aptarchive)/ Translation-en | |
80 | Reading package lists..." "empty file en.$COMPRESS over file" | |
81 | ||
82 | createemptyarchive 'en' | |
83 | testaptgetupdate "Get:1 file: Release.gpg [] | |
84 | Get:2 file: Release [] | |
85 | Reading package lists..." "empty archive en.$COMPRESS over file" | |
86 | ||
87 | createemptyarchive 'Packages' | |
88 | # FIXME: Why omits the file transport the Packages Get line? | |
89 | #Get:3 file: Packages [] | |
90 | testaptgetupdate "Ign file:$(readlink -f aptarchive)/ Translation-en | |
91 | Get:1 file: Release.gpg [] | |
92 | Get:2 file: Release [] | |
93 | Reading package lists..." "empty archive Packages.$COMPRESS over file" | |
94 | ||
95 | createemptyfile 'Packages' | |
96 | testaptgetupdate "Ign file:$(readlink -f aptarchive)/ Translation-en | |
97 | Get:1 file: Release.gpg [] | |
98 | Get:2 file: Release [] | |
99 | Err file: Packages | |
100 | Undetermined Error | |
101 | W: Failed to fetch file:$(readlink -f aptarchive/Packages.$COMPRESS) Undetermined Error | |
6874a1a8 | 102 | |
4260fd39 DK |
103 | E: Some index files failed to download, they have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over file" |
104 | } | |
6874a1a8 | 105 | |
4260fd39 DK |
106 | testoverhttp() { |
107 | setupcompressor "$1" | |
6874a1a8 | 108 | |
4260fd39 DK |
109 | createemptyfile 'en' |
110 | testaptgetupdate "Get:1 http://localhost Release.gpg [] | |
111 | Get:2 http://localhost/ Translation-en | |
112 | Get:3 http://localhost Release [] | |
113 | Ign http://localhost/ Translation-en | |
114 | Get:4 http://localhost Packages [] | |
115 | Reading package lists..." "empty file en.$COMPRESS over http" | |
116 | ||
117 | createemptyarchive 'en' | |
118 | testaptgetupdate "Get:1 http://localhost Release.gpg [] | |
119 | Get:2 http://localhost/ Translation-en [] | |
120 | Get:3 http://localhost Release [] | |
121 | Get:4 http://localhost Packages [] | |
122 | Reading package lists..." "empty archive en.$COMPRESS over http" | |
123 | ||
124 | createemptyarchive 'Packages' | |
125 | testaptgetupdate "Get:1 http://localhost Release.gpg [] | |
6874a1a8 | 126 | Ign http://localhost/ Translation-en |
6874a1a8 | 127 | Get:2 http://localhost Release [] |
6874a1a8 | 128 | Get:3 http://localhost Packages [] |
4260fd39 | 129 | Reading package lists..." "empty archive Packages.$COMPRESS over http" |
6874a1a8 | 130 | |
4260fd39 DK |
131 | createemptyfile 'Packages' |
132 | #FIXME: we should response with a good error message instead | |
133 | testaptgetupdate "Get:1 http://localhost Release.gpg [] | |
6874a1a8 | 134 | Ign http://localhost/ Translation-en |
4260fd39 DK |
135 | Get:2 http://localhost Release [] |
136 | Get:3 http://localhost Packages | |
6874a1a8 DK |
137 | Err http://localhost Packages |
138 | Undetermined Error | |
4260fd39 DK |
139 | W: Failed to fetch http://localhost:8080/Packages.$COMPRESS Undetermined Error |
140 | ||
141 | E: Some index files failed to download, they have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http" | |
142 | } | |
143 | ||
144 | for COMPRESSOR in 'gzip' 'bzip2' 'lzma'; do testoverfile $COMPRESSOR; done | |
145 | ||
146 | # do the same again with http instead of file | |
147 | changetowebserver | |
6874a1a8 | 148 | |
4260fd39 | 149 | for COMPRESSOR in 'gzip' 'bzip2' 'lzma'; do testoverhttp $COMPRESSOR; done |