test-apt-get-download 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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} -o Debug::pkgAcquire::Worker=1 -o Debug::pkgAcquire::Auth=1
  35. testsuccess test -f "$1"
  36. rm -f "$1"
  37. }
  38. # normal case as "root"
  39. OLDPWD="$(pwd)"
  40. cd downloaded
  41. testdownload apt_2.0_all.deb apt
  42. cd "$OLDPWD"
  43. # simulate normal user with non-existent root-owned directories
  44. rm -rf rootdir/var/cache/apt/archives/
  45. mkdir rootdir/var/cache/apt/archives/
  46. addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;"
  47. chmod -R -w rootdir/var/cache/apt/archives
  48. OLDPWD="$(pwd)"
  49. cd downloaded
  50. # normal case(es)
  51. testdownload apt_1.0_all.deb apt stable
  52. testdownload apt_2.0_all.deb apt
  53. DEBFILE="$(readlink -f ../aptarchive)/pool/apt_2.0_all.deb"
  54. testequal "'file://${DEBFILE}' apt_2.0_all.deb $(stat -c%s $DEBFILE) SHA512:$(sha512sum $DEBFILE | cut -d' ' -f 1)" aptget download apt --print-uris
  55. # deb:677887
  56. testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms --print-uris
  57. testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
  58. # deb:736962
  59. testsuccess aptget download apt
  60. testsuccess aptget download apt
  61. testsuccess test -s apt_2.0_all.deb
  62. rm -f apt_1.0_all.deb apt_2.0_all.deb
  63. # deb:738103
  64. testsuccess aptget download apt apt apt/unstable apt=2.0
  65. testsuccess test -s apt_2.0_all.deb
  66. # restore "root" rights
  67. cd "$OLDPWD"
  68. chmod -f -R +w $PWD/rootdir/var/cache/apt/archives
  69. rm -rf rootdir/var/cache/apt/archives/
  70. # file: debs aren't copied to archives, so change to http which obviously are
  71. changetowebserver
  72. testsuccess aptget update
  73. # test with already stored deb
  74. testsuccess aptget install -d apt
  75. testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb
  76. testaccessrights 'aptarchive/pool/apt_2.0_all.deb' '644'
  77. mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone
  78. cd downloaded
  79. testdownload apt_2.0_all.deb apt
  80. cd "$OLDPWD"
  81. mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb