test-apt-get-download 2.5 KB

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