]> git.saurik.com Git - apt.git/blame - test/integration/test-pdiff-usage
add --sha512 option + documentation for apt-ftparchive
[apt.git] / test / integration / test-pdiff-usage
CommitLineData
f213b6ea
DK
1#!/bin/sh
2set -e
3
9962ae93 4TESTDIR=$(readlink -f $(dirname $0))
f213b6ea
DK
5. $TESTDIR/framework
6
7setupenvironment
47d2bc78 8configarchitecture 'i386'
f213b6ea
DK
9
10buildaptarchive
11setupflataptarchive
12changetowebserver
f213b6ea 13
f213b6ea 14PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
47d2bc78 15
47d2bc78 16wasmergeused() {
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
43testrun() {
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
68SHA1-History:
69 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
70 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
71SHA1-Patches:
f6d4ab9a
DK
72 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
73 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
74SHA256-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
75SHA256-History:
76 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
77 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
78SHA256-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)
85SHA256-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: apply with two patches: $*"
47d2bc78
DK
99 cp ${PKGFILE}-new aptarchive/Packages
100 echo '
101Package: futurestuff
102Version: 1.0
103Architecture: i386
104Maintainer: Joe Sixpack <joe@example.org>
105Installed-Size: 202
106Filename: pool/futurestuff_1.0_i386.deb
107Size: 202200
108MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
109SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
110SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
111Description: some cool and shiny future stuff
112 This package will appear in the next next mirror update
113Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages
114
115 compressfile 'aptarchive/Packages'
116 PATCHFILE2="aptarchive/Packages.diff/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')"
117 diff -e ${PKGFILE}-new aptarchive/Packages > ${PATCHFILE2} || true
118 cat $PATCHFILE2 | gzip > ${PATCHFILE2}.gz
119 echo "SHA1-Current: $(sha1sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
120SHA1-History:
121 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
122 $(sha1sum ${PKGFILE} | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}) $(basename ${PATCHFILE})
123 $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) $(basename ${PATCHFILE2})
124SHA1-Patches:
f6d4ab9a 125 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
47d2bc78 126 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
f6d4ab9a
DK
127 $(sha1sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})
128SHA256-Current: $(sha256sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
129SHA256-History:
130 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
131 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
132 $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) $(basename ${PATCHFILE2})
133SHA256-Patches:
134 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
135 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
136 $(sha256sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})" > $PATCHINDEX
4f51fd86
DK
137 if $DOWNLOADHASH; then
138 echo "SHA1-Download:
139 2365ac0ac57cde3d43c63145e8251a3bd5410213 197 2010-08-18-2013.28.gz
140 $(sha1sum ${PATCHFILE}.gz | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE}.gz) $(basename ${PATCHFILE}.gz)
141 $(sha1sum ${PATCHFILE2}.gz | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}.gz) $(basename ${PATCHFILE2}.gz)
142SHA256-Download:
143 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
144 $(sha256sum ${PATCHFILE}.gz | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE}.gz) $(basename ${PATCHFILE}.gz)
145 $(sha256sum ${PATCHFILE2}.gz | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}.gz) $(basename ${PATCHFILE2}.gz)" >> $PATCHINDEX
146 fi
147
47d2bc78
DK
148 generatereleasefiles '+2hour'
149 signreleasefiles
150 cp -a aptarchive/Packages Packages-future
151 find aptarchive -name 'Packages*' -type f -delete
152 rm -rf rootdir/var/lib/apt/lists
153 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
154 wasmergeused "$@"
155 testnopackage oldstuff
25b86db1 156 testsuccessequal "$(cat Packages-future)
47d2bc78
DK
157" aptcache show apt newstuff futurestuff
158
34d6ece7 159 msgmsg "Testcase: patch applying fails, but successful fallback: $*"
47d2bc78
DK
160 rm -rf rootdir/var/lib/apt/lists
161 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
162 cp ${PKGFILE}-new aptarchive/Packages
163 compressfile 'aptarchive/Packages'
164 mkdir -p aptarchive/Packages.diff
165 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
166 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
4f51fd86 167 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
47d2bc78
DK
168 PATCHINDEX='aptarchive/Packages.diff/Index'
169 echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
170SHA1-History:
171 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
172 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
173SHA1-Patches:
f6d4ab9a
DK
174 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
175 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
176SHA256-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
177SHA256-History:
178 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
179 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
180SHA256-Patches:
181 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
182 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
4f51fd86
DK
183 if $DOWNLOADHASH; then
184 echo "SHA1-Download:
185 2365ac0ac57cde3d43c63145e8251a3bd5410213 197 2010-08-18-2013.28.gz
186 $(sha1sum ${PATCHFILE}.gz | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE}.gz) $(basename ${PATCHFILE}.gz)
187SHA256-Download:
188 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
189 $(sha256sum ${PATCHFILE}.gz | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE}.gz) $(basename ${PATCHFILE}.gz)" >> $PATCHINDEX
190 fi
6d3e5bd8 191 # needs to look like a valid command, otherwise the parser will fail before hashes are checked
4f51fd86 192 echo '1d' > $PATCHFILE
47d2bc78
DK
193 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
194 generatereleasefiles '+1hour'
195 signreleasefiles
196 testsuccess aptget update "$@"
36795154 197 cp -f rootdir/tmp/testsuccess.output rootdir/tmp/aptgetupdate.output
4f51fd86 198 testsuccess grep 'Hash Sum mismatch' rootdir/tmp/aptgetupdate.output
47d2bc78 199 testnopackage oldstuff
25b86db1 200 testsuccessequal "$(cat ${PKGFILE}-new)
47d2bc78 201" aptcache show apt newstuff
c355ea30
DK
202
203 msgmsg "Testcase: pdiff patch bigger than index itself: $*"
204 rm -rf rootdir/var/lib/apt/lists
205 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
206 cp ${PKGFILE}-new aptarchive/Packages
207 compressfile 'aptarchive/Packages'
208 mkdir -p aptarchive/Packages.diff
209 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
210 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
211 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
212 PATCHINDEX='aptarchive/Packages.diff/Index'
213 echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
214SHA1-History:
215 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
216 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
217SHA1-Patches:
218 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
219 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE)000 $(basename $PATCHFILE)
220SHA256-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
221SHA256-History:
222 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
223 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
224SHA256-Patches:
225 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
226 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE)000 $(basename $PATCHFILE)" > $PATCHINDEX
4f51fd86
DK
227 if $DOWNLOADHASH; then
228 echo "SHA1-Download:
229 2365ac0ac57cde3d43c63145e8251a3bd5410213 197 2010-08-18-2013.28.gz
230 $(sha1sum ${PATCHFILE}.gz | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE}.gz)000 $(basename ${PATCHFILE}.gz)
231SHA256-Download:
232 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
233 $(sha256sum ${PATCHFILE}.gz | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE}.gz)000 $(basename ${PATCHFILE}.gz)" >> $PATCHINDEX
234 fi
c355ea30
DK
235 generatereleasefiles '+1hour'
236 signreleasefiles
237 #find aptarchive -name 'Packages*' -type f -delete
238 testsuccess aptget update -o Debug::pkgAcquire::Diffs=1 "$@"
239 cp -f rootdir/tmp/testsuccess.output rootdir/tmp/aptgetupdate.output
240 testsuccess grep 'bytes (Limit is' rootdir/tmp/aptgetupdate.output
241 testnopackage oldstuff
25b86db1 242 testsuccessequal "$(cat ${PKGFILE}-new)
c355ea30 243" aptcache show apt newstuff
47d2bc78 244}
34d6ece7 245echo 'Debug::pkgAcquire::Diffs "true";
03bfbc96 246Debug::Acquire::Transaction "true";
34d6ece7 247Debug::pkgAcquire::rred "true";' > rootdir/etc/apt/apt.conf.d/rreddebug.conf
47d2bc78 248
d7a51997
DK
249testcase() {
250 testrun nohash -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=1 "$@"
251 testrun nohash -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=1 "$@"
4f51fd86 252
d7a51997
DK
253 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=1 "$@"
254 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=1 "$@"
255 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=0 "$@"
256 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=0 "$@"
f6d4ab9a 257
d7a51997
DK
258 sha256sum() {
259 echo '01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b -'
260 }
261 testrun -o Acquire::PDiffs::Merge=0 -o Acquire::ForceHash=SHA1 "$@"
262 testrun -o Acquire::PDiffs::Merge=1 -o Acquire::ForceHash=SHA1 "$@"
263 unset -f sha256sum
f6d4ab9a 264
d7a51997
DK
265 sha1sum() {
266 echo 'adc83b19e793491b1c6ea0fd8b46cd9f32e592fc -'
267 }
268 testrun -o Acquire::PDiffs::Merge=0 -o Acquire::ForceHash=SHA256 "$@"
269 testrun -o Acquire::PDiffs::Merge=1 -o Acquire::ForceHash=SHA256 "$@"
270 unset -f sha1sum
f6d4ab9a 271}
d7a51997
DK
272testcase -o Acquire::GzipIndexes=0
273testcase -o Acquire::GzipIndexes=1