You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

286 lines
13 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'i386'
  7. LOWCOSTEXT='lz4'
  8. buildaptarchive
  9. setupflataptarchive
  10. changetowebserver -o aptwebserver::support::modified-since=false
  11. PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
  12. wasmergeused() {
  13. testsuccess apt update "$@"
  14. msgtest 'No intermediate patch files' 'still exist'
  15. local EDS="$(find rootdir/var/lib/apt/lists -name '*.ed' -o -name '*.ed.*')"
  16. if [ -z "$EDS" ]; then
  17. msgpass
  18. else
  19. echo
  20. echo "$EDS"
  21. msgfail
  22. fi
  23. if echo "$*" | grep -q -- '-o test::cannot-use-pdiff=1'; then
  24. msgtest 'Check if pdiff was' 'not used'
  25. cp -a rootdir/tmp/testsuccess.output rootdir/tmp/aptupdate.output
  26. testsuccess --nomsg grep "diff/Index with Message: Couldn't parse pdiff index" rootdir/tmp/aptupdate.output
  27. return;
  28. fi
  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. testrun() {
  43. configcompression '.' 'xz'
  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. configcompression '.' 'gz'
  57. # see if the code deals properly with leftover partial files
  58. touch rootdir/var/lib/apt/lists-bak/partial/localhost:${APTHTTPPORT}_Packages
  59. msgmsg "Testcase: apply with one patch: $*"
  60. find aptarchive -name 'Packages*' -type f -delete
  61. cp "${PKGFILE}-new" aptarchive/Packages
  62. compressfile 'aptarchive/Packages'
  63. mkdir -p aptarchive/Packages.diff
  64. PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
  65. diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
  66. cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
  67. PATCHINDEX='aptarchive/Packages.diff/Index'
  68. echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
  69. SHA256-History:
  70. 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
  71. $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
  72. SHA256-Patches:
  73. e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
  74. $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
  75. SHA256-Download:
  76. d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
  77. $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" > "$PATCHINDEX"
  78. generatereleasefiles '+1hour'
  79. signreleasefiles
  80. find aptarchive -name 'Packages*' -type f -delete
  81. wasmergeused "$@"
  82. testnopackage oldstuff
  83. testsuccessequal "$(cat "${PKGFILE}-new")
  84. " aptcache show apt newstuff
  85. msgmsg "Testcase: SHA1-only patches are not used: $*"
  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 "SHA1-Current: $(sha1sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
  95. SHA1-History:
  96. 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
  97. $(sha1sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
  98. SHA1-Patches:
  99. 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-2013.28
  100. $(sha1sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
  101. SHA1-Download:
  102. 2365ac0ac57cde3d43c63145e8251a3bd5410213 197 2010-08-18-2013.28.gz
  103. $(sha1sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" > "$PATCHINDEX"
  104. generatereleasefiles '+1hour'
  105. signreleasefiles
  106. rm -rf rootdir/var/lib/apt/lists
  107. cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
  108. wasmergeused "$@" -o test::cannot-use-pdiff=1
  109. testnopackage oldstuff
  110. testsuccessequal "$(cat "${PKGFILE}-new")
  111. " aptcache show apt newstuff
  112. msgmsg "Testcase: no download-hashes patches are not used: $*"
  113. find aptarchive -name 'Packages*' -type f -delete
  114. cp "${PKGFILE}-new" aptarchive/Packages
  115. compressfile 'aptarchive/Packages'
  116. mkdir -p aptarchive/Packages.diff
  117. PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
  118. diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
  119. cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
  120. PATCHINDEX='aptarchive/Packages.diff/Index'
  121. echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
  122. SHA256-History:
  123. 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
  124. $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
  125. SHA256-Patches:
  126. e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
  127. $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")" > "$PATCHINDEX"
  128. generatereleasefiles '+1hour'
  129. signreleasefiles
  130. rm -rf rootdir/var/lib/apt/lists
  131. cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
  132. wasmergeused "$@" -o test::cannot-use-pdiff=1
  133. testnopackage oldstuff
  134. testsuccessequal "$(cat "${PKGFILE}-new")
  135. " aptcache show apt newstuff
  136. msgmsg "Testcase: apply with two patches: $*"
  137. cp "${PKGFILE}-new" aptarchive/Packages
  138. echo '
  139. Package: futurestuff
  140. Version: 1.0
  141. Architecture: i386
  142. Maintainer: Joe Sixpack <joe@example.org>
  143. Installed-Size: 202
  144. Filename: pool/futurestuff_1.0_i386.deb
  145. Size: 202200
  146. SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
  147. Description: some cool and shiny future stuff
  148. This package will appear in the next next mirror update
  149. Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages
  150. compressfile 'aptarchive/Packages'
  151. PATCHFILE2="aptarchive/Packages.diff/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')"
  152. diff -e "${PKGFILE}-new" aptarchive/Packages > "${PATCHFILE2}" || true
  153. cat "$PATCHFILE2" | gzip > "${PATCHFILE2}.gz"
  154. echo "SHA256-Current: $(sha256sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
  155. SHA256-History:
  156. 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
  157. $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
  158. $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new") $(basename "${PATCHFILE2}")
  159. SHA256-Patches:
  160. e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
  161. $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
  162. $(sha256sum "${PATCHFILE2}" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE2}") $(basename "${PATCHFILE2}")
  163. SHA256-Download:
  164. d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
  165. $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")
  166. $(sha256sum "${PATCHFILE2}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE2}.gz") $(basename "${PATCHFILE2}.gz")" > "$PATCHINDEX"
  167. generatereleasefiles '+2hour'
  168. signreleasefiles
  169. cp -a aptarchive/Packages Packages-future
  170. find aptarchive -name 'Packages*' -type f -delete
  171. rm -rf rootdir/var/lib/apt/lists
  172. cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
  173. wasmergeused "$@"
  174. testnopackage oldstuff
  175. testsuccessequal "$(cat Packages-future)
  176. " aptcache show apt newstuff futurestuff
  177. # we reuse the archive state of the previous test here
  178. msgmsg "Testcase: downloading a patch fails, but successful fallback: $*"
  179. rm -rf rootdir/var/lib/apt/lists
  180. cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
  181. cp Packages-future aptarchive/Packages
  182. rm "${PATCHFILE}.gz"
  183. testsuccess apt update "$@"
  184. cp rootdir/tmp/testsuccess.output patchdownload.output
  185. testsuccess grep '^Falling back to normal index file acquire' patchdownload.output
  186. testnopackage oldstuff
  187. testsuccessequal "$(cat Packages-future)
  188. " aptcache show apt newstuff futurestuff
  189. msgmsg "Testcase: patch applying fails, but successful fallback: $*"
  190. rm -rf rootdir/var/lib/apt/lists
  191. cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
  192. cp "${PKGFILE}-new" aptarchive/Packages
  193. compressfile 'aptarchive/Packages'
  194. mkdir -p aptarchive/Packages.diff
  195. PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
  196. diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
  197. cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
  198. PATCHINDEX='aptarchive/Packages.diff/Index'
  199. echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
  200. SHA256-History:
  201. 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
  202. $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
  203. SHA256-Patches:
  204. e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
  205. $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
  206. SHA256-Download:
  207. d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
  208. $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz") $(basename "${PATCHFILE}.gz")" > "$PATCHINDEX"
  209. # needs to look like a valid command, otherwise the parser will fail before hashes are checked
  210. echo '1d' > "$PATCHFILE"
  211. cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
  212. generatereleasefiles '+1hour'
  213. signreleasefiles
  214. testsuccess apt update "$@"
  215. cp -f rootdir/tmp/testsuccess.output rootdir/tmp/aptupdate.output
  216. testsuccess grep 'Hash Sum mismatch' rootdir/tmp/aptupdate.output
  217. testnopackage oldstuff
  218. testsuccessequal "$(cat "${PKGFILE}-new")
  219. " aptcache show apt newstuff
  220. msgmsg "Testcase: pdiff patch bigger than index itself: $*"
  221. rm -rf rootdir/var/lib/apt/lists
  222. cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
  223. # the general testcode checks for leftovers in partial, but as this file
  224. # is never touched in this test as it exits earlier its not a leftover…
  225. rm -f rootdir/var/lib/apt/lists/partial/localhost:${APTHTTPPORT}_Packages
  226. cp "${PKGFILE}-new" aptarchive/Packages
  227. compressfile 'aptarchive/Packages'
  228. mkdir -p aptarchive/Packages.diff
  229. PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
  230. diff -e "${PKGFILE}" "${PKGFILE}-new" > "${PATCHFILE}" || true
  231. cat "$PATCHFILE" | gzip > "${PATCHFILE}.gz"
  232. PATCHINDEX='aptarchive/Packages.diff/Index'
  233. echo "SHA256-Current: $(sha256sum "${PKGFILE}-new" | cut -d' ' -f 1) $(stat -c%s "${PKGFILE}-new")
  234. SHA256-History:
  235. 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b 33053002 2010-08-18-2013.28
  236. $(sha256sum "$PKGFILE" | cut -d' ' -f 1) $(stat -c%s "$PKGFILE") $(basename "$PATCHFILE")
  237. SHA256-Patches:
  238. e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 19722 2010-08-18-2013.28
  239. $(sha256sum "$PATCHFILE" | cut -d' ' -f 1) $(stat -c%s "$PATCHFILE") $(basename "$PATCHFILE")
  240. SHA256-Download:
  241. d2a1b33187ed2d248eeae3b1223ea71791ea35f2138a713ed371332a6421f467 197 2010-08-18-2013.28.gz
  242. $(sha256sum "${PATCHFILE}.gz" | cut -d' ' -f 1) $(stat -c%s "${PATCHFILE}.gz")000 $(basename "${PATCHFILE}.gz")" > "$PATCHINDEX"
  243. generatereleasefiles '+1hour'
  244. signreleasefiles
  245. testsuccess apt update -o Debug::pkgAcquire::Diffs=1 "$@"
  246. cp -f rootdir/tmp/testsuccess.output rootdir/tmp/aptupdate.output
  247. testsuccess grep 'bytes (Limit is' rootdir/tmp/aptupdate.output
  248. testnopackage oldstuff
  249. testsuccessequal "$(cat "${PKGFILE}-new")
  250. " aptcache show apt newstuff
  251. }
  252. echo 'Debug::pkgAcquire::Diffs "true";
  253. Debug::Acquire::Transaction "true";
  254. Debug::pkgAcquire::rred "true";' > rootdir/etc/apt/apt.conf.d/rreddebug.conf
  255. testcase() {
  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 "$@"
  260. }
  261. aptautotest_apt_update() { aptautotest_aptget_update "$@"; testsuccess test -e "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_Packages"; }
  262. testcase -o Acquire::IndexTargets::deb::Packages::KeepCompressed=false
  263. aptautotest_apt_update() { aptautotest_aptget_update "$@"; testsuccess test -e "rootdir/var/lib/apt/lists/localhost:${APTHTTPPORT}_Packages.$LOWCOSTEXT"; }
  264. testcase -o Acquire::IndexTargets::deb::Packages::KeepCompressed=true