test-compressed-indexes 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configcompression '.' 'xz' 'gz'
  7. configarchitecture "i386"
  8. buildsimplenativepackage "testpkg" "i386" "1.0"
  9. setupaptarchive
  10. GOODSHOW="$(aptcache show testpkg)
  11. "
  12. GOODPOLICY="$(aptcache policy testpkg)"
  13. GOODSHOWSRC="$(aptcache showsrc testpkg)
  14. "
  15. test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
  16. testequal "$GOODSHOW" aptcache show testpkg
  17. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 file:/' | wc -l) -eq 4 || msgdie 'policy is broken'
  18. testequal "$GOODPOLICY" aptcache policy testpkg
  19. test $(echo "$GOODSHOWSRC" | grep -e '^Package: testpkg' -e '^Format: 3.0 (native)' -e '^Files:' -e '^Checksums-Sha256:' | wc -l) -eq 4 || msgdie 'showsrc is broken'
  20. testequal "$GOODSHOWSRC" aptcache showsrc testpkg
  21. testrun() {
  22. local F
  23. if [ -e rootdir/var/lib/apt/lists/*localhost*Release ]; then
  24. msgtest "Check if all index files are" "${1:-uncompressed}"
  25. if [ "$1" = "compressed" ]; then
  26. ! test -e rootdir/var/lib/apt/lists/*_Packages || F=1
  27. ! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
  28. test -e rootdir/var/lib/apt/lists/*_Packages.xz || F=1
  29. test -e rootdir/var/lib/apt/lists/*_Sources.xz || F=1
  30. else
  31. test -e rootdir/var/lib/apt/lists/*_Packages || F=1
  32. test -e rootdir/var/lib/apt/lists/*_Sources || F=1
  33. ! test -e rootdir/var/lib/apt/lists/*_Packages.xz || F=1
  34. ! test -e rootdir/var/lib/apt/lists/*_Sources.xz || F=1
  35. fi
  36. if [ -n "$F" ]; then
  37. ls -laR rootdir/var/lib/apt/lists/
  38. msgfail
  39. else
  40. msgpass
  41. fi
  42. msgtest "Check if package is downloadable"
  43. testsuccess --nomsg aptget install -d testpkg
  44. msgtest "\tdeb file is present"; testsuccess --nomsg test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb
  45. aptget clean
  46. msgtest "\tdeb file is gone"; testfailure --nomsg test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb
  47. fi
  48. rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
  49. testequal "$GOODSHOW" aptcache show testpkg
  50. testequal "$GOODSHOW" aptcache show testpkg
  51. rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
  52. testequal "$GOODPOLICY" aptcache policy testpkg
  53. testequal "$GOODPOLICY" aptcache policy testpkg
  54. rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
  55. testequal "$GOODSHOWSRC" aptcache showsrc testpkg
  56. testequal "$GOODSHOWSRC" aptcache showsrc testpkg
  57. aptget clean
  58. msgtest "Check if the source is aptgetable"
  59. testsuccess --nomsg aptget source testpkg
  60. msgtest "\tdsc file is present"; testsuccess --nomsg test -f testpkg_1.0.dsc
  61. msgtest "\tdirectory is present"; testsuccess --nomsg test -d testpkg-1.0
  62. rm -rf testpkg-1.0
  63. testequal "$(aptcache show testpkg -o Acquire::Languages=none)
  64. " aptcache dumpavail
  65. }
  66. echo 'Acquire::GzipIndexes "false";' > rootdir/etc/apt/apt.conf.d/02compressindex
  67. msgmsg "File: Test with uncompressed indexes"
  68. testrun
  69. testsuccess aptget update -o Acquire::Pdiffs=1
  70. msgmsg "File: Test with uncompressed indexes (update unchanged with pdiffs)"
  71. testrun
  72. testsuccess aptget update -o Acquire::Pdiffs=0
  73. msgmsg "File: Test with uncompressed indexes (update unchanged without pdiffs)"
  74. testrun
  75. rm -rf rootdir/var/lib/apt/lists
  76. echo 'Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
  77. testsuccess aptget update -o Debug::pkgAcquire::worker=1
  78. msgmsg "File: Test with compressed indexes"
  79. testrun "compressed"
  80. testsuccess aptget update -o Acquire::Pdiffs=1
  81. msgmsg "File: Test with compressed indexes (update unchanged with pdiffs)"
  82. testrun "compressed"
  83. testsuccess aptget update -o Acquire::Pdiffs=0
  84. msgmsg "File: Test with compressed indexes (update unchanged without pdiffs)"
  85. testrun "compressed"
  86. rm rootdir/etc/apt/apt.conf.d/02compressindex
  87. changetowebserver
  88. testsuccess aptget update
  89. GOODPOLICY="$(aptcache policy testpkg)"
  90. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 http://' | wc -l) -eq 4
  91. testequal "$GOODPOLICY" aptcache policy testpkg
  92. msgmsg "HTTP: Test with uncompressed indexes"
  93. testrun
  94. testsuccess aptget update -o Acquire::Pdiffs=1
  95. msgmsg "HTTP: Test with uncompressed indexes (update unchanged with pdiffs)"
  96. testrun
  97. testsuccess aptget update -o Acquire::Pdiffs=0
  98. msgmsg "HTTP: Test with uncompressed indexes (update unchanged without pdiffs)"
  99. testrun
  100. rm -rf rootdir/var/lib/apt/lists
  101. echo 'Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
  102. testsuccess aptget update
  103. msgmsg "HTTP: Test with compressed indexes"
  104. testrun "compressed"
  105. testsuccess aptget update -o Acquire::Pdiffs=1 -o debug::pkgAcquire::Worker=1 -o debug::pkgAcquire::Auth=1
  106. msgmsg "HTTP: Test with compressed indexes (update unchanged with pdiffs)"
  107. testrun "compressed"
  108. testsuccess aptget update -o Acquire::Pdiffs=0
  109. msgmsg "HTTP: Test with compressed indexes (update unchanged without pdiffs)"
  110. testrun "compressed"