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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture "i386"
  7. buildaptarchive
  8. setupflataptarchive
  9. testaptgetupdate() {
  10. aptget update 2>> testaptgetupdate.diff >> testaptgetupdate.diff || true
  11. sed -i -e '/^Fetched / d' -e 's#\[[0-9]* [kMGTPY]*B\]#\[\]#' testaptgetupdate.diff
  12. GIVEN="$1"
  13. shift
  14. msgtest "Test for correctness of" "apt-get update with $*"
  15. if [ -z "$GIVEN" ]; then
  16. echo -n "" | checkdiff - testaptgetupdate.diff && msgpass || msgfail
  17. else
  18. echo "$GIVEN" | checkdiff - testaptgetupdate.diff && msgpass || msgfail
  19. fi
  20. rm testaptgetupdate.diff
  21. }
  22. touch aptarchive/en.bz2
  23. testaptgetupdate "Ign file: Release.gpg
  24. Ign file:$(readlink -f aptarchive)/ Translation-en
  25. Get:1 file: Release []
  26. Reading package lists..." "empty file en.bz2 over file"
  27. rm aptarchive/en.bz2
  28. echo -n "" | bzip2 > aptarchive/en.bz2
  29. testaptgetupdate "Ign file: Release.gpg
  30. Get:1 file: Release []
  31. Reading package lists..." "empty archive en.bz2 over file"
  32. rm aptarchive/en.bz2
  33. # do the same again with http instead of file
  34. changetowebserver
  35. touch aptarchive/en.bz2
  36. testaptgetupdate "Ign http://localhost Release.gpg
  37. Get:1 http://localhost/ Translation-en
  38. Get:2 http://localhost Release []
  39. Ign http://localhost/ Translation-en
  40. Get:3 http://localhost Packages []
  41. Reading package lists..." "empty file en.bz2 over http"
  42. rm aptarchive/en.bz2
  43. echo -n "" | bzip2 > aptarchive/en.bz2
  44. testaptgetupdate "Ign http://localhost Release.gpg
  45. Get:1 http://localhost/ Translation-en []
  46. Get:2 http://localhost Release []
  47. Ign http://localhost Packages/DiffIndex
  48. Get:3 http://localhost Packages []
  49. Reading package lists..." "empty archive en.bz2 over http"
  50. rm aptarchive/en.bz2
  51. rm aptarchive/Packages
  52. touch aptarchive/Packages
  53. buildaptarchivefromfiles
  54. testaptgetupdate "Ign http://localhost Release.gpg
  55. Ign http://localhost/ Translation-en
  56. Get:1 http://localhost Release []
  57. Ign http://localhost Packages/DiffIndex
  58. Get:2 http://localhost Packages []
  59. Reading package lists..." "empty archive Packages over http"
  60. find aptarchive/ -name 'Packages*' -type f -delete
  61. touch aptarchive/Packages.bz2
  62. aptftparchive release aptarchive/ > aptarchive/Release
  63. #FIXME: we should response with a good error message instead
  64. testaptgetupdate "Ign http://localhost Release.gpg
  65. Ign http://localhost/ Translation-en
  66. Get:1 http://localhost Release []
  67. Ign http://localhost Packages/DiffIndex
  68. Get:2 http://localhost Packages
  69. Err http://localhost Packages
  70. Undetermined Error
  71. W: Failed to fetch http://localhost:8080/Packages.bz2 Undetermined Error
  72. E: Some index files failed to download, they have been ignored, or old ones used instead." "empty file Packages over http"