test-apt-get-download 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. # Release file can't be accessed by _apt
  29. testsuccesswithnotice aptget update
  30. fi
  31. #everything (too) permissive
  32. find aptarchive/ -type f | while read file; do
  33. chmod 777 "$file"
  34. done
  35. find incoming/ -type f | while read file; do
  36. chmod 777 "$file"
  37. done
  38. testsuccess aptget update
  39. testdownload() {
  40. local DEB="$1"
  41. shift
  42. msgtest "Test download of package file $DEB with" "$@"
  43. testsuccess --nomsg aptget download "$@" -o Debug::pkgAcquire::Worker=1 -o Debug::pkgAcquire::Auth=1
  44. testsuccess test -f "$DEB"
  45. testaccessrights "$DEB" '644'
  46. rm -f "$DEB"
  47. }
  48. # normal case as "root"
  49. OLDPWD="$(pwd)"
  50. cd downloaded
  51. testdownload apt_2.0_all.deb apt
  52. cd "$OLDPWD"
  53. # simulate normal user with non-existent root-owned directories
  54. rm -rf rootdir/var/cache/apt/archives/
  55. mkdir rootdir/var/cache/apt/archives/
  56. addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/var/cache/apt/archives || true;"
  57. chmod -R -w rootdir/var/cache/apt/archives
  58. OLDPWD="$(pwd)"
  59. cd downloaded
  60. # normal case(es)
  61. testdownload apt_1.0_all.deb apt/stable
  62. testdownload apt_2.0_all.deb apt
  63. DEBFILE="$(readlink -f ../aptarchive)/pool/apt_2.0_all.deb"
  64. testequal "'file://${DEBFILE}' apt_2.0_all.deb $(stat -c%s "$DEBFILE") SHA512:$(sha512sum "$DEBFILE" | cut -d' ' -f 1)" aptget download apt --print-uris
  65. # deb:677887
  66. testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms --print-uris
  67. testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms
  68. # deb:736962
  69. testsuccess aptget download apt
  70. testsuccess test -s apt_2.0_all.deb
  71. testaccessrights 'apt_2.0_all.deb' '644'
  72. testsuccess aptget download apt
  73. testsuccess test -s apt_2.0_all.deb
  74. testaccessrights 'apt_2.0_all.deb' '644'
  75. rm -f apt_1.0_all.deb apt_2.0_all.deb
  76. # deb:738103
  77. testdownload apt_2.0_all.deb apt apt apt/unstable apt=2.0
  78. # FIXME: pick up already downloaded deb files for real
  79. # restore "root" rights
  80. #cd "$OLDPWD"
  81. #chmod -f -R +w "$PWD/rootdir/var/cache/apt/archives"
  82. #rm -rf rootdir/var/cache/apt/archives/
  83. # file: debs aren't copied to archives, so change to http which obviously are
  84. #changetowebserver
  85. #testsuccess aptget update
  86. # test with already stored deb
  87. #testsuccess aptget install -d apt
  88. #testsuccess test -s rootdir/var/cache/apt/archives/apt_2.0_all.deb
  89. #testaccessrights 'rootdir/var/cache/apt/archives/apt_2.0_all.deb' '644'
  90. #mv aptarchive/pool/apt_2.0_all.deb aptarchive/pool/apt_2.0_all.deb.gone
  91. #cd downloaded
  92. #testdownload apt_2.0_all.deb apt
  93. #cd "$OLDPWD"
  94. #mv aptarchive/pool/apt_2.0_all.deb.gone aptarchive/pool/apt_2.0_all.deb