test-apt-by-hash-update 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/sh
  2. set -e
  3. TESTDIR="$(readlink -f "$(dirname "$0")")"
  4. . "$TESTDIR/framework"
  5. setupenvironment
  6. configarchitecture 'i386'
  7. confighashes 'SHA512'
  8. configcompression '.' 'gz'
  9. insertpackage 'unstable' 'foo' 'all' '1.0'
  10. insertpackage 'unstable' 'bar' 'i386' '1.0'
  11. setupaptarchive --no-update
  12. # make Packages *only* accessible by-hash for this test
  13. makebyhashonly() {
  14. local NORMAL="$(readlink -f "./aptarchive/dists/unstable/main/${1}")"
  15. local BYHASH="${NORMAL}/by-hash/SHA512"
  16. mkdir -p "${BYHASH}"
  17. find "${NORMAL}/" -maxdepth 1 -name "${2}*" -exec mv '{}' "$BYHASH" \;
  18. ln -s "${BYHASH}/${2}.gz" "${BYHASH}/$(sha512sum "${BYHASH}/${2}.gz" | cut -f1 -d' ')"
  19. }
  20. makebyhashonly 'binary-i386' 'Packages'
  21. makebyhashonly 'binary-all' 'Packages'
  22. makebyhashonly 'source' 'Sources'
  23. ensureitsbroken() {
  24. rm -rf rootdir/var/lib/apt/lists
  25. # we moved the Packages file away, normal update won't work
  26. testfailure aptget update "$@"
  27. # ensure we do not know about "foo"
  28. testfailureequal "Reading package lists...
  29. Building dependency tree...
  30. E: Unable to locate package foo" aptget install -q -s foo
  31. }
  32. ensureitsbroken
  33. ensureitsbroken -o Acquire::By-Hash=1
  34. ensureitworks() {
  35. rm -rf rootdir/var/lib/apt/lists
  36. testsuccess aptget update "$@" -o Acquire::Languages=none
  37. testfailure grep '^Ign' rootdir/tmp/testsuccess.output
  38. rm -rf rootdir/var/lib/apt/lists
  39. testsuccess aptget update "$@"
  40. cp -f rootdir/tmp/testsuccess.output rootdir/tmp/aptupdate.output
  41. testsuccess grep '^Ign' rootdir/tmp/aptupdate.output
  42. testsuccessequal "Inst foo (1.0 unstable [all])
  43. Conf foo (1.0 unstable [all])" aptget install -qq -s foo
  44. testsuccessequal "Inst bar (1.0 unstable [i386])
  45. Conf bar (1.0 unstable [i386])" aptget install -qq -s bar
  46. }
  47. msgmsg 'Test by-hash via' 'config option'
  48. ensureitworks -o Acquire::By-Hash=force
  49. msgmsg 'Test by-hash via' 'release option'
  50. cp -a aptarchive/dists aptarchive/dists.bak
  51. # add magic string to Release file ...
  52. sed -i '/^Suite: / a \
  53. Acquire-By-Hash: yes' aptarchive/dists/unstable/Release
  54. signreleasefiles
  55. ensureitworks
  56. ensureitsbroken -o Acquire::By-Hash=0
  57. msgmsg 'Test by-hash via' 'sources option'
  58. sed -i "s#^\(deb\(-src\)\?\) #\1 [by-hash=yes] #" rootdir/etc/apt/sources.list.d/*
  59. ensureitworks
  60. #ensureitsbroken -o Acquire::By-Hash=0
  61. rm -rf aptarchive/dists
  62. cp -a aptarchive/dists.bak aptarchive/dists
  63. #ensureitworks -o Acquire::By-Hash=force
  64. ensureitsbroken -o Acquire::By-Hash=1
  65. ensureitsbroken -o Acquire::By-Hash=0
  66. sed -i "s#^\(deb\(-src\)\?\) \[by-hash=yes\] #\1 [by-hash=force] #" rootdir/etc/apt/sources.list.d/*
  67. ensureitworks
  68. #ensureitsbroken -o Acquire::By-Hash=0