test-apt-update-ims 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'amd64'
  7. insertpackage 'unstable' 'unrelated' 'all' '0.5~squeeze1'
  8. insertpackage 'unstable' 'unrelated2' 'amd64' '0.5~squeeze1'
  9. insertsource 'unstable' 'unrelated' 'all' '0.5~squeeze1'
  10. export APT_DONT_SIGN=""
  11. setupaptarchive --no-update
  12. logcurrentarchivedirectory
  13. changetowebserver
  14. runtest() {
  15. local APTOPT=""
  16. if [ -n "$1" ]; then
  17. APTOPT='--allow-insecure-repositories'
  18. else
  19. APTOPT='--no-allow-insecure-repositories'
  20. fi
  21. rm -rf rootdir/var/lib/apt/lists/
  22. local TEST="test${1:-success}"
  23. $TEST aptget update $APTOPT -o Debug::pkgAcquire::Worker=1
  24. if [ "$1" = 'failure' ]; then
  25. # accept the outdated Release file so we can check Hit behaviour
  26. "test${2:-success}" aptget update -o Acquire::Min-ValidTime=9999999 $APTOPT
  27. fi
  28. listcurrentlistsdirectory > listsdir.lst
  29. testsuccess grep '_Packages\(\.[0-9a-z]\+\)\?$' listsdir.lst
  30. testsuccess grep '_Sources\(\.[0-9a-z]\+\)\?$' listsdir.lst
  31. testsuccess grep '_Translation-en\(\.[0-9a-z]\+\)\?$' listsdir.lst
  32. # ensure no leftovers in partial
  33. testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
  34. # check that I-M-S header is kept in redirections
  35. echo "$EXPECT" | sed -e 's#(invalid since [^)]\+)#(invalid since)#' > expected.output
  36. $TEST aptget update -o Debug::pkgAcquire::Worker=0 -o Debug::Acquire::http=0 $APTOPT
  37. sed -i -e 's#(invalid since [^)]\+)#(invalid since)#' rootdir/tmp/${TEST}.output
  38. testequal "$(cat expected.output)" cat rootdir/tmp/${TEST}.output
  39. testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
  40. # ensure that we still do a hash check for other files on ims hit of Release
  41. if grep -q '^Hit:[0-9]\+ .* InRelease$' expected.output || ! grep -q '^Ign:[0-9]\+ .* Release\(\.gpg\)\?$' expected.output; then
  42. $TEST aptget update -o Debug::Acquire::gpgv=1 $APTOPT
  43. cp rootdir/tmp/${TEST}.output goodsign.output
  44. testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
  45. testsuccess grep '^Got GOODSIG ' goodsign.output
  46. fi
  47. # ensure no leftovers in partial
  48. testfailure ls 'rootdir/var/lib/apt/lists/partial/*'
  49. }
  50. msgmsg 'InRelease'
  51. EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
  52. Reading package lists..."
  53. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  54. runtest
  55. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  56. runtest
  57. msgmsg 'Release/Release.gpg'
  58. EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
  59. 404 Not Found
  60. Hit:2 http://localhost:${APTHTTPPORT} unstable Release
  61. Reading package lists..."
  62. find aptarchive -name 'InRelease' -delete
  63. logcurrentarchivedirectory
  64. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  65. runtest
  66. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  67. runtest
  68. msgmsg 'Release only'
  69. EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
  70. 404 Not Found
  71. Hit:2 http://localhost:${APTHTTPPORT} unstable Release
  72. Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
  73. 404 Not Found
  74. Reading package lists...
  75. W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
  76. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
  77. N: See apt-secure(8) manpage for repository creation and user configuration details."
  78. find aptarchive -name 'Release.gpg' -delete
  79. logcurrentarchivedirectory
  80. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  81. runtest 'warning'
  82. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  83. runtest 'warning'
  84. # make the release file old
  85. find aptarchive -name '*Release' -exec sed -i \
  86. -e "s#^Date: .*\$#Date: $(date -ud '-2 weeks' '+%a, %d %b %Y %H:%M:%S %Z')#" \
  87. -e '/^Valid-Until: / d' -e "/^Date: / a\
  88. Valid-Until: $(date -ud '-1 weeks' '+%a, %d %b %Y %H:%M:%S %Z')" '{}' \;
  89. signreleasefiles
  90. logcurrentarchivedirectory
  91. msgmsg 'expired InRelease'
  92. EXPECT="Hit:1 http://localhost:${APTHTTPPORT} unstable InRelease
  93. Reading package lists...
  94. E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/InRelease is expired (invalid since). Updates for this repository will not be applied."
  95. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  96. runtest 'failure'
  97. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  98. runtest 'failure'
  99. msgmsg 'expired Release/Release.gpg'
  100. EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
  101. 404 Not Found
  102. Hit:2 http://localhost:${APTHTTPPORT} unstable Release
  103. Reading package lists...
  104. E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
  105. find aptarchive -name 'InRelease' -delete
  106. logcurrentarchivedirectory
  107. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  108. runtest 'failure'
  109. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  110. runtest 'failure'
  111. msgmsg 'expired Release only'
  112. EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
  113. 404 Not Found
  114. Hit:2 http://localhost:${APTHTTPPORT} unstable Release
  115. Ign:3 http://localhost:${APTHTTPPORT} unstable Release.gpg
  116. 404 Not Found
  117. Reading package lists...
  118. W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' is not signed.
  119. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
  120. N: See apt-secure(8) manpage for repository creation and user configuration details.
  121. E: Release file for http://localhost:${APTHTTPPORT}/dists/unstable/Release is expired (invalid since). Updates for this repository will not be applied."
  122. find aptarchive -name 'Release.gpg' -delete
  123. logcurrentarchivedirectory
  124. echo 'Acquire::GzipIndexes "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  125. runtest 'failure' 'warning'
  126. echo 'Acquire::GzipIndexes "1";' > rootdir/etc/apt/apt.conf.d/02compressindex
  127. runtest 'failure' 'warning'
  128. msgmsg 'no Release at all'
  129. EXPECT="Ign:1 http://localhost:${APTHTTPPORT} unstable InRelease
  130. 404 Not Found
  131. Ign:2 http://localhost:${APTHTTPPORT} unstable Release
  132. 404 Not Found
  133. Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
  134. 404 Not Found
  135. Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
  136. 404 Not Found
  137. Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
  138. 404 Not Found
  139. Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
  140. 404 Not Found
  141. Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
  142. 404 Not Found
  143. Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
  144. 404 Not Found
  145. Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
  146. 404 Not Found
  147. Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
  148. 404 Not Found
  149. Ign:3 http://localhost:${APTHTTPPORT} unstable/main Sources
  150. 404 Not Found
  151. Ign:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
  152. 404 Not Found
  153. Ign:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
  154. 404 Not Found
  155. Ign:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
  156. 404 Not Found
  157. Hit:3 http://localhost:${APTHTTPPORT} unstable/main Sources
  158. Hit:4 http://localhost:${APTHTTPPORT} unstable/main amd64 Packages
  159. Hit:5 http://localhost:${APTHTTPPORT} unstable/main all Packages
  160. Hit:6 http://localhost:${APTHTTPPORT} unstable/main Translation-en
  161. Reading package lists...
  162. W: The repository 'http://localhost:${APTHTTPPORT} unstable Release' does not have a Release file.
  163. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
  164. N: See apt-secure(8) manpage for repository creation and user configuration details."
  165. find aptarchive -name '*Release*' -delete
  166. logcurrentarchivedirectory
  167. echo 'Acquire::GzipIndexes "0";
  168. Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  169. runtest 'warning'
  170. echo 'Acquire::GzipIndexes "1";
  171. Acquire::PDiffs "0";' > rootdir/etc/apt/apt.conf.d/02compressindex
  172. runtest 'warning'