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.
 
 
 
 
 
 

160 lines
5.7 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. echo '#!/bin/sh
  12. touch merge-was-used
  13. /usr/bin/diffindex-rred "$@"' > extrred
  14. chmod +x extrred
  15. echo 'Dir::Bin::rred "./extrred";' > rootdir/etc/apt/apt.conf.d/99rred
  16. wasmergeused() {
  17. msgtest 'Test for successful execution of' "$*"
  18. local OUTPUT=$(mktemp)
  19. addtrap "rm $OUTPUT;"
  20. if aptget update "$@" >${OUTPUT} 2>&1; then
  21. msgpass
  22. else
  23. echo
  24. cat $OUTPUT
  25. msgfail
  26. fi
  27. msgtest 'Check if the right pdiff merger was used'
  28. if grep -q '^pkgAcqIndexMergeDiffs::Done(): rred' $OUTPUT; then
  29. if echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
  30. msgpass
  31. else
  32. msgfail "Merge shouldn't have been used, but was"
  33. fi
  34. elif echo "$*" | grep -q -- '-o Acquire::PDiffs::Merge=1'; then
  35. msgfail "Merge should have been used, but wasn't"
  36. else
  37. msgpass
  38. fi
  39. }
  40. testrun() {
  41. # setup the base
  42. find aptarchive -name 'Packages*' -type f -delete
  43. cp ${PKGFILE} aptarchive/Packages
  44. compressfile 'aptarchive/Packages'
  45. generatereleasefiles
  46. signreleasefiles
  47. rm -rf aptarchive/Packages.diff rootdir/var/lib/apt/lists
  48. testsuccess aptget update "$@"
  49. cp -a rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists-bak
  50. testnopackage newstuff
  51. testequal "$(cat ${PKGFILE})
  52. " aptcache show apt oldstuff
  53. msgmsg 'Testcase: apply with one patch'
  54. cp ${PKGFILE}-new aptarchive/Packages
  55. compressfile 'aptarchive/Packages'
  56. mkdir -p aptarchive/Packages.diff
  57. PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
  58. diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
  59. cat $PATCHFILE | gzip > ${PATCHFILE}.gz
  60. PATCHINDEX='aptarchive/Packages.diff/Index'
  61. echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
  62. SHA1-History:
  63. 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
  64. $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
  65. SHA1-Patches:
  66. 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
  67. $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
  68. generatereleasefiles '+1hour'
  69. signreleasefiles
  70. find aptarchive -name 'Packages*' -type f -delete
  71. wasmergeused "$@"
  72. testnopackage oldstuff
  73. testequal "$(cat ${PKGFILE}-new)
  74. " aptcache show apt newstuff
  75. msgmsg 'Testcase: index is already up-to-date'
  76. find rootdir/var/lib/apt/lists -name '*.IndexDiff' -type f -delete
  77. testsuccess aptget update "$@"
  78. testequal "$(cat ${PKGFILE}-new)
  79. " aptcache show apt newstuff
  80. msgmsg 'Testcase: apply with two patches'
  81. cp ${PKGFILE}-new aptarchive/Packages
  82. echo '
  83. Package: futurestuff
  84. Version: 1.0
  85. Architecture: i386
  86. Maintainer: Joe Sixpack <joe@example.org>
  87. Installed-Size: 202
  88. Filename: pool/futurestuff_1.0_i386.deb
  89. Size: 202200
  90. MD5sum: 311aeeaaae5ba33aff1ceaf3e1f76671
  91. SHA1: 3c695e028f7a1ae324deeaae5ba332desa81088c
  92. SHA256: b46fd154615edaae5ba33c56a5cc0e7deaef23e2da3e4f129727fd660f28f050
  93. Description: some cool and shiny future stuff
  94. This package will appear in the next next mirror update
  95. Description-md5: d5f89fbbc2ce34c455dfee9b67d82b6b' >> aptarchive/Packages
  96. compressfile 'aptarchive/Packages'
  97. PATCHFILE2="aptarchive/Packages.diff/$(date -d 'now + 1hour' '+%Y-%m-%d-%H%M.%S')"
  98. diff -e ${PKGFILE}-new aptarchive/Packages > ${PATCHFILE2} || true
  99. cat $PATCHFILE2 | gzip > ${PATCHFILE2}.gz
  100. echo "SHA1-Current: $(sha1sum aptarchive/Packages | cut -d' ' -f 1) $(stat -c%s aptarchive/Packages)
  101. SHA1-History:
  102. 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
  103. $(sha1sum ${PKGFILE} | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}) $(basename ${PATCHFILE})
  104. $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new) $(basename ${PATCHFILE2})
  105. SHA1-Patches:
  106. 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
  107. $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)
  108. $(sha1sum ${PATCHFILE2} | cut -d' ' -f 1) $(stat -c%s ${PATCHFILE2}) $(basename ${PATCHFILE2})" > $PATCHINDEX
  109. generatereleasefiles '+2hour'
  110. signreleasefiles
  111. cp -a aptarchive/Packages Packages-future
  112. find aptarchive -name 'Packages*' -type f -delete
  113. rm -rf rootdir/var/lib/apt/lists
  114. cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
  115. wasmergeused "$@"
  116. testnopackage oldstuff
  117. testequal "$(cat Packages-future)
  118. " aptcache show apt newstuff futurestuff
  119. msgmsg 'Testcase: patch applying fails, but successful fallback'
  120. rm -rf rootdir/var/lib/apt/lists
  121. cp -a rootdir/var/lib/apt/lists-bak rootdir/var/lib/apt/lists
  122. cp ${PKGFILE}-new aptarchive/Packages
  123. compressfile 'aptarchive/Packages'
  124. mkdir -p aptarchive/Packages.diff
  125. PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
  126. diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
  127. PATCHINDEX='aptarchive/Packages.diff/Index'
  128. echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
  129. SHA1-History:
  130. 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
  131. $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
  132. SHA1-Patches:
  133. 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
  134. $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
  135. echo 'I am Mallory and I change files' >> $PATCHFILE
  136. cat $PATCHFILE | gzip > ${PATCHFILE}.gz
  137. generatereleasefiles '+1hour'
  138. signreleasefiles
  139. testsuccess aptget update "$@"
  140. testnopackage oldstuff
  141. testequal "$(cat ${PKGFILE}-new)
  142. " aptcache show apt newstuff
  143. }
  144. testrun -o Debug::pkgAcquire::Diffs=1 -o Debug::pkgAcquire::rred=1 -o Acquire::PDiffs::Merge=0
  145. testrun -o Debug::pkgAcquire::Diffs=1 -o Debug::pkgAcquire::rred=1 -o Acquire::PDiffs::Merge=1