test-compressed-indexes 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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/*i386_Packages || F=1
  30. ! test -e rootdir/var/lib/apt/lists/*all_Packages || F=1
  31. ! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
  32. ! test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
  33. test -e rootdir/var/lib/apt/lists/*i386_Packages.${COMPRESS} || F=1
  34. test -e rootdir/var/lib/apt/lists/*all_Packages.${COMPRESS} || F=1
  35. test -e rootdir/var/lib/apt/lists/*_Sources.${COMPRESS} || F=1
  36. test -e rootdir/var/lib/apt/lists/*_Translation-en.${COMPRESS} || F=1
  37. # there is no point in trying pdiff if we have compressed indexes
  38. # as we can't patch compressed files (well, we can, but what is the point?)
  39. ! test -e rootdir/var/lib/apt/lists/*diff_Index || F=1
  40. else
  41. # clear the faked pdiff indexes so the glob below works
  42. rm -f rootdir/var/lib/apt/lists/*diff_Index
  43. test -e rootdir/var/lib/apt/lists/*i386_Packages || F=1
  44. test -e rootdir/var/lib/apt/lists/*all_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. ! test -e rootdir/var/lib/apt/lists/*i386_Packages.* || F=1
  48. ! test -e rootdir/var/lib/apt/lists/*all_Packages.* || F=1
  49. ! test -e rootdir/var/lib/apt/lists/*_Sources.* || F=1
  50. ! test -e rootdir/var/lib/apt/lists/*_Translation-en.* || F=1
  51. fi
  52. if [ -n "$F" ]; then
  53. cat rootdir/tmp/testsuccess.output
  54. ls -laR rootdir/var/lib/apt/lists/
  55. msgfail
  56. else
  57. msgpass
  58. fi
  59. msgtest 'Check if package is downloadable'
  60. cd downloaded
  61. testsuccess --nomsg aptget download testpkg
  62. msgtest 'deb file is present'; testsuccess --nomsg test -f testpkg_1.0_i386.deb
  63. rm -f testpkg_1.0_i386.deb
  64. cd - >/dev/null
  65. testsuccessequal 'Reading package lists...
  66. Building dependency tree...
  67. The following NEW packages will be installed:
  68. testpkg
  69. 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
  70. Inst testpkg (1.0 unstable [i386])
  71. Conf testpkg (1.0 unstable [i386])' aptget install testpkg -s
  72. rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
  73. testsuccessequal "$GOODSHOW" aptcache show testpkg
  74. testsuccessequal "$GOODSHOW" aptcache show testpkg
  75. rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
  76. testsuccessequal "$GOODPOLICY" aptcache policy testpkg
  77. testsuccessequal "$GOODPOLICY" aptcache policy testpkg
  78. rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
  79. testsuccessequal "$GOODSHOWSRC" aptcache showsrc testpkg
  80. testsuccessequal "$GOODSHOWSRC" aptcache showsrc testpkg
  81. aptget clean
  82. msgtest 'Check if the source is aptgetable'
  83. cd downloaded
  84. testsuccess --nomsg aptget source testpkg
  85. testsuccess test -s testpkg_1.0.dsc
  86. testsuccess test -d testpkg-1.0
  87. rm -rf testpkg-1.0*
  88. cd - >/dev/null
  89. testsuccessequal "$(aptcache show testpkg -o Acquire::Languages=none)
  90. " aptcache dumpavail
  91. }
  92. echo 'Debug::pkgAcquire::worker "true";
  93. debug::pkgAcquire::Auth "true";
  94. Debug::pkgAcquire::Diffs "true";
  95. Debug::Acquire::http "true";' > rootdir/etc/apt/apt.conf.d/99debugconf
  96. testovermethod() {
  97. forcecompressor $2
  98. for INDEX in 'false' 'true'; do
  99. rm -rf rootdir/var/lib/apt/lists
  100. echo "Acquire::GzipIndexes \"${INDEX}\";" > rootdir/etc/apt/apt.conf.d/02compressindex
  101. local INDCOMP
  102. if [ "$INDEX" = 'false' -o "$1" = 'cdrom' ]; then
  103. INDCOMP='uncompressed'
  104. else
  105. INDCOMP='compressed'
  106. fi
  107. msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes gzip=$INDEX"
  108. if [ "${1}" = 'cdrom' ]; then
  109. testsuccess aptcdrom add </dev/null
  110. fi
  111. testsuccess aptget update
  112. testrun "$INDCOMP"
  113. if [ "${1}" != 'cdrom' ]; then
  114. testsuccess aptget update -o Acquire::Pdiffs=1
  115. msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes gzip=$INDEX (update unchanged with pdiffs)"
  116. testrun "$INDCOMP"
  117. testsuccess aptget update -o Acquire::Pdiffs=0
  118. msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes gzip=$INDEX (update unchanged without pdiffs)"
  119. testrun "$INDCOMP"
  120. fi
  121. rm rootdir/etc/apt/apt.conf.d/02compressindex
  122. done
  123. }
  124. testsuccess aptget update
  125. GOODSHOW="$(aptcache show testpkg)
  126. "
  127. test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
  128. testsuccessequal "$GOODSHOW" aptcache show testpkg
  129. GOODSHOWSRC="$(aptcache showsrc testpkg)
  130. "
  131. 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'
  132. testsuccessequal "$GOODSHOWSRC" aptcache showsrc testpkg
  133. GOODPOLICY="$(aptcache policy testpkg)"
  134. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 file:/' | wc -l) -eq 4 || msgdie 'file policy is broken'
  135. testsuccessequal "$GOODPOLICY" aptcache policy testpkg
  136. for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'file' $COMPRESSOR; done
  137. rewritesourceslist "copy://${TMPWORKINGDIRECTORY}/aptarchive"
  138. rm -rf rootdir/var/lib/apt/lists
  139. testsuccess aptget update
  140. GOODPOLICY="$(aptcache policy testpkg)"
  141. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 copy:/' | wc -l) -eq 4 || msgdie 'copy policy is broken'
  142. testsuccessequal "$GOODPOLICY" aptcache policy testpkg
  143. for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'copy' $COMPRESSOR; done
  144. changetowebserver
  145. rm -rf rootdir/var/lib/apt/lists
  146. testsuccess aptget update
  147. GOODPOLICY="$(aptcache policy testpkg)"
  148. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 http://' | wc -l) -eq 4 || msgdie 'http policy is broken'
  149. testsuccessequal "$GOODPOLICY" aptcache policy testpkg
  150. for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'http' $COMPRESSOR; done
  151. changetohttpswebserver
  152. rm -rf rootdir/var/lib/apt/lists
  153. testsuccess aptget update
  154. GOODPOLICY="$(aptcache policy testpkg)"
  155. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 https://' | wc -l) -eq 4 || msgdie 'https policy is broken'
  156. testsuccessequal "$GOODPOLICY" aptcache policy testpkg
  157. for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'https' $COMPRESSOR; done
  158. changetocdrom 'Debian APT Testdisk 0.8.15'
  159. rm -rf rootdir/var/lib/apt/lists
  160. testsuccess aptcdrom add </dev/null
  161. GOODPOLICY="$(aptcache policy testpkg)"
  162. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 cdrom://' | wc -l) -eq 4 || msgdie 'cdrom policy is broken'
  163. testsuccessequal "$GOODPOLICY" aptcache policy testpkg
  164. for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'cdrom' $COMPRESSOR; done