]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-update-ims
keep compressed indexes in a low-cost format
[apt.git] / test / integration / test-apt-update-ims
1 #!/bin/sh
2 set -e
3
4 TESTDIR="$(readlink -f "$(dirname "$0")")"
5 . "$TESTDIR/framework"
6 setupenvironment
7 configarchitecture 'amd64'
8
9 insertpackage 'unstable' 'unrelated' 'all' '0.5~squeeze1'
10 insertpackage 'unstable' 'unrelated2' 'amd64' '0.5~squeeze1'
11 insertsource 'unstable' 'unrelated' 'all' '0.5~squeeze1'
12
13 setupaptarchive --no-update
14 changetowebserver
15
16 runtest() {
17 local APTOPT=""
18 if [ -n "$1" ]; then
19 APTOPT='--allow-insecure-repositories'
20 else
21 APTOPT='--no-allow-insecure-repositories'
22 fi
23
24 rm -rf rootdir/var/lib/apt/lists/
25
26 local TEST="test${1:-success}"
27 $TEST aptget update $APTOPT -o Debug::pkgAcquire::Worker=1
28 if [ "$1" = 'failure' ]; then
29 # accept the outdated Release file so we can check Hit behaviour
30 "test${2:-success}" aptget update -o Acquire::Min-ValidTime=9999999 $APTOPT
31 fi
32 listcurrentlistsdirectory > listsdir.lst
33 testsuccess grep '_Packages\(\.[0-9a-z]\+\)\?$' listsdir.lst
34 testsuccess grep '_Sources\(\.[0-9a-z]\+\)\?$' listsdir.lst
35 testsuccess grep '_Translation-en\(\.[0-9a-z]\+\)\?$' listsdir.lst
36
37 # ensure no leftovers in partial
38 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
39
40 # check that I-M-S header is kept in redirections
41 echo "$EXPECT" | sed -e 's#(invalid since [^)]\+)#(invalid since)#' > expected.output
42 $TEST aptget update -o Debug::pkgAcquire::Worker=0 -o Debug::Acquire::http=0 $APTOPT
43 sed -i -e 's#(invalid since [^)]\+)#(invalid since)#' rootdir/tmp/${TEST}.output
44 testequal "$(cat expected.output)" cat rootdir/tmp/${TEST}.output
45 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
46
47 # ensure that we still do a hash check for other files on ims hit of Release
48 if grep -q '^Hit:[0-9]\+ .* InRelease$' expected.output || ! grep -q '^Ign:[0-9]\+ .* Release\(\.gpg\)\?$' expected.output; then
49 $TEST aptget update -o Debug::Acquire::gpgv=1 $APTOPT
50 cp rootdir/tmp/${TEST}.output goodsign.output
51 testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
52 testsuccess grep '^Got GOODSIG, key ID:GOODSIG' goodsign.output
53 fi
54
55 # ensure no leftovers in partial
56 testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
57 }
58
59 msgmsg 'InRelease'
60 EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
61 Reading package lists..."
62 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
63 runtest
64 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
65 runtest
66
67 msgmsg 'Release/Release.gpg'
68 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
69 404 Not Found
70 Hit:2 http://localhost:${APTHTTPPORT} unstable Release
71 Reading package lists..."
72 find aptarchive -name 'InRelease' -delete
73 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
74 runtest
75 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
76 runtest
77
78 msgmsg 'Release only'
79 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
80 404 Not Found
81 Hit:2 http://localhost:${APTHTTPPORT} unstable Release
82 Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
83 404 Not Found
84 Reading package lists...
85 W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
86 N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
87 N: See apt-secure(8) manpage for repository creation and user configuration details."
88 find aptarchive -name 'Release.gpg' -delete
89 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
90 runtest 'warning'
91 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
92 runtest 'warning'
93
94
95 # make the release file old
96 find aptarchive -name '*Release' -exec sed -i \
97 -e "s#^Date: .*\$#Date: $(date -d '-2 weeks' '+%a, %d %b %Y %H:%M:%S %Z')#" \
98 -e '/^Valid-Until: / d' -e "/^Date: / a\
99 Valid-Until: $(date -d '-1 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" '{}' \;
100 signreleasefiles
101
102 msgmsg 'expired InRelease'
103 EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
104 Reading package lists...
105 E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied."
106 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
107 runtest 'failure'
108 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
109 runtest 'failure'
110
111 msgmsg 'expired Release/Release.gpg'
112 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
113 404 Not Found
114 Hit:2 http://localhost:${APTHTTPPORT} unstable Release
115 Reading package lists...
116 E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
117 find aptarchive -name 'InRelease' -delete
118 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
119 runtest 'failure'
120 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
121 runtest 'failure'
122
123 msgmsg 'expired Release only'
124 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
125 404 Not Found
126 Hit:2 http://localhost:${APTHTTPPORT} unstable Release
127 Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
128 404 Not Found
129 Reading package lists...
130 W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
131 N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
132 N: See apt-secure(8) manpage for repository creation and user configuration details.
133 E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
134 find aptarchive -name 'Release.gpg' -delete
135 echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
136 runtest 'failure' 'warning'
137 echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
138 runtest 'failure' 'warning'
139
140
141 msgmsg 'no Release at all'
142 EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
143 404 Not Found
144 Ign:2 http://localhost:${APTHTTPPORT} unstable Release
145 404 Not Found
146 Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
147 404 Not Found
148 Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
149 404 Not Found
150 Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
151 404 Not Found
152 Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
153 404 Not Found
154 Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
155 404 Not Found
156 Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
157 404 Not Found
158 Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
159 404 Not Found
160 Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
161 404 Not Found
162 Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
163 404 Not Found
164 Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
165 404 Not Found
166 Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
167 404 Not Found
168 Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
169 404 Not Found
170 Hit:3 http://localhost:${APTHTTPPORT} unstable/main Sources
171 Hit:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
172 Hit:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
173 Hit:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
174 Reading package lists...
175 W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' does not have a Release file.
176 N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
177 N: See apt-secure(8) manpage for repository creation and user configuration details."
178 find aptarchive -name '*Release*' -delete
179 echo 'Acquire::GzipIndexes "0";
180 Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
181 runtest 'warning'
182 echo 'Acquire::GzipIndexes "1";
183 Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
184 runtest 'warning'