test-apt-update-ims 6.6 KB

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