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