test-apt-update-ims 7.3 KB

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