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