test-compressed-indexes 7.3 KB

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