4 TESTDIR
="$(readlink -f "$(dirname "$0")")"
8 configarchitecture 'i386'
15 cat >rootdir/etc/apt/apt.conf.d/contents.conf <<EOF
16 Acquire::IndexTargets::deb::Contents {
17 MetaKey "\
$(COMPONENT)/Contents
-\
$(ARCHITECTURE)";
18 ShortDescription "Contents
";
19 Description "\
$(RELEASE)/\
$(COMPONENT) \
$(ARCHITECTURE) Contents
";
20 MetaKey "\
$(COMPONENT)/Contents
-\
$(ARCHITECTURE)";
21 flatMetaKey "Contents
-\
$(ARCHITECTURE)";
22 flatDescription "\
$(RELEASE) \
$(ARCHITECTURE) Contents
";
26 PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
27 echo 'contents for stuff' > aptarchive
/Contents
-i386
28 compressfile aptarchive
/Contents
-i386
29 echo 'hacked' > aptarchive
/hacked
-i386
30 compressfile aptarchive
/hacked
-i386
33 testsuccess apt update
"$@"
35 msgtest
'No intermediate patch files' 'still exist'
36 local EDS
="$(find rootdir/var/lib/apt/lists -name '*.ed' -o -name '*.ed.*')"
37 if [ -z "$EDS" ]; then
45 if echo "$*" | grep -q -- '-o test::cannot-use-pdiff=1'; then
46 msgtest
'Check if pdiff was' 'not used'
47 cp -a rootdir
/tmp
/testsuccess.output rootdir
/tmp
/aptupdate.output
48 testsuccess
--nomsg grep "diff/Index with Message: Couldn't parse pdiff index" rootdir
/tmp
/aptupdate.output
52 msgtest
'Check if the right pdiff merger was used'
53 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' rootdir
/tmp
/testsuccess.output
; then
54 if echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
57 msgfail
"Merge shouldn't have been used, but was"
59 elif echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
60 msgfail
"Merge should have been used, but wasn't"
67 configcompression
'.' 'xz'
68 msgmsg
"Testcase: setup the base with: $*"
69 find aptarchive
-name 'Packages*' -type f
-delete
70 cp "${PKGFILE}" aptarchive
/Packages
71 compressfile
'aptarchive/Packages'
74 rm -rf aptarchive
/Packages.
diff rootdir
/var
/lib
/apt
/lists rootdir
/var
/lib
/apt
/lists
-bak
75 testsuccess aptget update
"$@"
76 cp -a rootdir
/var
/lib
/apt
/lists rootdir
/var
/lib
/apt
/lists
-bak
77 testnopackage newstuff
78 testsuccessequal
"$(cat "${PKGFILE}")
79 " aptcache show apt oldstuff
80 configcompression
'.' 'gz'
82 # see if the code deals properly with leftover partial files
85 msgmsg
"Testcase: apply with one patch: $*"
86 find aptarchive
-name 'Packages*' -type f
-delete
87 cp "${PKGFILE}-new" aptarchive
/Packages
88 compressfile
'aptarchive/Packages'
89 mkdir -p aptarchive
/Packages.
diff
90 PATCHFILE
="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
91 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
92 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
93 PATCHINDEX
='aptarchive/Packages.diff/Index'
94 echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
96 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
97 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
99 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
100 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
102 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
103 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" > "$PATCHINDEX"
105 generatereleasefiles
'+1hour'
107 find aptarchive
-name 'Packages*' -type f
-delete
109 testnopackage oldstuff
110 testsuccessequal
"$(cat "${PKGFILE}-new")
111 " aptcache show apt newstuff
113 msgmsg
"Testcase: SHA1-only patches are not used: $*"
114 find aptarchive
-name 'Packages*' -type f
-delete
115 cp "${PKGFILE}-new" aptarchive
/Packages
116 compressfile
'aptarchive/Packages'
117 mkdir -p aptarchive
/Packages.
diff
118 PATCHFILE
="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
119 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
120 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
121 PATCHINDEX
='aptarchive/Packages.diff/Index'
122 echo "SHA1-Current: $(sha1sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
124 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
125 $(sha1sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
127 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
128 $(sha1sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
130 2365ac0ac57cde3d43c63145e8251a3bd5410213 197 2010-08-18-2013.28.gz
131 $(sha1sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" > "$PATCHINDEX"
132 generatereleasefiles
'+1hour'
134 rm -rf rootdir
/var
/lib
/apt
/lists
135 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
136 wasmergeused
"$@" -o test::cannot
-use-pdiff=1
137 testnopackage oldstuff
138 testsuccessequal
"$(cat "${PKGFILE}-new")
139 " aptcache show apt newstuff
141 msgmsg
"Testcase: no download-hashes patches are not used: $*"
142 find aptarchive
-name 'Packages*' -type f
-delete
143 cp "${PKGFILE}-new" aptarchive
/Packages
144 compressfile
'aptarchive/Packages'
145 mkdir -p aptarchive
/Packages.
diff
146 PATCHFILE
="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
147 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
148 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
149 PATCHINDEX
='aptarchive/Packages.diff/Index'
150 echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
152 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
153 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
155 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
156 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")" > "$PATCHINDEX"
157 generatereleasefiles
'+1hour'
159 rm -rf rootdir
/var
/lib
/apt
/lists
160 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
161 wasmergeused
"$@" -o test::cannot
-use-pdiff=1
162 testnopackage oldstuff
163 testsuccessequal
"$(cat "${PKGFILE}-new")
164 " aptcache show apt newstuff
166 msgmsg
"Testcase: apply with two patches: $*"
167 cp "${PKGFILE}-new" aptarchive
/Packages
172 Maintainer: Joe Sixpack <joe@example.org>
174 Filename: pool/futurestuff_1.0_i386.deb
176 SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
177 Description: some cool and shiny future stuff
178 This package will appear in the next next mirror update
179 Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive
/Packages
181 compressfile
'aptarchive/Packages'
182 PATCHFILE2
="aptarchive/Packages.diff/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')"
183 diff -e "${PKGFILE}-new" aptarchive
/Packages
> "${PATCHFILE2}" || true
184 cat "$PATCHFILE2" | gzip > "${PATCHFILE2}.gz"
185 echo "SHA256-Current: $(sha256sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
187 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
188 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
189 $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new") $(basename "${PATCHFILE2}")
191 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
192 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
193 $(sha256sum "${PATCHFILE2}" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE2}") $(basename "${PATCHFILE2}")
195 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
196 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")
197 $(sha256sum "${PATCHFILE2}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE2}.gz") $(basename "${PATCHFILE2}.gz")" > "$PATCHINDEX"
199 generatereleasefiles
'+2hour'
201 cp -a aptarchive
/Packages Packages
-future
202 find aptarchive
-name 'Packages*' -type f
-delete
203 rm -rf rootdir
/var
/lib
/apt
/lists
204 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
206 testnopackage oldstuff
207 testsuccessequal
"$(cat Packages-future)
208 " aptcache show apt newstuff futurestuff
210 # we reuse the archive state of the previous test here
211 msgmsg
"Testcase: pdiff handling is stopped if transaction fails $*"
212 rm -rf rootdir
/var
/lib
/apt
/lists
213 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
214 cp Packages
-future aptarchive
/Packages
215 rm -f rootdir
/var
/lib
/apt
/lists
/*_Contents
-*
216 webserverconfig
'aptwebserver::overwrite::.*Contents-.*::filename' '/hacked-i386.gz'
217 testfailure apt update
"$@" -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::http
=1
218 webserverconfig
'aptwebserver::overwrite::.*Contents-.*::filename' '/Contents-i386.gz'
219 cp rootdir
/tmp
/testfailure.output patchdownload.output
220 testfailure
grep 'rred:600' patchdownload.output
221 testnopackage newstuff futurestuff
222 testsuccessequal
"$(cat "${PKGFILE}")
223 " aptcache show apt oldstuff
225 # we reuse the archive state of the previous test here
226 msgmsg
"Testcase: downloading a patch fails, but successful fallback: $*"
227 rm -rf rootdir
/var
/lib
/apt
/lists
228 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
229 cp Packages
-future aptarchive
/Packages
231 testsuccess apt update
"$@"
232 cp rootdir
/tmp
/testsuccess.output patchdownload.output
233 testsuccess
grep '^Falling back to normal index file acquire' patchdownload.output
234 testnopackage oldstuff
235 testsuccessequal
"$(cat Packages-future)
236 " aptcache show apt newstuff futurestuff
238 msgmsg
"Testcase: patch applying fails, but successful fallback: $*"
239 rm -rf rootdir
/var
/lib
/apt
/lists
240 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
241 cp "${PKGFILE}-new" aptarchive
/Packages
242 compressfile
'aptarchive/Packages'
243 mkdir -p aptarchive
/Packages.
diff
244 PATCHFILE
="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
245 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
246 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
247 PATCHINDEX
='aptarchive/Packages.diff/Index'
248 echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
250 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
251 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
253 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
254 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
256 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
257 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" > "$PATCHINDEX"
258 # needs to look like a valid command, otherwise the parser will fail before hashes are checked
259 echo '1d' > "$PATCHFILE"
260 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
261 generatereleasefiles
'+1hour'
263 testsuccess apt update
"$@"
264 cp -f rootdir
/tmp
/testsuccess.output rootdir
/tmp
/aptupdate.output
265 testsuccess
grep 'Hash Sum mismatch' rootdir
/tmp
/aptupdate.output
266 testnopackage oldstuff
267 testsuccessequal
"$(cat "${PKGFILE}-new")
268 " aptcache show apt newstuff
270 msgmsg
"Testcase: pdiff patch bigger than index itself: $*"
271 rm -rf rootdir
/var
/lib
/apt
/lists
272 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
273 # the general testcode checks for leftovers in partial, but as this file
274 # is never touched in this test as it exits earlier its not a leftover…
275 rm -f rootdir
/var
/lib
/apt
/lists
/partial
/localhost
:${APTHTTPPORT}_Packages
276 cp "${PKGFILE}-new" aptarchive
/Packages
277 compressfile
'aptarchive/Packages'
278 mkdir -p aptarchive
/Packages.
diff
279 PATCHFILE
="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
280 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
281 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
282 PATCHINDEX
='aptarchive/Packages.diff/Index'
283 echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
285 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
286 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
288 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
289 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
291 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
292 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz")000 $(basename "${PATCHFILE}.gz")" > "$PATCHINDEX"
293 generatereleasefiles
'+1hour'
295 testsuccess apt update
-o Debug
::pkgAcquire
::Diffs
=1 "$@"
296 cp -f rootdir
/tmp
/testsuccess.output rootdir
/tmp
/aptupdate.output
297 testsuccess
grep 'bytes (Limit is' rootdir
/tmp
/aptupdate.output
298 testnopackage oldstuff
299 testsuccessequal
"$(cat "${PKGFILE}-new")
300 " aptcache show apt newstuff
302 echo 'Debug::pkgAcquire::Diffs "true";
303 Debug::Acquire::Transaction "true";
304 Debug::pkgAcquire::rred "true";' > rootdir
/etc
/apt
/apt.conf.d
/rreddebug.conf
307 testrun
-o Acquire
::PDiffs
::Merge
=0 -o APT
::Get
::List
-Cleanup=1 "$@"
308 testrun
-o Acquire
::PDiffs
::Merge
=1 -o APT
::Get
::List
-Cleanup=1 "$@"
309 testrun
-o Acquire
::PDiffs
::Merge
=0 -o APT
::Get
::List
-Cleanup=0 "$@"
310 testrun
-o Acquire
::PDiffs
::Merge
=1 -o APT
::Get
::List
-Cleanup=0 "$@"
312 partialleftovers
() { touch "rootdir/var/lib/apt/lists-bak/partial/localhost:${APTHTTPPORT}_Packages"; }
313 aptautotest_apt_update
() { aptautotest_aptget_update
"$@"; testsuccess
test -e "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_Packages"; }
314 testcase
-o Acquire
::IndexTargets
::deb
::Packages
::KeepCompressed
=false
315 partialleftovers
() { touch "rootdir/var/lib/apt/lists-bak/partial/localhost:${APTHTTPPORT}_Packages.$LOWCOSTEXT"; }
316 aptautotest_apt_update
() { aptautotest_aptget_update
"$@"; testsuccess
test -e "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_Packages.$LOWCOSTEXT"; }
317 testcase
-o Acquire
::IndexTargets
::deb
::Packages
::KeepCompressed
=true
320 partialleftovers
() { touch "rootdir/var/lib/apt/lists-bak/partial/localhost:${APTHTTPPORT}_redirectme_Packages.$LOWCOSTEXT"; }
321 webserverconfig
'aptwebserver::redirect::replace::/redirectme/' "http://0.0.0.0:${APTHTTPPORT}/"
322 rewritesourceslist
"http://localhost:${APTHTTPPORT}/redirectme"
323 aptautotest_apt_update
() {
324 aptautotest_aptget_update
"$@"
325 testsuccess
test -e "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_redirectme_Packages.$LOWCOSTEXT"
326 testempty
find rootdir
/var
/lib
/apt
/lists
-type f \
! \
( -name lock
-o -name '*_redirectme_*' \
)
328 testcase
-o Acquire
::IndexTargets
::deb
::Packages
::KeepCompressed
=true