test-compressed-indexes 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. 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::CompressionTypes::Order:: "gz";
  77. Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
  78. testsuccess aptget update
  79. msgmsg "File: Test with compressed indexes"
  80. testrun "compressed"
  81. testsuccess aptget update -o Acquire::Pdiffs=1
  82. msgmsg "File: Test with compressed indexes (update unchanged with pdiffs)"
  83. testrun "compressed"
  84. testsuccess aptget update -o Acquire::Pdiffs=0
  85. msgmsg "File: Test with compressed indexes (update unchanged without pdiffs)"
  86. testrun "compressed"
  87. rm rootdir/etc/apt/apt.conf.d/02compressindex
  88. changetowebserver
  89. testsuccess aptget update
  90. GOODPOLICY="$(aptcache policy testpkg)"
  91. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 http://' | wc -l) -eq 4
  92. testequal "$GOODPOLICY" aptcache policy testpkg
  93. msgmsg "HTTP: Test with uncompressed indexes"
  94. testrun
  95. testsuccess aptget update -o Acquire::Pdiffs=1
  96. msgmsg "HTTP: Test with uncompressed indexes (update unchanged with pdiffs)"
  97. testrun
  98. testsuccess aptget update -o Acquire::Pdiffs=0
  99. msgmsg "HTTP: Test with uncompressed indexes (update unchanged without pdiffs)"
  100. testrun
  101. rm -rf rootdir/var/lib/apt/lists
  102. echo 'Acquire::CompressionTypes::Order:: "gz";
  103. Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
  104. testsuccess aptget update
  105. msgmsg "HTTP: Test with compressed indexes"
  106. testrun "compressed"
  107. testsuccess aptget update -o Acquire::Pdiffs=1
  108. msgmsg "HTTP: Test with compressed indexes (update unchanged with pdiffs)"
  109. testrun "compressed"
  110. testsuccess aptget update -o Acquire::Pdiffs=0
  111. msgmsg "HTTP: Test with compressed indexes (update unchanged without pdiffs)"
  112. testrun "compressed"