]>
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 | |
ab53c018 | 35 | generatereleasefiles |
4260fd39 DK |
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 | |
ab53c018 | 46 | generatereleasefiles |
4260fd39 DK |
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";; | |
79d5bab6 | 57 | xz) COMPRESS="xz";; |
4260fd39 DK |
58 | esac |
59 | echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; }; | |
5d885723 | 60 | Dir::Bin::uncompressed \"/does/not/exist\"; |
4260fd39 DK |
61 | Dir::Bin::gzip \"/does/not/exist\"; |
62 | Dir::Bin::bzip2 \"/does/not/exist\"; | |
79d5bab6 DK |
63 | Dir::Bin::lzma \"/does/not/exist\"; |
64 | Dir::Bin::xz \"/does/not/exist\";" > rootdir/etc/apt/apt.conf.d/00compressor | |
4260fd39 DK |
65 | if [ -e "/bin/${COMPRESSOR}" ]; then |
66 | echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor | |
67 | elif [ -e "/usr/bin/${COMPRESSOR}" ]; then | |
68 | echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor | |
69 | else | |
70 | msgtest "Test for availability of compressor" "${COMPRESSOR}" | |
71 | msgfail | |
72 | exit 1 | |
73 | fi | |
74 | } | |
6874a1a8 | 75 | |
4260fd39 DK |
76 | testoverfile() { |
77 | setupcompressor "$1" | |
6874a1a8 | 78 | |
4260fd39 | 79 | createemptyfile 'en' |
fe0f7911 | 80 | testaptgetupdate "Get:1 file: InRelease [] |
ab53c018 | 81 | Ign file: Translation-en |
4260fd39 DK |
82 | Reading package lists..." "empty file en.$COMPRESS over file" |
83 | ||
84 | createemptyarchive 'en' | |
fe0f7911 | 85 | testaptgetupdate "Get:1 file: InRelease [] |
4260fd39 DK |
86 | Reading package lists..." "empty archive en.$COMPRESS over file" |
87 | ||
88 | createemptyarchive 'Packages' | |
89 | # FIXME: Why omits the file transport the Packages Get line? | |
90 | #Get:3 file: Packages [] | |
ab53c018 DK |
91 | testaptgetupdate "Get:1 file: InRelease [] |
92 | Ign file: Translation-en | |
4260fd39 DK |
93 | Reading package lists..." "empty archive Packages.$COMPRESS over file" |
94 | ||
95 | createemptyfile 'Packages' | |
ab53c018 DK |
96 | testaptgetupdate "Get:1 file: InRelease [] |
97 | Ign file: Translation-en | |
4260fd39 | 98 | Err file: Packages |
5d885723 DK |
99 | Empty files can't be valid archives |
100 | W: Failed to fetch ${COMPRESSOR}:$(readlink -f aptarchive/Packages.$COMPRESS) Empty files can't be valid archives | |
6874a1a8 | 101 | |
196c511c | 102 | E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over file" |
4260fd39 | 103 | } |
6874a1a8 | 104 | |
4260fd39 DK |
105 | testoverhttp() { |
106 | setupcompressor "$1" | |
6874a1a8 | 107 | |
4260fd39 | 108 | createemptyfile 'en' |
fe0f7911 | 109 | testaptgetupdate "Get:1 http://localhost InRelease [] |
ab53c018 DK |
110 | Get:2 http://localhost Packages [] |
111 | Get:3 http://localhost Translation-en | |
112 | Ign http://localhost Translation-en | |
4260fd39 DK |
113 | Reading package lists..." "empty file en.$COMPRESS over http" |
114 | ||
115 | createemptyarchive 'en' | |
fe0f7911 | 116 | testaptgetupdate "Get:1 http://localhost InRelease [] |
ab53c018 DK |
117 | Get:2 http://localhost Packages [] |
118 | Get:3 http://localhost Translation-en [] | |
4260fd39 DK |
119 | Reading package lists..." "empty archive en.$COMPRESS over http" |
120 | ||
121 | createemptyarchive 'Packages' | |
fe0f7911 | 122 | testaptgetupdate "Get:1 http://localhost InRelease [] |
fe0f7911 | 123 | Get:2 http://localhost Packages [] |
ab53c018 | 124 | Ign http://localhost Translation-en |
4260fd39 | 125 | Reading package lists..." "empty archive Packages.$COMPRESS over http" |
6874a1a8 | 126 | |
4260fd39 DK |
127 | createemptyfile 'Packages' |
128 | #FIXME: we should response with a good error message instead | |
fe0f7911 | 129 | testaptgetupdate "Get:1 http://localhost InRelease [] |
fe0f7911 | 130 | Get:2 http://localhost Packages |
ab53c018 | 131 | Ign http://localhost Translation-en |
6874a1a8 | 132 | Err http://localhost Packages |
5d885723 DK |
133 | Empty files can't be valid archives |
134 | W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:8080_Packages) Empty files can't be valid archives | |
4260fd39 | 135 | |
196c511c | 136 | E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http" |
4260fd39 DK |
137 | } |
138 | ||
79d5bab6 | 139 | for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverfile $COMPRESSOR; done |
4260fd39 DK |
140 | |
141 | # do the same again with http instead of file | |
142 | changetowebserver | |
6874a1a8 | 143 | |
79d5bab6 | 144 | for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverhttp $COMPRESSOR; done |