]> git.saurik.com Git - apt.git/blob - test/integration/test-pdiff-usage
don't try other compressions on hashsum mismatch
[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
10 buildaptarchive
11 setupflataptarchive
12 changetowebserver
13
14 PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
15
16 wasmergeused() {
17 testsuccess aptget update "$@"
18
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
29 msgtest 'Check if the right pdiff merger was used'
30 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' rootdir/tmp/testsuccess.output; then
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() {
44 msgmsg "Testcase: setup the base with: $*"
45 find aptarchive -name 'Packages*' -type f -delete
46 cp ${PKGFILE} aptarchive/Packages
47 compressfile 'aptarchive/Packages'
48 generatereleasefiles
49 signreleasefiles
50 rm -rf aptarchive/Packages.diff rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
51 testsuccess aptget update "$@"
52 cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
53 testnopackage newstuff
54 testsuccessequal "$(cat ${PKGFILE})
55 " aptcache show apt oldstuff
56
57 msgmsg "Testcase: apply with one patch: $*"
58 cp ${PKGFILE}-new aptarchive/Packages
59 compressfile 'aptarchive/Packages'
60 mkdir -p aptarchive/Packages.diff
61 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
62 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
63 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
64 PATCHINDEX='aptarchive/Packages.diff/Index'
65 echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
66 SHA1-History:
67 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
68 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
69 SHA1-Patches:
70 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
71 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
72 SHA256-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
73 SHA256-History:
74 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
75 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
76 SHA256-Patches:
77 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
78 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
79 generatereleasefiles '+1hour'
80 signreleasefiles
81 find aptarchive -name 'Packages*' -type f -delete
82 wasmergeused "$@"
83 testnopackage oldstuff
84 testsuccessequal "$(cat ${PKGFILE}-new)
85 " aptcache show apt newstuff
86
87 msgmsg "Testcase: index is already up-to-date: $*"
88 find rootdir/var/lib/apt/lists -name '*diff_Index' -type f -delete
89 testsuccess aptget update "$@"
90 testequal 'Hit http://localhost:8080 InRelease
91 Reading package lists...' aptget update "$@" -o Debug::Acquire::Transaction=0 -o Debug::pkgAcquire::Diffs=0
92 testsuccessequal "$(cat ${PKGFILE}-new)
93 " aptcache show apt newstuff
94
95 msgmsg "Testcase: apply with two patches: $*"
96 cp ${PKGFILE}-new aptarchive/Packages
97 echo '
98 Package: futurestuff
99 Version: 1.0
100 Architecture: i386
101 Maintainer: Joe Sixpack <joe@example.org>
102 Installed-Size: 202
103 Filename: pool/futurestuff_1.0_i386.deb
104 Size: 202200
105 MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
106 SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
107 SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
108 Description: some cool and shiny future stuff
109 This package will appear in the next next mirror update
110 Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages
111
112 compressfile 'aptarchive/Packages'
113 PATCHFILE2="aptarchive/Packages.diff/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')"
114 diff -e ${PKGFILE}-new aptarchive/Packages > ${PATCHFILE2} || true
115 cat $PATCHFILE2 | gzip > ${PATCHFILE2}.gz
116 echo "SHA1-Current: $(sha1sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
117 SHA1-History:
118 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
119 $(sha1sum ${PKGFILE} | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}) $(basename ${PATCHFILE})
120 $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) $(basename ${PATCHFILE2})
121 SHA1-Patches:
122 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
123 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
124 $(sha1sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})
125 SHA256-Current: $(sha256sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
126 SHA256-History:
127 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
128 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
129 $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) $(basename ${PATCHFILE2})
130 SHA256-Patches:
131 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
132 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
133 $(sha256sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})" > $PATCHINDEX
134 generatereleasefiles '+2hour'
135 signreleasefiles
136 cp -a aptarchive/Packages Packages-future
137 find aptarchive -name 'Packages*' -type f -delete
138 rm -rf rootdir/var/lib/apt/lists
139 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
140 wasmergeused "$@"
141 testnopackage oldstuff
142 testsuccessequal "$(cat Packages-future)
143 " aptcache show apt newstuff futurestuff
144
145 msgmsg "Testcase: patch applying fails, but successful fallback: $*"
146 rm -rf rootdir/var/lib/apt/lists
147 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
148 cp ${PKGFILE}-new aptarchive/Packages
149 compressfile 'aptarchive/Packages'
150 mkdir -p aptarchive/Packages.diff
151 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
152 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
153 PATCHINDEX='aptarchive/Packages.diff/Index'
154 echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
155 SHA1-History:
156 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
157 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
158 SHA1-Patches:
159 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
160 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
161 SHA256-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
162 SHA256-History:
163 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
164 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
165 SHA256-Patches:
166 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
167 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
168 echo 'I am Mallory and I change files' >> $PATCHFILE
169 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
170 generatereleasefiles '+1hour'
171 signreleasefiles
172 testsuccess aptget update "$@"
173 testnopackage oldstuff
174 testsuccessequal "$(cat ${PKGFILE}-new)
175 " aptcache show apt newstuff
176
177 msgmsg "Testcase: pdiff patch bigger than index itself: $*"
178 rm -rf rootdir/var/lib/apt/lists
179 cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
180 cp ${PKGFILE}-new aptarchive/Packages
181 compressfile 'aptarchive/Packages'
182 mkdir -p aptarchive/Packages.diff
183 PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
184 diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
185 cat $PATCHFILE | gzip > ${PATCHFILE}.gz
186 PATCHINDEX='aptarchive/Packages.diff/Index'
187 echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
188 SHA1-History:
189 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
190 $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
191 SHA1-Patches:
192 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
193 $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE)000 $(basename $PATCHFILE)
194 SHA256-Current: $(sha256sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
195 SHA256-History:
196 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
197 $(sha256sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
198 SHA256-Patches:
199 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
200 $(sha256sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE)000 $(basename $PATCHFILE)" > $PATCHINDEX
201 generatereleasefiles '+1hour'
202 signreleasefiles
203 #find aptarchive -name 'Packages*' -type f -delete
204 testsuccess aptget update -o Debug::pkgAcquire::Diffs=1 "$@"
205 cp -f rootdir/tmp/testsuccess.output rootdir/tmp/aptgetupdate.output
206 testsuccess grep 'bytes (Limit is' rootdir/tmp/aptgetupdate.output
207 testnopackage oldstuff
208 testsuccessequal "$(cat ${PKGFILE}-new)
209 " aptcache show apt newstuff
210 }
211 echo 'Debug::pkgAcquire::Diffs "true";
212 Debug::Acquire::Transaction "true";
213 Debug::pkgAcquire::rred "true";' > rootdir/etc/apt/apt.conf.d/rreddebug.conf
214
215 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=1
216 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=1
217 testrun -o Acquire::PDiffs::Merge=0 -o APT::Get::List-Cleanup=0
218 testrun -o Acquire::PDiffs::Merge=1 -o APT::Get::List-Cleanup=0
219
220 sha256sum() {
221 echo '01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b -'
222 }
223 testrun -o Acquire::PDiffs::Merge=0 -o Acquire::ForceHash=SHA1
224 testrun -o Acquire::PDiffs::Merge=1 -o Acquire::ForceHash=SHA1
225
226 unset -f sha256sum
227 sha1sum() {
228 echo 'adc83b19e793491b1c6ea0fd8b46cd9f32e592fc -'
229 }
230 testrun -o Acquire::PDiffs::Merge=0 -o Acquire::ForceHash=SHA256
231 testrun -o Acquire::PDiffs::Merge=1 -o Acquire::ForceHash=SHA256