test-releasefile-verification 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. prepare() {
  11. local DATE="${2:-now}"
  12. if [ "$DATE" = 'now' -a "$1" = "${PKGFILE}-new" ]; then
  13. DATE='now + 6 days'
  14. fi
  15. for release in $(find rootdir/var/lib/apt/lists 2> /dev/null); do
  16. touch -d 'now - 6 hours' $release
  17. done
  18. rm -rf rootdir/var/cache/apt/archives
  19. rm -f rootdir/var/cache/apt/*.bin
  20. cp $1 aptarchive/Packages
  21. find aptarchive -name 'Release' -delete
  22. cat aptarchive/Packages | gzip > aptarchive/Packages.gz
  23. cat aptarchive/Packages | bzip2 > aptarchive/Packages.bz2
  24. cat aptarchive/Packages | lzma > aptarchive/Packages.lzma
  25. generatereleasefiles "$DATE"
  26. }
  27. installaptold() {
  28. testequal 'Reading package lists...
  29. Building dependency tree...
  30. Suggested packages:
  31. aptitude synaptic wajig dpkg-dev apt-doc bzip2 lzma python-apt
  32. The following NEW packages will be installed:
  33. apt
  34. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  35. After this operation, 5370 kB of additional disk space will be used.
  36. Get:1 http://localhost/ apt 0.7.25.3
  37. Download complete and in download only mode' aptget install apt -dy
  38. }
  39. installaptnew() {
  40. testequal 'Reading package lists...
  41. Building dependency tree...
  42. Suggested packages:
  43. aptitude synaptic wajig dpkg-dev apt-doc bzip2 lzma python-apt
  44. The following NEW packages will be installed:
  45. apt
  46. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  47. After this operation, 5808 kB of additional disk space will be used.
  48. Get:1 http://localhost/ apt 0.8.0~pre1
  49. Download complete and in download only mode' aptget install apt -dy
  50. }
  51. failaptold() {
  52. testequal 'Reading package lists...
  53. Building dependency tree...
  54. Suggested packages:
  55. aptitude synaptic wajig dpkg-dev apt-doc bzip2 lzma python-apt
  56. The following NEW packages will be installed:
  57. apt
  58. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  59. After this operation, 5370 kB of additional disk space will be used.
  60. WARNING: The following packages cannot be authenticated!
  61. apt
  62. E: There are problems and -y was used without --force-yes' aptget install apt -dy
  63. }
  64. failaptnew() {
  65. testequal 'Reading package lists...
  66. Building dependency tree...
  67. Suggested packages:
  68. aptitude synaptic wajig dpkg-dev apt-doc bzip2 lzma python-apt
  69. The following NEW packages will be installed:
  70. apt
  71. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  72. After this operation, 5808 kB of additional disk space will be used.
  73. WARNING: The following packages cannot be authenticated!
  74. apt
  75. E: There are problems and -y was used without --force-yes' aptget install apt -dy
  76. }
  77. # fake our downloadable file
  78. touch aptarchive/apt.deb
  79. PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
  80. runtest() {
  81. prepare ${PKGFILE}
  82. rm -rf rootdir/var/lib/apt/lists
  83. signreleasefiles 'Joe Sixpack'
  84. find aptarchive/ -name "$DELETEFILE" -delete
  85. msgtest 'Cold archive signed by' 'Joe Sixpack'
  86. aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass
  87. testequal "$(cat ${PKGFILE})
  88. " aptcache show apt
  89. installaptold
  90. prepare ${PKGFILE}-new
  91. signreleasefiles 'Joe Sixpack'
  92. find aptarchive/ -name "$DELETEFILE" -delete
  93. msgtest 'Good warm archive signed by' 'Joe Sixpack'
  94. aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass
  95. testequal "$(cat ${PKGFILE}-new)
  96. " aptcache show apt
  97. installaptnew
  98. prepare ${PKGFILE}
  99. rm -rf rootdir/var/lib/apt/lists
  100. signreleasefiles 'Marvin Paranoid'
  101. find aptarchive/ -name "$DELETEFILE" -delete
  102. msgtest 'Cold archive signed by' 'Marvin Paranoid'
  103. aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgpass || msgfail
  104. testequal "$(cat ${PKGFILE})
  105. " aptcache show apt
  106. failaptold
  107. prepare ${PKGFILE}-new
  108. # weborf doesn't support If-Range
  109. for release in $(find rootdir/var/lib/apt/lists/partial/ -name '*Release'); do
  110. rm $release
  111. touch $release
  112. done
  113. signreleasefiles 'Joe Sixpack'
  114. find aptarchive/ -name "$DELETEFILE" -delete
  115. msgtest 'Bad warm archive signed by' 'Joe Sixpack'
  116. aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass
  117. testequal "$(cat ${PKGFILE}-new)
  118. " aptcache show apt
  119. installaptnew
  120. prepare ${PKGFILE}
  121. rm -rf rootdir/var/lib/apt/lists
  122. signreleasefiles 'Joe Sixpack'
  123. find aptarchive/ -name "$DELETEFILE" -delete
  124. msgtest 'Cold archive signed by' 'Joe Sixpack'
  125. aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass
  126. testequal "$(cat ${PKGFILE})
  127. " aptcache show apt
  128. installaptold
  129. prepare ${PKGFILE}-new
  130. signreleasefiles 'Marvin Paranoid'
  131. find aptarchive/ -name "$DELETEFILE" -delete
  132. msgtest 'Good warm archive signed by' 'Marvin Paranoid'
  133. aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgpass || msgfail
  134. testequal "$(cat ${PKGFILE})
  135. " aptcache show apt
  136. installaptold
  137. }
  138. DELETEFILE="InRelease"
  139. runtest
  140. DELETEFILE="Release.gpg"
  141. runtest