]> git.saurik.com Git - apt.git/blame - test/integration/test-pdiff-usage
test-apt-download-progress: Allow smaller progress change
[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'
c5ede4ca 9confighashes 'SHA1' 'SHA256'
f213b6ea
DK
10
11buildaptarchive
12setupflataptarchive
63c71412 13changetowebserver -o aptwebserver::support::modified-since=false
f213b6ea 14
f213b6ea 15PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
47d2bc78 16
47d2bc78 17wasmergeused() {
ba6b79bd 18 testsuccess aptget 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
47d2bc78 30 msgtest 'Check if the right pdiff merger was used'
ba6b79bd 31 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' rootdir/tmp/testsuccess.output; then
47d2bc78
DK
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
44testrun() {
34d6ece7 45 msgmsg "Testcase: setup the base with: $*"
4f51fd86
DK
46 local DOWNLOADHASH=true
47 if [ "$1" = 'nohash' ]; then DOWNLOADHASH=false; shift; fi
47d2bc78
DK
48 find aptarchive -name 'Packages*' -type f -delete
49 cp ${PKGFILE} aptarchive/Packages
50 compressfile 'aptarchive/Packages'
51 generatereleasefiles
52 signreleasefiles
146f7715 53 rm -rf aptarchive/Packages.diff rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
47d2bc78
DK
54 testsuccess aptget update "$@"
55 cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
56 testnopackage newstuff
25b86db1 57 testsuccessequal "$(cat ${PKGFILE})
f213b6ea
DK
58" aptcache show apt oldstuff
59
34d6ece7 60 msgmsg "Testcase: apply with one patch: $*"
47d2bc78
DK
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)
f213b6ea
DK
69SHA1-History:
70 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
71 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
72SHA1-Patches:
f6d4ab9a
DK
73 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
74 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
75SHA256-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
76SHA256-History:
77 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
78 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
79SHA256-Patches:
80 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
81 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
4f51fd86
DK
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)
86SHA256-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
47d2bc78
DK
91 generatereleasefiles '+1hour'
92 signreleasefiles
93 find aptarchive -name 'Packages*' -type f -delete
94 wasmergeused "$@"
95 testnopackage oldstuff
25b86db1 96 testsuccessequal "$(cat ${PKGFILE}-new)
47d2bc78 97" aptcache show apt newstuff
f213b6ea 98
34d6ece7 99 msgmsg "Testcase: apply with two patches: $*"
47d2bc78
DK
100 cp ${PKGFILE}-new aptarchive/Packages
101 echo '
102Package: futurestuff
103Version: 1.0
104Architecture: i386
105Maintainer: Joe Sixpack <joe@example.org>
106Installed-Size: 202
107Filename: pool/futurestuff_1.0_i386.deb
108Size: 202200
109MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
110SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
111SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
112Description: some cool and shiny future stuff
113 This package will appear in the next next mirror update
114Description-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)
121SHA1-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})
125SHA1-Patches:
f6d4ab9a 126 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
47d2bc78 127 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
f6d4ab9a
DK
128 $(sha1sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})
129SHA256-Current: $(sha256sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
130SHA256-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})
134SHA256-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
4f51fd86
DK
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)
143SHA256-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
47d2bc78
DK
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
25b86db1 157 testsuccessequal "$(cat Packages-future)
47d2bc78
DK
158" aptcache show apt newstuff futurestuff
159
34d6ece7 160 msgmsg "Testcase: patch applying fails, but successful fallback: $*"
47d2bc78
DK
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
4f51fd86 168 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
47d2bc78
DK
169 PATCHINDEX='aptarchive/Packages.diff/Index'
170 echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
171SHA1-History:
172 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
173 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
174SHA1-Patches:
f6d4ab9a
DK
175 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
176 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
177SHA256-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
178SHA256-History:
179 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
180 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
181SHA256-Patches:
182 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
183 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
4f51fd86
DK
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)
188SHA256-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
6d3e5bd8 192 # needs to look like a valid command, otherwise the parser will fail before hashes are checked
4f51fd86 193 echo '1d' > $PATCHFILE
47d2bc78
DK
194 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
195 generatereleasefiles '+1hour'
196 signreleasefiles
197 testsuccess aptget update "$@"
36795154 198 cp -f rootdir/tmp/testsuccess.output rootdir/tmp/aptgetupdate.output
4f51fd86 199 testsuccess grep 'Hash Sum mismatch' rootdir/tmp/aptgetupdate.output
47d2bc78 200 testnopackage oldstuff
25b86db1 201 testsuccessequal "$(cat ${PKGFILE}-new)
47d2bc78 202" aptcache show apt newstuff
c355ea30
DK
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)
215SHA1-History:
216 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
217 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
218SHA1-Patches:
219 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
220 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE)000 $(basename $PATCHFILE)
221SHA256-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
222SHA256-History:
223 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
224 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
225SHA256-Patches:
226 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
227 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE)000 $(basename $PATCHFILE)" > $PATCHINDEX
4f51fd86
DK
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)
232SHA256-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
c355ea30
DK
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
25b86db1 243 testsuccessequal "$(cat ${PKGFILE}-new)
c355ea30 244" aptcache show apt newstuff
47d2bc78 245}
34d6ece7 246echo 'Debug::pkgAcquire::Diffs "true";
03bfbc96 247Debug::Acquire::Transaction "true";
34d6ece7 248Debug::pkgAcquire::rred "true";' > rootdir/etc/apt/apt.conf.d/rreddebug.conf
47d2bc78 249
d7a51997
DK
250testcase() {
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 "$@"
4f51fd86 253
d7a51997
DK
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 "$@"
f6d4ab9a 258
d7a51997
DK
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
f6d4ab9a 265
d7a51997
DK
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
f6d4ab9a 272}
d7a51997
DK
273testcase -o Acquire::GzipIndexes=0
274testcase -o Acquire::GzipIndexes=1