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