test-apt-get-download 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture "i386"
  7. buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
  8. buildsimplenativepackage 'apt' 'all' '2.0' 'unstable'
  9. insertinstalledpackage 'vrms' 'all' '1.0'
  10. OLD_UMASK="$(umask)"
  11. umask 0027
  12. setupaptarchive --no-update
  13. umask "$OLD_UMASK"
  14. # directories should be readable by everyone
  15. find aptarchive/dists -type d | while read dir; do
  16. chmod o+rx "$dir"
  17. done
  18. # apt-ftparchive knows how to chmod files
  19. find aptarchive/dists -name '*Packages*' -type f | while read file; do
  20. testaccessrights "$file" '644'
  21. chmod 640 "$file"
  22. done
  23. # created by the framework without special care
  24. find aptarchive/dists -name '*Release*' -type f | while read file; do
  25. testaccessrights "$file" '640'
  26. done
  27. testsuccess aptget update
  28. testdownload() {
  29. local APT="$2"
  30. if [ -n "$3" ]; then
  31. APT="${APT}/${3}"
  32. fi
  33. msgtest "Test download of package file $1 with" "$APT"
  34. testsuccess --nomsg aptget download ${APT}
  35. testsuccess test -f "$1"
  36. rm -f "$1"
  37. }
  38. # normal case as "root"
  39. testdownload apt_2.0_all.deb apt
  40. # simulate normal user with non-existent root-owned directories
  41. rm -rf rootdir/var/cache/apt/archives/
  42. mkdir rootdir/var/cache/apt/archives/
  43. addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;"
  44. chmod -R -w rootdir/var/cache/apt/archives
  45. # normal case(es)
  46. testdownload apt_1.0_all.deb apt stable
  47. testdownload apt_2.0_all.deb apt
  48. DEBFILE="$(readlink -f aptarchive)/pool/apt_2.0_all.deb"
  49. testequal "'file://${DEBFILE}' apt_2.0_all.deb $(stat -c%s $DEBFILE) SHA512:$(sha512sum $DEBFILE | cut -d' ' -f 1)" aptget download apt --print-uris
  50. # deb:677887
  51. testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
  52. # deb:736962
  53. testsuccess aptget download apt
  54. testsuccess aptget download apt
  55. testsuccess test -s apt_2.0_all.deb
  56. rm -f apt_1.0_all.deb apt_2.0_all.deb
  57. # deb:738103
  58. testsuccess aptget download apt apt apt/unstable apt=2.0
  59. testsuccess test -s apt_2.0_all.deb
  60. # restore "root" rights
  61. chmod -f -R +w $PWD/rootdir/var/cache/apt/archives
  62. rm -rf rootdir/var/cache/apt/archives/
  63. # file: debs aren't copied to archives, so change to http which obviously are
  64. changetowebserver
  65. testsuccess aptget update
  66. # test with already stored deb
  67. testsuccess aptget install -d apt
  68. testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb
  69. testaccessrights 'aptarchive/pool/apt_2.0_all.deb' '644'
  70. mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone
  71. testdownload apt_2.0_all.deb apt
  72. mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb