You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

132 lines
4.8 KiB

  1. #!/bin/sh
  2. set -e
  3. TESTDIR=$(readlink -f $(dirname $0))
  4. . $TESTDIR/framework
  5. setupenvironment
  6. configarchitecture "i386"
  7. buildsimplenativepackage "testpkg" "i386" "1.0"
  8. setupaptarchive
  9. local GOODSHOW="$(aptcache show testpkg)
  10. "
  11. local GOODPOLICY="$(aptcache policy testpkg)"
  12. local GOODSHOWSRC="$(aptcache showsrc testpkg)
  13. "
  14. test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
  15. testequal "$GOODSHOW" aptcache show testpkg
  16. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 file:/' | wc -l) -eq 4 || msgdie 'policy is broken'
  17. testequal "$GOODPOLICY" aptcache policy testpkg
  18. 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'
  19. testequal "$GOODSHOWSRC" aptcache showsrc testpkg
  20. testrun() {
  21. local F
  22. if [ -e rootdir/var/lib/apt/lists/*localhost*Release ]; then
  23. msgtest "Check if all index files are" "${1:-uncompressed}"
  24. if [ "$1" = "compressed" ]; then
  25. ! test -e rootdir/var/lib/apt/lists/*_Packages || F=1
  26. ! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
  27. test -e rootdir/var/lib/apt/lists/*_Packages.gz || F=1
  28. test -e rootdir/var/lib/apt/lists/*_Sources.gz || F=1
  29. else
  30. test -e rootdir/var/lib/apt/lists/*_Packages || F=1
  31. test -e rootdir/var/lib/apt/lists/*_Sources || F=1
  32. ! test -e rootdir/var/lib/apt/lists/*_Packages.gz || F=1
  33. ! test -e rootdir/var/lib/apt/lists/*_Sources.gz || F=1
  34. fi
  35. if [ -n "$F" ]; then
  36. ls -laR rootdir/var/lib/apt/lists/
  37. msgfail
  38. else
  39. msgpass
  40. fi
  41. msgtest "Check if package is downloadable"
  42. aptget install -d testpkg -qq && msgpass || msgfail
  43. msgtest "\tdeb file is present"; test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb && msgpass || msgfail
  44. aptget clean
  45. msgtest "\tdeb file is gone"; ! test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb && msgpass || msgfail
  46. fi
  47. rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
  48. testequal "$GOODSHOW" aptcache show testpkg
  49. testequal "$GOODSHOW" aptcache show testpkg
  50. rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
  51. testequal "$GOODPOLICY" aptcache policy testpkg
  52. testequal "$GOODPOLICY" aptcache policy testpkg
  53. rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
  54. testequal "$GOODSHOWSRC" aptcache showsrc testpkg
  55. testequal "$GOODSHOWSRC" aptcache showsrc testpkg
  56. aptget clean
  57. msgtest "Check if the source is aptgetable"
  58. aptget source testpkg -qq 2> /dev/null > /dev/null && msgpass || msgfail
  59. msgtest "\tdsc file is present"; test -f testpkg_1.0.dsc && msgpass || msgfail
  60. msgtest "\tdirectory is present"; test -d testpkg-1.0 && msgpass || msgfail
  61. rm -rf testpkg-1.0
  62. }
  63. echo 'Acquire::GzipIndexes "false";' > rootdir/etc/apt/apt.conf.d/02compressindex
  64. msgmsg "File: Test with uncompressed indexes"
  65. testrun
  66. aptget update -qq -o Acquire::Pdiffs=1
  67. msgmsg "File: Test with uncompressed indexes (update unchanged with pdiffs)"
  68. testrun
  69. aptget update -qq -o Acquire::Pdiffs=0
  70. msgmsg "File: Test with uncompressed indexes (update unchanged without pdiffs)"
  71. testrun
  72. rm -rf rootdir/var/lib/apt/lists
  73. echo 'Acquire::CompressionTypes::Order:: "gz";
  74. Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
  75. aptget update -qq
  76. msgmsg "File: Test with compressed indexes"
  77. testrun "compressed"
  78. aptget update -qq -o Acquire::Pdiffs=1
  79. msgmsg "File: Test with compressed indexes (update unchanged with pdiffs)"
  80. testrun "compressed"
  81. aptget update -qq -o Acquire::Pdiffs=0
  82. msgmsg "File: Test with compressed indexes (update unchanged without pdiffs)"
  83. testrun "compressed"
  84. rm rootdir/etc/apt/apt.conf.d/02compressindex
  85. changetowebserver
  86. aptget update -qq
  87. local GOODPOLICY="$(aptcache policy testpkg)"
  88. test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 http://' | wc -l) -eq 4
  89. testequal "$GOODPOLICY" aptcache policy testpkg
  90. msgmsg "HTTP: Test with uncompressed indexes"
  91. testrun
  92. aptget update -qq -o Acquire::Pdiffs=1
  93. msgmsg "HTTP: Test with uncompressed indexes (update unchanged with pdiffs)"
  94. testrun
  95. aptget update -qq -o Acquire::Pdiffs=0
  96. msgmsg "HTTP: Test with uncompressed indexes (update unchanged without pdiffs)"
  97. testrun
  98. rm -rf rootdir/var/lib/apt/lists
  99. echo 'Acquire::CompressionTypes::Order:: "gz";
  100. Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
  101. aptget update -qq
  102. msgmsg "HTTP: Test with compressed indexes"
  103. testrun "compressed"
  104. aptget update -qq -o Acquire::Pdiffs=1
  105. msgmsg "HTTP: Test with compressed indexes (update unchanged with pdiffs)"
  106. testrun "compressed"
  107. aptget update -qq -o Acquire::Pdiffs=0
  108. msgmsg "HTTP: Test with compressed indexes (update unchanged without pdiffs)"
  109. testrun "compressed"