You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

71 lines
2.1 KiB

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