test-compressed-indexes 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configcompression '.' 'xz' 'bz2' 'lzma' 'gz'
  7. configarchitecture 'i386'
  8. buildsimplenativepackage 'testpkg' 'i386' '1.0'
  9. buildaptarchive
  10. setupdistsaptarchive
  11. # fake a pdiff setup as apt wouldn't try pdiffs otherwise
  12. find aptarchive -name 'Packages' -o -name 'Sources' | while read file; do
  13. mkdir "${file}.diff"
  14. PATCHINDEX="${file}.diff/Index"
  15. echo 'SHA1-Current: adc83b19e793491b1c6ea0fd8b46cd9f32e592fc 0
  16. SHA1-History:
  17. adc83b19e793491b1c6ea0fd8b46cd9f32e592fc 33053002 2010-08-18-2013.28
  18. ecfd1b19e793491b1c6ea123eabdcd9f32e592fc 33053001 2010-08-18-2013.29
  19. SHA1-Patches:
  20. abc1fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
  21. dfe3444ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.29' > $PATCHINDEX
  22. done
  23. generatereleasefiles
  24. signreleasefiles
  25. testrun() {
  26. local F
  27. msgtest 'Check if all index files are' "${1:-uncompressed}"
  28. if [ "$1" = 'compressed' ]; then
  29. ! test -e rootdir/var/lib/apt/lists/*_Packages || F=1
  30. ! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
  31. ! test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
  32. test -e rootdir/var/lib/apt/lists/*_Packages.${COMPRESS} || F=1
  33. test -e rootdir/var/lib/apt/lists/*_Sources.${COMPRESS} || F=1
  34. test -e rootdir/var/lib/apt/lists/*_Translation-en.${COMPRESS} || F=1
  35. # there is no point in trying pdiff if we have compressed indexes
  36. # as we can't patch compressed files (well, we can, but what is the point?)
  37. ! test -e rootdir/var/lib/apt/lists/*diff_Index || F=1
  38. else
  39. # clear the faked pdiff indexes so the glob below works
  40. rm -f rootdir/var/lib/apt/lists/*diff_Index
  41. test -e rootdir/var/lib/apt/lists/*_Packages || F=1
  42. test -e rootdir/var/lib/apt/lists/*_Sources || F=1
  43. test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
  44. ! test -e rootdir/var/lib/apt/lists/*_Packages.* || F=1
  45. ! test -e rootdir/var/lib/apt/lists/*_Sources.* || F=1
  46. ! test -e rootdir/var/lib/apt/lists/*_Translation-en.* || F=1
  47. fi
  48. if [ -n "$F" ]; then
  49. cat rootdir/tmp/testsuccess.output
  50. ls -laR rootdir/var/lib/apt/lists/
  51. msgfail
  52. else
  53. msgpass
  54. fi
  55. msgtest 'Check if package is downloadable'
  56. testsuccess --nomsg aptget download testpkg
  57. msgtest '\tdeb file is present'; testsuccess --nomsg test -f testpkg_1.0_i386.deb
  58. rm testpkg_1.0_i386.deb
  59. testequal 'Reading package lists...
  60. Building dependency tree...
  61. The following NEW packages will be installed:
  62. testpkg
  63. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  64. Inst testpkg (1.0 unstable [i386])
  65. Conf testpkg (1.0 unstable [i386])' aptget install testpkg -s
  66. rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
  67. testequal "$GOODSHOW" aptcache show testpkg
  68. testequal "$GOODSHOW" aptcache show testpkg
  69. rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
  70. testequal "$GOODPOLICY" aptcache policy testpkg
  71. testequal "$GOODPOLICY" aptcache policy testpkg
  72. rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
  73. testequal "$GOODSHOWSRC" aptcache showsrc testpkg
  74. testequal "$GOODSHOWSRC" aptcache showsrc testpkg
  75. aptget clean
  76. msgtest 'Check if the source is aptgetable'
  77. testsuccess --nomsg aptget source testpkg
  78. msgtest '\tdsc file is present'; testsuccess --nomsg test -f testpkg_1.0.dsc
  79. msgtest '\tdirectory is present'; testsuccess --nomsg test -d testpkg-1.0
  80. rm -rf testpkg-1.0*
  81. testequal "$(aptcache show testpkg -o Acquire::Languages=none)
  82. " aptcache dumpavail
  83. }
  84. echo 'Debug::pkgAcquire::worker "true";
  85. debug::pkgAcquire::Auth "true";
  86. Debug::pkgAcquire::Diffs "true";' > rootdir/etc/apt/apt.conf.d/99debugconf
  87. testovermethod() {
  88. forcecompressor $2
  89. for INDEX in 'false' 'true'; do
  90. rm -rf rootdir/var/lib/apt/lists
  91. echo "Acquire::GzipIndexes \"${INDEX}\";" > rootdir/etc/apt/apt.conf.d/02compressindex
  92. local INDCOMP
  93. if [ "$INDEX" = 'false' ]; then
  94. INDCOMP='uncompressed'
  95. else
  96. INDCOMP='compressed'
  97. fi
  98. testsuccess aptget update -o Debug::Acquire::http=1
  99. msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes"
  100. testrun "$INDCOMP"
  101. testsuccess aptget update -o Acquire::Pdiffs=1 -o Debug::Acquire::http=1
  102. msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes (update unchanged with pdiffs)"
  103. testrun "$INDCOMP"
  104. testsuccess aptget update -o Acquire::Pdiffs=0 -o Debug::Acquire::http=1
  105. msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes (update unchanged without pdiffs)"
  106. testrun "$INDCOMP"
  107. rm rootdir/etc/apt/apt.conf.d/02compressindex
  108. done
  109. }
  110. testsuccess aptget update
  111. GOODSHOW="$(aptcache show testpkg)
  112. "
  113. test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
  114. testequal "$GOODSHOW" aptcache show testpkg
  115. GOODSHOWSRC="$(aptcache showsrc testpkg)
  116. "
  117. 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'
  118. testequal "$GOODSHOWSRC" aptcache showsrc testpkg
  119. GOODPOLICY="$(aptcache policy testpkg)"
  120. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 file:/' | wc -l) -eq 4 || msgdie 'policy is broken'
  121. testequal "$GOODPOLICY" aptcache policy testpkg
  122. for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'file' $COMPRESSOR; done
  123. changetowebserver
  124. rm -rf rootdir/var/lib/apt/lists
  125. testsuccess aptget update
  126. GOODPOLICY="$(aptcache policy testpkg)"
  127. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 http://' | wc -l) -eq 4 || msgdie 'policy is broken'
  128. testequal "$GOODPOLICY" aptcache policy testpkg
  129. for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'http' $COMPRESSOR; done