test-apt-update-transactions 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/sh
  2. set -e
  3. # ensure that an update will only succeed entirely or not at all
  4. TESTDIR=$(readlink -f $(dirname $0))
  5. . $TESTDIR/framework
  6. setupenvironment
  7. configarchitecture 'i386'
  8. insertpackage 'unstable' 'foo' 'all' '1.0'
  9. insertsource 'unstable' 'foo' 'all' '1.0'
  10. setupaptarchive --no-update
  11. breakfile() {
  12. mv "$1" "${1}.bak"
  13. cat > "$1" <<EOF
  14. Package: bar
  15. EOF
  16. compressfile "$1"
  17. }
  18. restorefile() {
  19. mv "${1}.bak" "$1"
  20. }
  21. listscheck() {
  22. testequal "$(cat $1)" ls rootdir/var/lib/apt/lists
  23. }
  24. testrun() {
  25. # produce an unsigned repository
  26. find aptarchive \( -name 'Release.gpg' -o -name 'InRelease' \) -delete
  27. testfailure aptget update --no-allow-insecure-repositories
  28. listscheck "$1"
  29. # signed but broken
  30. signreleasefiles
  31. breakfile aptarchive/dists/unstable/main/binary-i386/Packages
  32. testfailure aptget update
  33. listscheck "$1"
  34. restorefile aptarchive/dists/unstable/main/binary-i386/Packages
  35. breakfile aptarchive/dists/unstable/main/source/Sources
  36. testfailure aptget update
  37. listscheck "$1"
  38. restorefile aptarchive/dists/unstable/main/source/Sources
  39. }
  40. testsetup() {
  41. msgmsg 'Test with no initial data over' "$1"
  42. rm -rf rootdir/var/lib/apt/lists
  43. mkdir -p rootdir/var/lib/apt/lists/partial
  44. ls rootdir/var/lib/apt/lists > listsdir.lst
  45. testrun 'listsdir.lst'
  46. msgmsg 'Test with initial data over' "$1"
  47. testsuccess aptget update
  48. ls rootdir/var/lib/apt/lists > listsdir.lst
  49. testrun 'listsdir.lst'
  50. }
  51. testsetup 'file'
  52. changetowebserver
  53. testsetup 'http'