5     for hash_gen 
in SHA1
:sha1sum SHA256
:sha256sum SHA512
:sha512sum
; do 
   6         hash=$(echo ${hash_gen} | cut -f1 -d:) 
   7         gen
=$(echo ${hash_gen} | cut -f2 -d:) 
   8         testsuccess stat aptarchive
/dists
/unstable
/main
/binary
-i386/by
-hash/$hash/$($gen aptarchive/dists/unstable/main/binary-i386/Packages | cut -f1 -d' ') 
   9         testsuccess stat aptarchive
/dists
/unstable
/main
/binary
-i386/by
-hash/$hash/$($gen aptarchive/dists/unstable/main/binary-i386/Packages.gz | cut -f1 -d' ') 
  16 TESTDIR
=$(readlink -f $(dirname $0)) 
  19 configarchitecture 
'i386' 
  20 configcompression 
'gz' '.' 
  21 confighashes 
'SHA1' 'SHA256' 'SHA512' 
  23 # enable by-hash in apt-ftparchive 
  24 echo 'APT::FTPArchive::DoByHash "1";' >> aptconfig.conf
 
  27 buildsimplenativepackage 
'foo' 'i386' '1' 'unstable' 
  28 buildaptarchivefromincoming
 
  32 previous_hash
=$(sha256sum aptarchive/dists/unstable/main/binary-i386/Packages | cut -f1 -d' ') 
  35 buildsimplenativepackage 
'bar' 'i386' '1' 'unstable' 
  37 buildaptarchivefromincoming
 
  39 # ensure the new package packag is there 
  40 testsuccess 
zgrep "Package: bar" aptarchive
/dists
/unstable
/main
/binary
-i386/Packages.gz
 
  42 # ensure we have the by-hash stuff 
  45 # ensure the old hash is still there 
  46 testsuccess stat aptarchive
/dists
/unstable
/main
/binary
-i386/by
-hash/SHA
256/$previous_hash 
  48 # ensure we have it in the Release file 
  49 testsuccess 
grep "Acquire-By-Hash: true" aptarchive
/dists
/unstable
/*Release
 
  53     buildsimplenativepackage 
'bar' 'i386' "$i" 'unstable' 
  54     buildaptarchivefromincoming
 
  57 hash_count
=$(ls aptarchive/dists/unstable/main/binary-i386/by-hash/SHA256/|wc -l) 
  58 # we have 2 files (uncompressed, gz) per run, 5 runs in total 
  59 # by default apt-ftparchive keeps three generations (current plus 2 older) 
  60 msgtest 
"Check that gc for by-hash works… " 
  61 if [ "$hash_count" = "6" ]; then 
  64     echo "Got $hash_count expected 6" 
  68 # ensure the current generation is still there