test-bug-595691-empty-and-broken-archive-files 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture "i386"
  7. buildaptarchive
  8. touch aptarchive/Packages
  9. setupflataptarchive
  10. failureupdate() {
  11. rm -rf rootdir/var/lib/apt
  12. testfailure aptget update --allow-insecure-repositories
  13. testsuccess grep "^E: Failed to fetch store:${1} Empty files can't be valid archives$" rootdir/tmp/testfailure.output
  14. }
  15. successupdate() {
  16. rm -rf rootdir/var/lib/apt
  17. testwarning aptget update --allow-insecure-repositories
  18. }
  19. createemptyarchive() {
  20. find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
  21. touch aptarchive/Packages
  22. echo -n "" | $COMPRESSOR_CMD > aptarchive/${1}.$COMPRESS
  23. find aptarchive -name '*Release*' -delete
  24. rm -f aptarchive/Packages
  25. }
  26. createemptyfile() {
  27. find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
  28. touch aptarchive/Packages aptarchive/${1}.$COMPRESS
  29. find aptarchive -name '*Release*' -delete
  30. rm -f aptarchive/Packages
  31. }
  32. testoverfile() {
  33. local APTARCHIVE="$(readlink -f ./aptarchive)"
  34. forcecompressor "$1"
  35. msgmsg 'archive over file' "Packages.$COMPRESS"
  36. createemptyarchive 'Packages'
  37. successupdate
  38. createemptyfile 'Packages'
  39. failureupdate "$(readlink -f rootdir/var/lib/apt/lists/partial/$(echo "$APTARCHIVE" | sed -e 's#/#_#g')_Packages.${COMPRESS})"
  40. }
  41. testoverhttp() {
  42. forcecompressor "$1"
  43. msgmsg 'archive over http' "Packages.$COMPRESS"
  44. createemptyarchive 'Packages'
  45. successupdate
  46. createemptyfile 'Packages'
  47. failureupdate "$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:${APTHTTPPORT}_Packages.${COMPRESS})"
  48. }
  49. forallsupportedcompressors testoverfile
  50. # do the same again with http instead of file
  51. changetowebserver
  52. forallsupportedcompressors testoverhttp