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