4 TESTDIR
="$(readlink -f "$(dirname "$0")")"
8 configarchitecture 'i386'
13 changetowebserver -o aptwebserver::support::modified-since=false
15 PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
18 testsuccess apt update
"$@"
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
30 if echo "$*" | grep -q -- '-o test::cannot-use-pdiff=1'; then
31 msgtest
'Check if pdiff was' 'not used'
32 cp -a rootdir
/tmp
/testsuccess.output rootdir
/tmp
/aptupdate.output
33 testsuccess
--nomsg grep 'diff_Index: Did not find a good hashsum in the index' rootdir
/tmp
/aptupdate.output
37 msgtest
'Check if the right pdiff merger was used'
38 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' rootdir
/tmp
/testsuccess.output
; then
39 if echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
42 msgfail
"Merge shouldn't have been used, but was"
44 elif echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
45 msgfail
"Merge should have been used, but wasn't"
52 configcompression
'.' 'xz'
53 msgmsg
"Testcase: setup the base with: $*"
54 local DOWNLOADHASH
=true
55 if [ "$1" = 'nohash' ]; then DOWNLOADHASH
=false
; shift; fi
56 find aptarchive
-name 'Packages*' -type f
-delete
57 cp "${PKGFILE}" aptarchive
/Packages
58 compressfile
'aptarchive/Packages'
61 rm -rf aptarchive
/Packages.
diff rootdir
/var
/lib
/apt
/lists rootdir
/var
/lib
/apt
/lists
-bak
62 testsuccess aptget update
"$@"
63 cp -a rootdir
/var
/lib
/apt
/lists rootdir
/var
/lib
/apt
/lists
-bak
64 testnopackage newstuff
65 testsuccessequal
"$(cat "${PKGFILE}")
66 " aptcache show apt oldstuff
67 configcompression
'.' 'gz'
69 # see if the code deals properly with leftover partial files
70 touch rootdir
/var
/lib
/apt
/lists
-bak/partial
/localhost
:${APTHTTPPORT}_Packages
72 msgmsg
"Testcase: apply with one patch: $*"
73 find aptarchive
-name 'Packages*' -type f
-delete
74 cp "${PKGFILE}-new" aptarchive
/Packages
75 compressfile
'aptarchive/Packages'
76 mkdir -p aptarchive
/Packages.
diff
77 PATCHFILE
="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
78 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
79 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
80 PATCHINDEX
='aptarchive/Packages.diff/Index'
81 echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
83 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
84 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
86 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
87 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")" > "$PATCHINDEX"
88 if $DOWNLOADHASH; then
89 echo "SHA256-Download:
90 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
91 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" >> "$PATCHINDEX"
94 generatereleasefiles
'+1hour'
96 find aptarchive
-name 'Packages*' -type f
-delete
98 testnopackage oldstuff
99 testsuccessequal
"$(cat "${PKGFILE}-new")
100 " aptcache show apt newstuff
102 msgmsg
"Testcase: apply with one patch and SHA1 only: $*"
103 find aptarchive
-name 'Packages*' -type f
-delete
104 cp "${PKGFILE}-new" aptarchive
/Packages
105 compressfile
'aptarchive/Packages'
106 mkdir -p aptarchive
/Packages.
diff
107 PATCHFILE
="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
108 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
109 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
110 PATCHINDEX
='aptarchive/Packages.diff/Index'
111 echo "SHA1-Current: $(sha1sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
113 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
114 $(sha1sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
116 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
117 $(sha1sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")" > "$PATCHINDEX"
118 if $DOWNLOADHASH; then
120 2365ac0ac57cde3d43c63145e8251a3bd5410213 197 2010-08-18-2013.28.gz
121 $(sha1sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" >> "$PATCHINDEX"
124 generatereleasefiles
'+1hour'
126 rm -rf rootdir
/var
/lib
/apt
/lists
127 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
128 wasmergeused
"$@" -o test::cannot
-use-pdiff=1
129 testnopackage oldstuff
130 testsuccessequal
"$(cat "${PKGFILE}-new")
131 " aptcache show apt newstuff
133 msgmsg
"Testcase: apply with two patches: $*"
134 cp "${PKGFILE}-new" aptarchive
/Packages
139 Maintainer: Joe Sixpack <joe@example.org>
141 Filename: pool/futurestuff_1.0_i386.deb
143 SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
144 Description: some cool and shiny future stuff
145 This package will appear in the next next mirror update
146 Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive
/Packages
148 compressfile
'aptarchive/Packages'
149 PATCHFILE2
="aptarchive/Packages.diff/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')"
150 diff -e "${PKGFILE}-new" aptarchive
/Packages
> "${PATCHFILE2}" || true
151 cat "$PATCHFILE2" | gzip > "${PATCHFILE2}.gz"
152 echo "SHA256-Current: $(sha256sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
154 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
155 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
156 $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new") $(basename "${PATCHFILE2}")
158 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
159 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
160 $(sha256sum "${PATCHFILE2}" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE2}") $(basename "${PATCHFILE2}")" > "$PATCHINDEX"
161 if $DOWNLOADHASH; then
162 echo "SHA256-Download:
163 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
164 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")
165 $(sha256sum "${PATCHFILE2}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE2}.gz") $(basename "${PATCHFILE2}.gz")" >> "$PATCHINDEX"
168 generatereleasefiles
'+2hour'
170 cp -a aptarchive
/Packages Packages
-future
171 find aptarchive
-name 'Packages*' -type f
-delete
172 rm -rf rootdir
/var
/lib
/apt
/lists
173 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
175 testnopackage oldstuff
176 testsuccessequal
"$(cat Packages-future)
177 " aptcache show apt newstuff futurestuff
179 # we reuse the archive state of the previous test here
180 msgmsg
"Testcase: downloading a patch fails, but successful fallback: $*"
181 rm -rf rootdir
/var
/lib
/apt
/lists
182 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
183 cp Packages
-future aptarchive
/Packages
185 testsuccess apt update
"$@"
186 cp rootdir
/tmp
/testsuccess.output patchdownload.output
187 testsuccess
grep '^Falling back to normal index file acquire' patchdownload.output
188 testnopackage oldstuff
189 testsuccessequal
"$(cat Packages-future)
190 " aptcache show apt newstuff futurestuff
192 msgmsg
"Testcase: patch applying fails, but successful fallback: $*"
193 rm -rf rootdir
/var
/lib
/apt
/lists
194 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
195 cp "${PKGFILE}-new" aptarchive
/Packages
196 compressfile
'aptarchive/Packages'
197 mkdir -p aptarchive
/Packages.
diff
198 PATCHFILE
="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
199 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
200 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
201 PATCHINDEX
='aptarchive/Packages.diff/Index'
202 echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
204 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
205 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
207 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
208 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")" > $PATCHINDEX
209 if $DOWNLOADHASH; then
210 echo "SHA256-Download:
211 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
212 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" >> $PATCHINDEX
214 # needs to look like a valid command, otherwise the parser will fail before hashes are checked
215 echo '1d' > "$PATCHFILE"
216 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
217 generatereleasefiles
'+1hour'
219 testsuccess apt update
"$@"
220 cp -f rootdir
/tmp
/testsuccess.output rootdir
/tmp
/aptupdate.output
221 testsuccess
grep 'Hash Sum mismatch' rootdir
/tmp
/aptupdate.output
222 testnopackage oldstuff
223 testsuccessequal
"$(cat "${PKGFILE}-new")
224 " aptcache show apt newstuff
226 msgmsg
"Testcase: pdiff patch bigger than index itself: $*"
227 rm -rf rootdir
/var
/lib
/apt
/lists
228 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
229 # the general testcode checks for leftovers in partial, but as this file
230 # is never touched in this test as it exits earlier its not a leftover…
231 rm -f rootdir
/var
/lib
/apt
/lists
/partial
/localhost
:${APTHTTPPORT}_Packages
232 cp "${PKGFILE}-new" aptarchive
/Packages
233 compressfile
'aptarchive/Packages'
234 mkdir -p aptarchive
/Packages.
diff
235 PATCHFILE
="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
236 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
237 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
238 PATCHINDEX
='aptarchive/Packages.diff/Index'
239 BIGSIZE
="$(stat -c%s "$PATCHFILE")"
240 if ! $DOWNLOADHASH; then
241 BIGSIZE
="${BIGSIZE}000"
243 echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
245 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
246 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
248 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
249 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $BIGSIZE $(basename "$PATCHFILE")" > "$PATCHINDEX"
250 if $DOWNLOADHASH; then
251 echo "SHA256-Download:
252 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
253 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz")000 $(basename "${PATCHFILE}.gz")" >> "$PATCHINDEX"
255 generatereleasefiles
'+1hour'
257 testsuccess apt update
-o Debug
::pkgAcquire
::Diffs
=1 "$@"
258 cp -f rootdir
/tmp
/testsuccess.output rootdir
/tmp
/aptupdate.output
259 testsuccess
grep 'bytes (Limit is' rootdir
/tmp
/aptupdate.output
260 testnopackage oldstuff
261 testsuccessequal
"$(cat "${PKGFILE}-new")
262 " aptcache show apt newstuff
264 echo 'Debug::pkgAcquire::Diffs "true";
265 Debug::Acquire::Transaction "true";
266 Debug::pkgAcquire::rred "true";' > rootdir
/etc
/apt
/apt.conf.d
/rreddebug.conf
269 testrun nohash
-o Acquire
::PDiffs
::Merge
=0 -o APT
::Get
::List
-Cleanup=1 "$@"
270 testrun nohash
-o Acquire
::PDiffs
::Merge
=1 -o APT
::Get
::List
-Cleanup=1 "$@"
272 testrun
-o Acquire
::PDiffs
::Merge
=0 -o APT
::Get
::List
-Cleanup=1 "$@"
273 testrun
-o Acquire
::PDiffs
::Merge
=1 -o APT
::Get
::List
-Cleanup=1 "$@"
274 testrun
-o Acquire
::PDiffs
::Merge
=0 -o APT
::Get
::List
-Cleanup=0 "$@"
275 testrun
-o Acquire
::PDiffs
::Merge
=1 -o APT
::Get
::List
-Cleanup=0 "$@"
277 aptautotest_apt_update
() { aptautotest_aptget_update
"$@"; testsuccess
test -e "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_Packages"; }
278 testcase
-o Acquire
::IndexTargets
::deb
::Packages
::KeepCompressed
=false
279 aptautotest_apt_update
() { aptautotest_aptget_update
"$@"; testsuccess
test -e "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_Packages.$LOWCOSTEXT"; }
280 testcase
-o Acquire
::IndexTargets
::deb
::Packages
::KeepCompressed
=true