4 TESTDIR
="$(readlink -f "$(dirname "$0")")"
8 configarchitecture 'i386'
9 confighashes 'SHA1' 'SHA256'
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 msgtest
'Check if the right pdiff merger was used'
31 if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' rootdir
/tmp
/testsuccess.output
; then
32 if echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
35 msgfail
"Merge shouldn't have been used, but was"
37 elif echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
38 msgfail
"Merge should have been used, but wasn't"
45 configcompression
'.' 'xz'
46 msgmsg
"Testcase: setup the base with: $*"
47 local DOWNLOADHASH
=true
48 if [ "$1" = 'nohash' ]; then DOWNLOADHASH
=false
; shift; fi
49 find aptarchive
-name 'Packages*' -type f
-delete
50 cp "${PKGFILE}" aptarchive
/Packages
51 compressfile
'aptarchive/Packages'
54 rm -rf aptarchive
/Packages.
diff rootdir
/var
/lib
/apt
/lists rootdir
/var
/lib
/apt
/lists
-bak
55 testsuccess aptget update
"$@"
56 cp -a rootdir
/var
/lib
/apt
/lists rootdir
/var
/lib
/apt
/lists
-bak
57 testnopackage newstuff
58 testsuccessequal
"$(cat "${PKGFILE}")
59 " aptcache show apt oldstuff
60 configcompression
'.' 'gz'
62 msgmsg
"Testcase: apply with one patch: $*"
63 find aptarchive
-name 'Packages*' -type f
-delete
64 cp "${PKGFILE}-new" aptarchive
/Packages
65 compressfile
'aptarchive/Packages'
66 mkdir -p aptarchive
/Packages.
diff
67 PATCHFILE
="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
68 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
69 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
70 PATCHINDEX
='aptarchive/Packages.diff/Index'
71 echo "SHA1-Current: $(sha1sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
73 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
74 $(sha1sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
76 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
77 $(sha1sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
78 SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
80 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
81 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
83 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
84 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")" > "$PATCHINDEX"
85 if $DOWNLOADHASH; then
87 2365ac0ac57cde3d43c63145e8251a3bd5410213 197 2010-08-18-2013.28.gz
88 $(sha1sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")
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 two patches: $*"
103 cp "${PKGFILE}-new" aptarchive
/Packages
108 Maintainer: Joe Sixpack <joe@example.org>
110 Filename: pool/futurestuff_1.0_i386.deb
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
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)
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}")
129 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
130 $(sha1sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
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)
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}")
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"
141 if $DOWNLOADHASH; then
143 2365ac0ac57cde3d43c63145e8251a3bd5410213 197 2010-08-18-2013.28.gz
144 $(sha1sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")
145 $(sha1sum "${PATCHFILE2}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE2}.gz") $(basename "${PATCHFILE2}.gz")
147 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
148 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")
149 $(sha256sum "${PATCHFILE2}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE2}.gz") $(basename "${PATCHFILE2}.gz")" >> "$PATCHINDEX"
152 generatereleasefiles
'+2hour'
154 cp -a aptarchive
/Packages Packages
-future
155 find aptarchive
-name 'Packages*' -type f
-delete
156 rm -rf rootdir
/var
/lib
/apt
/lists
157 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
159 testnopackage oldstuff
160 testsuccessequal
"$(cat Packages-future)
161 " aptcache show apt newstuff futurestuff
163 msgmsg
"Testcase: patch applying fails, but successful fallback: $*"
164 rm -rf rootdir
/var
/lib
/apt
/lists
165 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
166 cp "${PKGFILE}-new" aptarchive
/Packages
167 compressfile
'aptarchive/Packages'
168 mkdir -p aptarchive
/Packages.
diff
169 PATCHFILE
="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
170 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
171 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
172 PATCHINDEX
='aptarchive/Packages.diff/Index'
173 echo "SHA1-Current: $(sha1sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
175 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
176 $(sha1sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
178 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
179 $(sha1sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
180 SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
182 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
183 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
185 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
186 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")" > $PATCHINDEX
187 if $DOWNLOADHASH; then
189 2365ac0ac57cde3d43c63145e8251a3bd5410213 197 2010-08-18-2013.28.gz
190 $(sha1sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")
192 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
193 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" >> $PATCHINDEX
195 # needs to look like a valid command, otherwise the parser will fail before hashes are checked
196 echo '1d' > "$PATCHFILE"
197 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
198 generatereleasefiles
'+1hour'
200 testsuccess apt update
"$@"
201 cp -f rootdir
/tmp
/testsuccess.output rootdir
/tmp
/aptupdate.output
202 testsuccess
grep 'Hash Sum mismatch' rootdir
/tmp
/aptupdate.output
203 testnopackage oldstuff
204 testsuccessequal
"$(cat "${PKGFILE}-new")
205 " aptcache show apt newstuff
207 msgmsg
"Testcase: pdiff patch bigger than index itself: $*"
208 rm -rf rootdir
/var
/lib
/apt
/lists
209 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
210 cp "${PKGFILE}-new" aptarchive
/Packages
211 compressfile
'aptarchive/Packages'
212 mkdir -p aptarchive
/Packages.
diff
213 PATCHFILE
="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
214 diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
215 cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
216 PATCHINDEX
='aptarchive/Packages.diff/Index'
217 echo "SHA1-Current: $(sha1sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
219 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
220 $(sha1sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
222 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
223 $(sha1sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE")000 $(basename "$PATCHFILE")
224 SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
226 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
227 $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
229 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
230 $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE")000 $(basename "$PATCHFILE")" > "$PATCHINDEX"
231 if $DOWNLOADHASH; then
233 2365ac0ac57cde3d43c63145e8251a3bd5410213 197 2010-08-18-2013.28.gz
234 $(sha1sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz")000 $(basename "${PATCHFILE}.gz")
236 d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
237 $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz")000 $(basename "${PATCHFILE}.gz")" >> "$PATCHINDEX"
239 generatereleasefiles
'+1hour'
241 testsuccess apt update
-o Debug
::pkgAcquire
::Diffs
=1 "$@"
242 cp -f rootdir
/tmp
/testsuccess.output rootdir
/tmp
/aptupdate.output
243 testsuccess
grep 'bytes (Limit is' rootdir
/tmp
/aptupdate.output
244 testnopackage oldstuff
245 testsuccessequal
"$(cat "${PKGFILE}-new")
246 " aptcache show apt newstuff
248 echo 'Debug::pkgAcquire::Diffs "true";
249 Debug::Acquire::Transaction "true";
250 Debug::pkgAcquire::rred "true";' > rootdir
/etc
/apt
/apt.conf.d
/rreddebug.conf
253 testrun nohash
-o Acquire
::PDiffs
::Merge
=0 -o APT
::Get
::List
-Cleanup=1 "$@"
254 testrun nohash
-o Acquire
::PDiffs
::Merge
=1 -o APT
::Get
::List
-Cleanup=1 "$@"
256 testrun
-o Acquire
::PDiffs
::Merge
=0 -o APT
::Get
::List
-Cleanup=1 "$@"
257 testrun
-o Acquire
::PDiffs
::Merge
=1 -o APT
::Get
::List
-Cleanup=1 "$@"
258 testrun
-o Acquire
::PDiffs
::Merge
=0 -o APT
::Get
::List
-Cleanup=0 "$@"
259 testrun
-o Acquire
::PDiffs
::Merge
=1 -o APT
::Get
::List
-Cleanup=0 "$@"
262 echo '01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b -'
264 testrun
-o Acquire
::PDiffs
::Merge
=0 -o Acquire
::ForceHash
=SHA1
"$@"
265 testrun
-o Acquire
::PDiffs
::Merge
=1 -o Acquire
::ForceHash
=SHA1
"$@"
269 echo 'adc83b19e793491b1c6ea0fd8b46cd9f32e592fc -'
271 testrun
-o Acquire
::PDiffs
::Merge
=0 -o Acquire
::ForceHash
=SHA256
"$@"
272 testrun
-o Acquire
::PDiffs
::Merge
=1 -o Acquire
::ForceHash
=SHA256
"$@"
275 aptautotest_apt_update
() { aptautotest_aptget_update
"$@"; testsuccess
test -e "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_Packages"; }
276 testcase
-o Acquire
::IndexTargets
::deb
::Packages
::KeepCompressed
=false
277 aptautotest_apt_update
() { aptautotest_aptget_update
"$@"; testsuccess
test -e "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_Packages.gz"; }
278 testcase
-o Acquire
::IndexTargets
::deb
::Packages
::KeepCompressed
=true