test-apt-by-hash-update 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture "i386"
  7. insertpackage 'unstable' 'foo' 'all' '1.0'
  8. setupaptarchive --no-update
  9. APTARCHIVE=$(readlink -f ./aptarchive)
  10. # make Packages *only* accessable by-hash for this test
  11. mkdir -p aptarchive/dists/unstable/main/binary-i386/by-hash/SHA512
  12. (cd aptarchive/dists/unstable/main/binary-i386/by-hash/SHA512 &&
  13. mv ../../Packages* . &&
  14. ln -s Packages.gz $(sha512sum Packages.gz|cut -f1 -d' ') )
  15. # add sources
  16. mkdir -p aptarchive/dists/unstable/main/source/by-hash/SHA512
  17. (cd aptarchive/dists/unstable/main/source/by-hash/SHA512 &&
  18. ln -s ../../Sources.gz $(sha512sum ../../Sources.gz|cut -f1 -d' ')
  19. )
  20. # we moved the Packages file away, normal update won't work
  21. testfailure aptget upate
  22. # ensure we do not know about "foo"
  23. testequal "Reading package lists...
  24. Building dependency tree...
  25. E: Unable to locate package foo" aptget install -q -s foo
  26. # ensure we can apt-get update by hash
  27. testsuccess aptget update -o APT::Acquire::By-Hash=1
  28. # ensure it works
  29. testequal "Inst foo (1.0 unstable [all])
  30. Conf foo (1.0 unstable [all])" aptget install -qq -s foo
  31. # add magic string to Release file ...
  32. MAGIC="Acquire-By-Hash: true"
  33. sed -i "s#Suite: unstable#Suite: unstable\n$MAGIC#" aptarchive/dists/unstable/Release
  34. signreleasefiles
  35. # ... and verify that it fetches by hash now
  36. testsuccess aptget update