test-apt-update-hooks 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'i386'
  7. confighashes 'SHA512'
  8. insertpackage 'unstable' 'foo' 'i386' '1.0'
  9. insertpackage 'testing' 'foo' 'i386' '1.0'
  10. setupaptarchive --no-update
  11. APTARCHIVE="$(readlink -f ./aptarchive)"
  12. signreleasefiles 'Joe Sixpack'
  13. echo 'APT::Update::Post-Invoke-Success { "echo SUCCESS"; };' >> rootdir/etc/apt/apt.conf.d/display-success.conf
  14. echo 'APT::Update::Post-Invoke { "echo RUN"; };' >> rootdir/etc/apt/apt.conf.d/display-success.conf
  15. msgmsg "All sources OK => run Post-Invoke-Success and Post-Invoke"
  16. testsuccess aptget update
  17. cp rootdir/tmp/testsuccess.output aptupdate.output
  18. testsuccess grep "RUN" aptupdate.output
  19. testsuccess grep "SUCCESS" aptupdate.output
  20. msgmsg "Some sources broken => run Post-Invoke-Success and Post-Invoke"
  21. sed -i -e '/^ / d' -e '/^SHA512:/ d' "$APTARCHIVE/dists/unstable/Release"
  22. testsuccess rm "$(aptget indextargets 'Created-By: Packages' 'Suite: testing' --format '$(FILENAME)')"
  23. signreleasefiles
  24. listcurrentlistsdirectory > lists.before
  25. testfailure apt update
  26. cp rootdir/tmp/testfailure.output aptupdate.output
  27. listcurrentlistsdirectory > lists.after
  28. testfailure cmp lists.before lists.after
  29. testsuccess grep "RUN" aptupdate.output
  30. testsuccess grep "SUCCESS" aptupdate.output
  31. msgmsg "All sources broken => run Post-Invoke"
  32. sed -i -e '/^ / d' -e '/^SHA512:/ d' "$APTARCHIVE/dists/testing/Release"
  33. signreleasefiles
  34. mv lists.after lists.before
  35. testfailure apt update
  36. cp rootdir/tmp/testfailure.output aptupdate.output
  37. testfileequal lists.before "$(listcurrentlistsdirectory)"
  38. testsuccess grep "RUN" aptupdate.output
  39. testfailure grep "SUCCESS" aptupdate.output