]> git.saurik.com Git - apt.git/blob - test/integration/test-pdiff-usage
test-apt-update-reporting: Make more use of framework
[apt.git] / test / integration / test-pdiff-usage
1 #!/bin/sh
2 set -e
3
4 TESTDIR="$(readlink -f "$(dirname "$0")")"
5 . "$TESTDIR/framework"
6
7 setupenvironment
8 configarchitecture 'i386'
9 LOWCOSTEXT='lz4'
10
11 buildaptarchive
12 setupflataptarchive
13 changetowebserver -o aptwebserver::support::modified-since=false
14
15 PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
16
17 wasmergeused() {
18 testsuccess apt update "$@"
19
20 msgtest 'No intermediate patch files' 'still exist'
21 local EDS="$(find rootdir/var/lib/apt/lists -name '*.ed' -o -name '*.ed.*')"
22 if [ -z "$EDS" ]; then
23 msgpass
24 else
25 echo
26 echo "$EDS"
27 msgfail
28 fi
29
30 if echo "$*" | grep -q -- '-o test::cannot-use-pdiff=1'; then
31 msgtest 'Check if pdiff was' 'not used'
32 cp -a rootdir/tmp/testsuccess.output rootdir/tmp/aptupdate.output
33 testsuccess --nomsg grep "diff/Index with Message: Couldn't parse pdiff index" rootdir/tmp/aptupdate.output
34 return;
35 fi
36
37 msgtest 'Check if the right pdiff merger was used'
38 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' rootdir/tmp/testsuccess.output; then
39 if echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
40 msgpass
41 else
42 msgfail "Merge shouldn't have been used, but was"
43 fi
44 elif echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
45 msgfail "Merge should have been used, but wasn't"
46 else
47 msgpass
48 fi
49 }
50
51 testrun() {
52 configcompression '.' 'xz'
53 msgmsg "Testcase: setup the base with: $*"
54 find aptarchive -name 'Packages*' -type f -delete
55 cp "${PKGFILE}" aptarchive/Packages
56 compressfile 'aptarchive/Packages'
57 generatereleasefiles
58 signreleasefiles
59 rm -rf aptarchive/Packages.diff rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
60 testsuccess aptget update "$@"
61 cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
62 testnopackage newstuff
63 testsuccessequal "$(cat "${PKGFILE}")
64 " aptcache show apt oldstuff
65 configcompression '.' 'gz'
66
67 # see if the code deals properly with leftover partial files
68 partialleftovers
69
70 msgmsg "Testcase: apply with one patch: $*"
71 find aptarchive -name 'Packages*' -type f -delete
72 cp "${PKGFILE}-new" aptarchive/Packages
73 compressfile 'aptarchive/Packages'
74 mkdir -p aptarchive/Packages.diff
75 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
76 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
77 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
78 PATCHINDEX='aptarchive/Packages.diff/Index'
79 echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
80 SHA256-History:
81 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
82 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
83 SHA256-Patches:
84 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
85 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
86 SHA256-Download:
87 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
88 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" > "$PATCHINDEX"
89
90 generatereleasefiles '+1hour'
91 signreleasefiles
92 find aptarchive -name 'Packages*' -type f -delete
93 wasmergeused "$@"
94 testnopackage oldstuff
95 testsuccessequal "$(cat "${PKGFILE}-new")
96 " aptcache show apt newstuff
97
98 msgmsg "Testcase: SHA1-only patches are not used: $*"
99 find aptarchive -name 'Packages*' -type f -delete
100 cp "${PKGFILE}-new" aptarchive/Packages
101 compressfile 'aptarchive/Packages'
102 mkdir -p aptarchive/Packages.diff
103 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
104 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
105 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
106 PATCHINDEX='aptarchive/Packages.diff/Index'
107 echo "SHA1-Current: $(sha1sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
108 SHA1-History:
109 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
110 $(sha1sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
111 SHA1-Patches:
112 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
113 $(sha1sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
114 SHA1-Download:
115 2365ac0ac57cde3d43c63145e8251a3bd5410213 197 2010-08-18-2013.28.gz
116 $(sha1sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" > "$PATCHINDEX"
117 generatereleasefiles '+1hour'
118 signreleasefiles
119 rm -rf rootdir/var/lib/apt/lists
120 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
121 wasmergeused "$@" -o test::cannot-use-pdiff=1
122 testnopackage oldstuff
123 testsuccessequal "$(cat "${PKGFILE}-new")
124 " aptcache show apt newstuff
125
126 msgmsg "Testcase: no download-hashes patches are not used: $*"
127 find aptarchive -name 'Packages*' -type f -delete
128 cp "${PKGFILE}-new" aptarchive/Packages
129 compressfile 'aptarchive/Packages'
130 mkdir -p aptarchive/Packages.diff
131 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
132 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
133 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
134 PATCHINDEX='aptarchive/Packages.diff/Index'
135 echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
136 SHA256-History:
137 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
138 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
139 SHA256-Patches:
140 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
141 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")" > "$PATCHINDEX"
142 generatereleasefiles '+1hour'
143 signreleasefiles
144 rm -rf rootdir/var/lib/apt/lists
145 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
146 wasmergeused "$@" -o test::cannot-use-pdiff=1
147 testnopackage oldstuff
148 testsuccessequal "$(cat "${PKGFILE}-new")
149 " aptcache show apt newstuff
150
151 msgmsg "Testcase: apply with two patches: $*"
152 cp "${PKGFILE}-new" aptarchive/Packages
153 echo '
154 Package: futurestuff
155 Version: 1.0
156 Architecture: i386
157 Maintainer: Joe Sixpack <joe@example.org>
158 Installed-Size: 202
159 Filename: pool/futurestuff_1.0_i386.deb
160 Size: 202200
161 SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
162 Description: some cool and shiny future stuff
163 This package will appear in the next next mirror update
164 Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages
165
166 compressfile 'aptarchive/Packages'
167 PATCHFILE2="aptarchive/Packages.diff/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')"
168 diff -e "${PKGFILE}-new" aptarchive/Packages > "${PATCHFILE2}" || true
169 cat "$PATCHFILE2" | gzip > "${PATCHFILE2}.gz"
170 echo "SHA256-Current: $(sha256sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
171 SHA256-History:
172 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
173 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
174 $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new") $(basename "${PATCHFILE2}")
175 SHA256-Patches:
176 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
177 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
178 $(sha256sum "${PATCHFILE2}" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE2}") $(basename "${PATCHFILE2}")
179 SHA256-Download:
180 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
181 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")
182 $(sha256sum "${PATCHFILE2}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE2}.gz") $(basename "${PATCHFILE2}.gz")" > "$PATCHINDEX"
183
184 generatereleasefiles '+2hour'
185 signreleasefiles
186 cp -a aptarchive/Packages Packages-future
187 find aptarchive -name 'Packages*' -type f -delete
188 rm -rf rootdir/var/lib/apt/lists
189 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
190 wasmergeused "$@"
191 testnopackage oldstuff
192 testsuccessequal "$(cat Packages-future)
193 " aptcache show apt newstuff futurestuff
194
195 # we reuse the archive state of the previous test here
196 msgmsg "Testcase: downloading a patch fails, but successful fallback: $*"
197 rm -rf rootdir/var/lib/apt/lists
198 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
199 cp Packages-future aptarchive/Packages
200 rm "${PATCHFILE}.gz"
201 testsuccess apt update "$@"
202 cp rootdir/tmp/testsuccess.output patchdownload.output
203 testsuccess grep '^Falling back to normal index file acquire' patchdownload.output
204 testnopackage oldstuff
205 testsuccessequal "$(cat Packages-future)
206 " aptcache show apt newstuff futurestuff
207
208 msgmsg "Testcase: patch applying fails, but successful fallback: $*"
209 rm -rf rootdir/var/lib/apt/lists
210 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
211 cp "${PKGFILE}-new" aptarchive/Packages
212 compressfile 'aptarchive/Packages'
213 mkdir -p aptarchive/Packages.diff
214 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
215 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
216 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
217 PATCHINDEX='aptarchive/Packages.diff/Index'
218 echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
219 SHA256-History:
220 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
221 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
222 SHA256-Patches:
223 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
224 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
225 SHA256-Download:
226 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
227 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" > "$PATCHINDEX"
228 # needs to look like a valid command, otherwise the parser will fail before hashes are checked
229 echo '1d' > "$PATCHFILE"
230 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
231 generatereleasefiles '+1hour'
232 signreleasefiles
233 testsuccess apt update "$@"
234 cp -f rootdir/tmp/testsuccess.output rootdir/tmp/aptupdate.output
235 testsuccess grep 'Hash Sum mismatch' rootdir/tmp/aptupdate.output
236 testnopackage oldstuff
237 testsuccessequal "$(cat "${PKGFILE}-new")
238 " aptcache show apt newstuff
239
240 msgmsg "Testcase: pdiff patch bigger than index itself: $*"
241 rm -rf rootdir/var/lib/apt/lists
242 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
243 # the general testcode checks for leftovers in partial, but as this file
244 # is never touched in this test as it exits earlier its not a leftover…
245 rm -f rootdir/var/lib/apt/lists/partial/localhost:${APTHTTPPORT}_Packages
246 cp "${PKGFILE}-new" aptarchive/Packages
247 compressfile 'aptarchive/Packages'
248 mkdir -p aptarchive/Packages.diff
249 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
250 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
251 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
252 PATCHINDEX='aptarchive/Packages.diff/Index'
253 echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
254 SHA256-History:
255 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
256 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
257 SHA256-Patches:
258 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
259 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
260 SHA256-Download:
261 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
262 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz")000 $(basename "${PATCHFILE}.gz")" > "$PATCHINDEX"
263 generatereleasefiles '+1hour'
264 signreleasefiles
265 testsuccess apt update -o Debug::pkgAcquire::Diffs=1 "$@"
266 cp -f rootdir/tmp/testsuccess.output rootdir/tmp/aptupdate.output
267 testsuccess grep 'bytes (Limit is' rootdir/tmp/aptupdate.output
268 testnopackage oldstuff
269 testsuccessequal "$(cat "${PKGFILE}-new")
270 " aptcache show apt newstuff
271 }
272 echo 'Debug::pkgAcquire::Diffs "true";
273 Debug::Acquire::Transaction "true";
274 Debug::pkgAcquire::rred "true";' > rootdir/etc/apt/apt.conf.d/rreddebug.conf
275
276 testcase() {
277 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=1 "$@"
278 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=1 "$@"
279 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=0 "$@"
280 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=0 "$@"
281 }
282 partialleftovers() { touch "rootdir/var/lib/apt/lists-bak/partial/localhost:${APTHTTPPORT}_Packages"; }
283 aptautotest_apt_update() { aptautotest_aptget_update "$@"; testsuccess test -e "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_Packages"; }
284 testcase -o Acquire::IndexTargets::deb::Packages::KeepCompressed=false
285 partialleftovers() { touch "rootdir/var/lib/apt/lists-bak/partial/localhost:${APTHTTPPORT}_Packages.$LOWCOSTEXT"; }
286 aptautotest_apt_update() { aptautotest_aptget_update "$@"; testsuccess test -e "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_Packages.$LOWCOSTEXT"; }
287 testcase -o Acquire::IndexTargets::deb::Packages::KeepCompressed=true
288
289
290 partialleftovers() { touch "rootdir/var/lib/apt/lists-bak/partial/localhost:${APTHTTPPORT}_redirectme_Packages.$LOWCOSTEXT"; }
291 webserverconfig 'aptwebserver::redirect::replace::/redirectme/' "http://0.0.0.0:${APTHTTPPORT}/"
292 rewritesourceslist "http://localhost:${APTHTTPPORT}/redirectme"
293 aptautotest_apt_update() {
294 aptautotest_aptget_update "$@"
295 testsuccess test -e "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_redirectme_Packages.$LOWCOSTEXT"
296 testempty find rootdir/var/lib/apt/lists -type f \! \( -name lock -o -name '*_redirectme_*' \)
297 }
298 testcase -o Acquire::IndexTargets::deb::Packages::KeepCompressed=true