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.

test-apt-update-expected-size 4.1 KiB

support arch:all data e.g. in separate Packages file Based on a discussion with Niels Thykier who asked for Contents-all this implements apt trying for all architecture dependent files to get a file for the architecture all, which is treated internally now as an official architecture which is always around (like native). This way arch:all data can be shared instead of duplicated for each architecture requiring the user to download the same information again and again. There is one problem however: In Debian there is already a binary-all/ Packages file, but the binary-any files still include arch:all packages, so that downloading this file now would be a waste of time, bandwidth and diskspace. We therefore need a way to decide if it makes sense to download the all file for Packages in Debian or not. The obvious answer would be a special flag in the Release file indicating this, which would need to default to 'no' and every reasonable repository would override it to 'yes' in a few years time, but the flag would be there "forever". Looking closer at a Release file we see the field "Architectures", which doesn't include 'all' at the moment. With the idea outlined above that 'all' is a "proper" architecture now, we interpret this field as being authoritative in declaring which architectures are supported by this repository. If it says 'all', apt will try to get all, if not it will be skipped. This gives us another interesting feature: If I configure a source to download armel and mips, but it declares it supports only armel apt will now print a notice saying as much. Previously this was a very cryptic failure. If on the other hand the repository supports mips, too, but for some reason doesn't ship mips packages at the moment, this 'missing' file is silently ignored (= that is the same as the repository including an empty file). The Architectures field isn't mandatory through, so if it isn't there, we assume that every architecture is supported by this repository, which skips the arch:all if not listed in the release file.
5 years ago
support arch:all data e.g. in separate Packages file Based on a discussion with Niels Thykier who asked for Contents-all this implements apt trying for all architecture dependent files to get a file for the architecture all, which is treated internally now as an official architecture which is always around (like native). This way arch:all data can be shared instead of duplicated for each architecture requiring the user to download the same information again and again. There is one problem however: In Debian there is already a binary-all/ Packages file, but the binary-any files still include arch:all packages, so that downloading this file now would be a waste of time, bandwidth and diskspace. We therefore need a way to decide if it makes sense to download the all file for Packages in Debian or not. The obvious answer would be a special flag in the Release file indicating this, which would need to default to 'no' and every reasonable repository would override it to 'yes' in a few years time, but the flag would be there "forever". Looking closer at a Release file we see the field "Architectures", which doesn't include 'all' at the moment. With the idea outlined above that 'all' is a "proper" architecture now, we interpret this field as being authoritative in declaring which architectures are supported by this repository. If it says 'all', apt will try to get all, if not it will be skipped. This gives us another interesting feature: If I configure a source to download armel and mips, but it declares it supports only armel apt will now print a notice saying as much. Previously this was a very cryptic failure. If on the other hand the repository supports mips, too, but for some reason doesn't ship mips packages at the moment, this 'missing' file is silently ignored (= that is the same as the repository including an empty file). The Architectures field isn't mandatory through, so if it isn't there, we assume that every architecture is supported by this repository, which skips the arch:all if not listed in the release file.
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'i386'
  7. configcompression '.' 'gz'
  8. insertpackage 'unstable' 'apt' 'i386' '1.0'
  9. export APT_DONT_SIGN=''
  10. setupaptarchive --no-update
  11. cp -a aptarchive/dists aptarchive/dists.good
  12. test_inreleasetoobig() {
  13. # make InRelease really big to trigger fallback
  14. dd if=/dev/zero of=aptarchive/dists/unstable/InRelease bs=1M count=2 2>/dev/null
  15. touch -d '+1hour' aptarchive/dists/unstable/InRelease
  16. testsuccess aptget update -o Apt::Get::List-Cleanup=0 -o acquire::MaxReleaseFileSize=$((1*1000*1000)) -o Debug::pkgAcquire::worker=0
  17. msgtest 'Check that the max write warning is triggered'
  18. cp rootdir/tmp/testsuccess.output update.output
  19. testsuccess --nomsg grep -q 'File has unexpected size' update.output
  20. rm -f update.output
  21. # ensure the failed InRelease file got renamed
  22. testsuccess ls rootdir/var/lib/apt/lists/partial/*InRelease.FAILED
  23. testfailure test -e rootdir/var/lib/apt/lists/partial/Old.FAILED
  24. }
  25. test_packagestoobig() {
  26. insertpackage 'unstable' 'foo' 'i386' '1.0'
  27. buildaptarchivefromfiles '+1 hour'
  28. signreleasefiles
  29. # append junk at the end of the Packages.gz/Packages
  30. SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
  31. find aptarchive/dists -name 'Packages*' | while read pkg; do
  32. echo "1234567890" >> "$pkg"
  33. touch -d '+1hour' "$pkg"
  34. done
  35. NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
  36. testfailuremsg "E: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages.gz File has unexpected size ($NEW_SIZE != $SIZE). Mirror sync in progress?
  37. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::Transaction=0
  38. testsuccess ls rootdir/var/lib/apt/lists/partial/*Packages*.FAILED
  39. testfailure test -e rootdir/var/lib/apt/lists/partial/Old.FAILED
  40. }
  41. test_packagestoosmall() {
  42. insertpackage 'unstable' 'foo' 'i386' '1.0'
  43. buildaptarchivefromfiles '+1 hour'
  44. signreleasefiles
  45. # replace Packages.gz/Packages with short junk
  46. SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
  47. find aptarchive/dists -name 'Packages*' | while read pkg; do
  48. echo "1234567890" > "$pkg"
  49. touch -d '+1hour' "$pkg"
  50. done
  51. NEW_SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages.gz)"
  52. testfailuremsg "E: Failed to fetch ${1}/dists/unstable/main/binary-i386/Packages.gz File is smaller than expected ($NEW_SIZE < $SIZE). Mirror sync in progress?
  53. E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::Transaction=0
  54. testsuccess ls rootdir/var/lib/apt/lists/partial/*Packages*.FAILED
  55. testfailure test -e rootdir/var/lib/apt/lists/partial/Old.FAILED
  56. }
  57. methodtest() {
  58. # less complicated test setup this way
  59. webserverconfig 'aptwebserver::support::modified-since' 'false' "$1"
  60. webserverconfig 'aptwebserver::support::last-modified' 'false' "$1" # curl is clever and sees hits here also
  61. msgmsg 'Test with' "$1" 'and clean start'
  62. rm -rf rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good aptarchive/dists
  63. cp -a aptarchive/dists.good aptarchive/dists
  64. # normal update works fine
  65. testsuccess aptget update
  66. touch rootdir/var/lib/apt/lists/partial/Old.FAILED
  67. mv rootdir/var/lib/apt/lists rootdir/var/lib/apt/lists.good
  68. # starting fresh works
  69. test_inreleasetoobig "$1"
  70. rm -rf aptarchive/dists rootdir/var/lib/apt/lists
  71. cp -a aptarchive/dists.good aptarchive/dists
  72. test_packagestoobig "$1"
  73. msgmsg 'Test with' "$1" 'and existing old data'
  74. rm -rf aptarchive/dists rootdir/var/lib/apt/lists
  75. cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
  76. cp -a aptarchive/dists.good aptarchive/dists
  77. test_inreleasetoobig "$1"
  78. rm -rf aptarchive/dists rootdir/var/lib/apt/lists
  79. cp -a rootdir/var/lib/apt/lists.good rootdir/var/lib/apt/lists
  80. cp -a aptarchive/dists.good aptarchive/dists
  81. test_packagestoobig "$1"
  82. }
  83. changetowebserver
  84. methodtest "http://localhost:${APTHTTPPORT}"
  85. changetohttpswebserver
  86. methodtest "https://localhost:${APTHTTPSPORT}"