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 '.' 'gz' # only gz is supported for this, so ensure it is used
  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.gz || F=1
  29. test -e rootdir/var/lib/apt/lists/*_Sources.gz || 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.gz || F=1
  34. ! test -e rootdir/var/lib/apt/lists/*_Sources.gz || 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. }
  64. echo 'Acquire::GzipIndexes "false";' > rootdir/etc/apt/apt.conf.d/02compressindex
  65. msgmsg "File: Test with uncompressed indexes"
  66. testrun
  67. testsuccess aptget update -o Acquire::Pdiffs=1
  68. msgmsg "File: Test with uncompressed indexes (update unchanged with pdiffs)"
  69. testrun
  70. testsuccess aptget update -o Acquire::Pdiffs=0
  71. msgmsg "File: Test with uncompressed indexes (update unchanged without pdiffs)"
  72. testrun
  73. rm -rf rootdir/var/lib/apt/lists
  74. echo 'Acquire::CompressionTypes::Order:: "gz";
  75. Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
  76. testsuccess aptget update
  77. msgmsg "File: Test with compressed indexes"
  78. testrun "compressed"
  79. testsuccess aptget update -o Acquire::Pdiffs=1
  80. msgmsg "File: Test with compressed indexes (update unchanged with pdiffs)"
  81. testrun "compressed"
  82. testsuccess aptget update -o Acquire::Pdiffs=0
  83. msgmsg "File: Test with compressed indexes (update unchanged without pdiffs)"
  84. testrun "compressed"
  85. rm rootdir/etc/apt/apt.conf.d/02compressindex
  86. changetowebserver
  87. testsuccess aptget update
  88. GOODPOLICY="$(aptcache policy testpkg)"
  89. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 http://' | wc -l) -eq 4
  90. testequal "$GOODPOLICY" aptcache policy testpkg
  91. msgmsg "HTTP: Test with uncompressed indexes"
  92. testrun
  93. testsuccess aptget update -o Acquire::Pdiffs=1
  94. msgmsg "HTTP: Test with uncompressed indexes (update unchanged with pdiffs)"
  95. testrun
  96. testsuccess aptget update -o Acquire::Pdiffs=0
  97. msgmsg "HTTP: Test with uncompressed indexes (update unchanged without pdiffs)"
  98. testrun
  99. rm -rf rootdir/var/lib/apt/lists
  100. echo 'Acquire::CompressionTypes::Order:: "gz";
  101. 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
  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"