test-apt-ftparchive-by-hash 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. set -e
  3. verify_by_hash() {
  4. for hash_gen in SHA1:sha1sum SHA256:sha256sum SHA512:sha512sum; do
  5. hash=$(echo ${hash_gen} | cut -f1 -d:)
  6. gen=$(echo ${hash_gen} | cut -f2 -d:)
  7. testsuccess stat aptarchive/dists/unstable/main/binary-i386/by-hash/$hash/$($gen aptarchive/dists/unstable/main/binary-i386/Packages | cut -f1 -d' ')
  8. testsuccess stat aptarchive/dists/unstable/main/binary-i386/by-hash/$hash/$($gen aptarchive/dists/unstable/main/binary-i386/Packages.gz | cut -f1 -d' ')
  9. done
  10. }
  11. #
  12. # main()
  13. #
  14. TESTDIR=$(readlink -f $(dirname $0))
  15. . $TESTDIR/framework
  16. setupenvironment
  17. configarchitecture 'i386'
  18. configcompression 'gz' '.'
  19. # enable by-hash in apt-ftparchive
  20. echo 'APT::FTPArchive::DoByHash "1";' >> aptconfig.conf
  21. # build one pacakge
  22. buildsimplenativepackage 'foo' 'i386' '1' 'unstable'
  23. buildaptarchivefromincoming
  24. # verify initial run
  25. verify_by_hash
  26. previous_hash=$(sha256sum aptarchive/dists/unstable/main/binary-i386/Packages | cut -f1 -d' ')
  27. # insert new package
  28. buildsimplenativepackage 'bar' 'i386' '1' 'unstable'
  29. # and build again
  30. buildaptarchivefromincoming
  31. # ensure the new package packag is there
  32. testsuccess zgrep "Package: bar" aptarchive/dists/unstable/main/binary-i386/Packages.gz
  33. # ensure we have the by-hash stuff
  34. verify_by_hash
  35. # ensure the old hash is still there
  36. testsuccess stat aptarchive/dists/unstable/main/binary-i386/by-hash/SHA256/$previous_hash
  37. # ensure we have it in the Release file
  38. testsuccess grep "Acquire-By-Hash: true" aptarchive/dists/unstable/*Release
  39. # now ensure gc work
  40. for i in $(seq 3); do
  41. buildsimplenativepackage 'bar' 'i386' "$i" 'unstable'
  42. buildaptarchivefromincoming
  43. done
  44. hash_count=$(ls aptarchive/dists/unstable/main/binary-i386/by-hash/SHA256/|wc -l)
  45. # we have 2 files (uncompressed, gz) per run, 5 runs in total
  46. # by default apt-ftparchive keeps three generations (current plus 2 older)
  47. msgtest "Check that gc for by-hash works… "
  48. if [ "$hash_count" = "6" ]; then
  49. msgpass
  50. else
  51. echo "Got $hash_count expected 6"
  52. msgfail
  53. fi
  54. # ensure the current generation is still there
  55. verify_by_hash