test-indexes.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/sh -e
  2. # Test behaviour of index retrieval and usage, in particular with uncompressed
  3. # and gzip compressed indexes.
  4. # Author: Martin Pitt <martin.pitt@ubuntu.com>
  5. # (C) 2010 Canonical Ltd.
  6. BUILDDIR=$(readlink -f $(dirname $0)/../build)
  7. TEST_SOURCE="deb http://ftp.debian.org/debian unstable contrib"
  8. TEST_SOURCE_KEYID=55BE302B
  9. GPG_KEYSERVER=gpg-keyserver.de
  10. # should be a small package with dependencies satisfiable in TEST_SOURCE, i. e.
  11. # ideally no depends at all
  12. TEST_PKG="python-psyco-doc"
  13. export LD_LIBRARY_PATH=$BUILDDIR/bin
  14. OPTS="-o RootDir=. -o Dir::Bin::Methods=$BUILDDIR/bin/methods -o Debug::NoLocking=true"
  15. DEBUG=""
  16. #DEBUG="-o Debug::pkgCacheGen=true"
  17. #DEBUG="-o Debug::pkgAcquire=true"
  18. APT_GET="$BUILDDIR/bin/apt-get $OPTS $DEBUG"
  19. APT_CACHE="$BUILDDIR/bin/apt-cache $OPTS $DEBUG"
  20. [ -x "$BUILDDIR/bin/apt-get" ] || {
  21. echo "please build the tree first" >&2
  22. exit 1
  23. }
  24. echo "---- building sandbox----"
  25. WORKDIR=$(mktemp -d)
  26. trap "cd /; rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
  27. cd $WORKDIR
  28. rm -fr etc var
  29. rm -f home
  30. ln -s /home home
  31. mkdir -p etc/apt/preferences.d etc/apt/trusted.gpg.d var/cache/apt/archives/partial var/lib/apt/lists/partial var/lib/dpkg
  32. cp /etc/apt/trusted.gpg etc/apt
  33. touch var/lib/dpkg/status
  34. echo "$TEST_SOURCE" > etc/apt/sources.list
  35. # get keyring
  36. gpg --no-options --no-default-keyring --secret-keyring etc/apt/secring.gpg --trustdb-name etc/apt/trustdb.gpg --keyring etc/apt/trusted.gpg --primary-keyring etc/apt/trusted.gpg --keyserver $GPG_KEYSERVER --recv-keys $TEST_SOURCE_KEYID
  37. echo "---- uncompressed update ----"
  38. $APT_GET update
  39. test -e var/lib/apt/lists/*_Packages
  40. ! test -e var/lib/apt/lists/*_Packages.gz
  41. echo "---- uncompressed cache ----"
  42. $APT_CACHE show $TEST_PKG | grep -q ^Version:
  43. # again (with cache)
  44. $APT_CACHE show $TEST_PKG | grep -q ^Version:
  45. rm var/cache/apt/*.bin
  46. $APT_CACHE policy $TEST_PKG | grep -q '500 http://'
  47. # again (with cache)
  48. $APT_CACHE policy $TEST_PKG | grep -q '500 http://'
  49. echo "---- uncompressed install ----"
  50. $APT_GET install -d $TEST_PKG
  51. test -e var/cache/apt/archives/$TEST_PKG*.deb
  52. $APT_GET clean
  53. ! test -e var/cache/apt/archives/$TEST_PKG*.deb
  54. echo "----- uncompressed update with preexisting indexes, no pdiff ----"
  55. $APT_GET -o Acquire::PDiffs=false update
  56. test -e var/lib/apt/lists/*_Packages
  57. ! test -e var/lib/apt/lists/*_Packages.gz
  58. echo "----- uncompressed update with preexisting indexes, with pdiff ----"
  59. $APT_GET -o Acquire::PDiffs=true update
  60. test -e var/lib/apt/lists/*_Packages
  61. ! test -e var/lib/apt/lists/*_Packages.gz
  62. echo "----- compressed update ----"
  63. find var/lib/apt/lists/ -type f | xargs -r rm
  64. $APT_GET -o Acquire::GzipIndexes=true update
  65. ! test -e var/lib/apt/lists/*_Packages
  66. test -e var/lib/apt/lists/*_Packages.gz
  67. echo "---- compressed cache ----"
  68. $APT_CACHE show $TEST_PKG | grep -q ^Version:
  69. # again (with cache)
  70. $APT_CACHE show $TEST_PKG | grep -q ^Version:
  71. rm var/cache/apt/*.bin
  72. $APT_CACHE policy $TEST_PKG | grep -q '500 http://'
  73. # again (with cache)
  74. $APT_CACHE policy $TEST_PKG | grep -q '500 http://'
  75. echo "---- compressed install ----"
  76. $APT_GET install -d $TEST_PKG
  77. ! test -e var/cache/apt/archives/$TEST_PKG*.deb
  78. echo "----- compressed update with preexisting indexes, no pdiff ----"
  79. $APT_GET -o Acquire::PDiffs=false -o Acquire::GzipIndexes=true update
  80. ! test -e var/lib/apt/lists/*_Packages
  81. test -e var/lib/apt/lists/*_Packages.gz
  82. echo "----- compressed update with preexisting indexes, with pdiff ----"
  83. $APT_GET -o Acquire::PDiffs=true -o Acquire::GzipIndexes=true update
  84. ! test -e var/lib/apt/lists/*_Packages
  85. test -e var/lib/apt/lists/*_Packages.gz
  86. echo "---- ALL TESTS PASSED ----"