test-apt-get-download 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture "i386"
  7. confighashes 'SHA512'
  8. buildsimplenativepackage 'apt' 'all' '1.0' 'stable'
  9. buildsimplenativepackage 'apt' 'all' '2.0' 'unstable'
  10. insertinstalledpackage 'vrms' 'all' '1.0'
  11. addtrap 'prefix' "umask $(umask);"
  12. umask 0027
  13. setupaptarchive --no-update
  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. if [ "$(id -u)" = '0' ]; then
  28. # permission errors an everything
  29. testfailure aptget update
  30. find aptarchive/dists -name '*Packages*' -type f | while read file; do
  31. chmod 777 "$file"
  32. done
  33. # permission errors on Release
  34. testwarning aptget update
  35. fi
  36. #everything (too) permissive
  37. find aptarchive/ -type f | while read file; do
  38. chmod 777 "$file"
  39. done
  40. find incoming/ -type f | while read file; do
  41. chmod 777 "$file"
  42. done
  43. testsuccess aptget update
  44. testdownload() {
  45. local DEB="$1"
  46. shift
  47. msgtest "Test download of package file $DEB with" "$@"
  48. testsuccess --nomsg aptget download "$@" -o Debug::pkgAcquire::Worker=1 -o Debug::pkgAcquire::Auth=1
  49. testsuccess test -f "$DEB"
  50. testaccessrights "$DEB" '644'
  51. rm -f "$DEB"
  52. }
  53. # normal case as "root"
  54. OLDPWD="$(pwd)"
  55. cd downloaded
  56. testdownload apt_2.0_all.deb apt
  57. cd "$OLDPWD"
  58. # simulate normal user with non-existent root-owned directories
  59. rm -rf rootdir/var/cache/apt/archives/
  60. mkdir rootdir/var/cache/apt/archives/
  61. addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;"
  62. chmod -R -w rootdir/var/cache/apt/archives
  63. OLDPWD="$(pwd)"
  64. cd downloaded
  65. # normal case(es)
  66. testdownload apt_1.0_all.deb apt/stable
  67. testdownload apt_2.0_all.deb apt
  68. DEBFILE="$(readlink -f ../aptarchive)/pool/apt_2.0_all.deb"
  69. testequal "'file://${DEBFILE}' apt_2.0_all.deb $(stat -c%s "$DEBFILE") SHA512:$(sha512sum "$DEBFILE" | cut -d' ' -f 1)" aptget download apt --print-uris
  70. # deb:677887
  71. testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms --print-uris
  72. testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
  73. # deb:736962
  74. testsuccess aptget download apt
  75. testsuccess test -s apt_2.0_all.deb
  76. testaccessrights 'apt_2.0_all.deb' '644'
  77. testsuccess aptget download apt
  78. testsuccess test -s apt_2.0_all.deb
  79. testaccessrights 'apt_2.0_all.deb' '644'
  80. rm -f apt_1.0_all.deb apt_2.0_all.deb
  81. # deb:738103
  82. testdownload apt_2.0_all.deb apt apt apt/unstable apt=2.0
  83. # FIXME: pick up already downloaded deb files for real
  84. # restore "root" rights
  85. #cd "$OLDPWD"
  86. #chmod -f -R +w "$PWD/rootdir/var/cache/apt/archives"
  87. #rm -rf rootdir/var/cache/apt/archives/
  88. # file: debs aren't copied to archives, so change to http which obviously are
  89. #changetowebserver
  90. #testsuccess aptget update
  91. # test with already stored deb
  92. #testsuccess aptget install -d apt
  93. #testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb
  94. #testaccessrights 'rootdir/var/cache/apt/archives/apt_2.0_all.deb' '644'
  95. #mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone
  96. #cd downloaded
  97. #testdownload apt_2.0_all.deb apt
  98. #cd "$OLDPWD"
  99. #mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb