test-apt-by-hash-update 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. # make Packages *only* accessible by-hash for this test
  10. mkdir -p aptarchive/dists/unstable/main/binary-i386/by-hash/SHA512
  11. (cd aptarchive/dists/unstable/main/binary-i386/by-hash/SHA512 &&
  12. mv ../../Packages* . &&
  13. ln -s Packages.gz $(sha512sum Packages.gz|cut -f1 -d' ') )
  14. # add sources
  15. mkdir -p aptarchive/dists/unstable/main/source/by-hash/SHA512
  16. (cd aptarchive/dists/unstable/main/source/by-hash/SHA512 &&
  17. ln -s ../../Sources.gz $(sha512sum ../../Sources.gz|cut -f1 -d' ')
  18. )
  19. # we moved the Packages file away, normal update won't work
  20. testfailure aptget update
  21. # ensure we do not know about "foo"
  22. testfailureequal "Reading package lists...
  23. Building dependency tree...
  24. E: Unable to locate package foo" aptget install -q -s foo
  25. # ensure we can apt-get update by hash
  26. testsuccess aptget update -o APT::Acquire::By-Hash=1 -o Acquire::Languages=none
  27. ensureitworks() {
  28. testsuccessequal "Inst foo (1.0 unstable [all])
  29. Conf foo (1.0 unstable [all])" aptget install -qq -s foo
  30. }
  31. ensureitworks
  32. # add magic string to Release file ...
  33. MAGIC="Acquire-By-Hash: true"
  34. sed -i "s#Suite: unstable#Suite: unstable\n$MAGIC#" aptarchive/dists/unstable/Release
  35. signreleasefiles
  36. # ... and verify that it fetches by hash now
  37. rm -rf rootdir/var/lib/apt/lists
  38. testsuccess aptget update -o Acquire::Languages=none
  39. ensureitworks