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.
 
 
 
 
 
 

274 lines
12 KiB

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