test-apt-ftparchive-cachedb 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/sh
  2. set -e
  3. ensure_correct_packages_file() {
  4. testequal "Package: foo
  5. Architecture: i386
  6. Version: 1
  7. Priority: optional
  8. Section: others
  9. Maintainer: Joe Sixpack <joe@example.org>
  10. $(dpkg-deb -I ./aptarchive/pool/main/foo_1_i386.deb | grep 'Installed-Size:' | sed 's#^ ##')
  11. Filename: pool/main/foo_1_i386.deb" head -n8 ./aptarchive/dists/test/main/binary-i386/Packages
  12. }
  13. ensure_correct_contents_file() {
  14. testfileequal ./aptarchive/dists/test/Contents-i386 "usr/bin/foo-i386 others/foo
  15. usr/share/doc/foo/FEATURES others/foo
  16. usr/share/doc/foo/changelog others/foo
  17. usr/share/doc/foo/copyright others/foo"
  18. }
  19. #
  20. # main()
  21. #
  22. TESTDIR="$(readlink -f "$(dirname "$0")")"
  23. . "$TESTDIR/framework"
  24. setupenvironment
  25. configarchitecture 'i386'
  26. mkdir -p aptarchive/dists/test/main/i18n/
  27. mkdir -p aptarchive/dists/test/main/source/
  28. mkdir -p aptarchive/dists/test/main/binary-i386
  29. mkdir -p aptarchive/pool/main
  30. mkdir aptarchive-overrides
  31. mkdir aptarchive-cache
  32. cat > ftparchive.conf <<"EOF"
  33. Dir {
  34. ArchiveDir "./aptarchive";
  35. OverrideDir "./aptarchive-overrides";
  36. CacheDir "./aptarchive-cache";
  37. };
  38. Default {
  39. Packages::Compress ". gzip bzip2";
  40. Contents::Compress ". gzip bzip2";
  41. LongDescription "false";
  42. };
  43. TreeDefault {
  44. BinCacheDB "packages-$(SECTION)-$(ARCH).db";
  45. Directory "pool/$(SECTION)";
  46. SrcDirectory "pool/$(SECTION)";
  47. Packages "$(DIST)/$(SECTION)/binary-$(ARCH)/Packages";
  48. Contents "$(DIST)/Contents-$(ARCH)";
  49. };
  50. Tree "dists/test" {
  51. Sections "main";
  52. Architectures "i386";
  53. };
  54. EOF
  55. # build one pacakge
  56. buildsimplenativepackage 'foo' 'i386' '1' 'test'
  57. mv incoming/* aptarchive/pool/main/
  58. # generate (empty cachedb)
  59. testsuccess aptftparchive generate ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1
  60. cp rootdir/tmp/testsuccess.output stats-out.txt
  61. ensure_correct_packages_file
  62. ensure_correct_contents_file
  63. testsuccessequal ' Misses in Cache: 2
  64. dists/test/Contents-i386: New 402 B Misses in Cache: 0' grep Misses stats-out.txt
  65. # generate again
  66. testsuccess aptftparchive generate ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1
  67. cp rootdir/tmp/testsuccess.output stats-out.txt
  68. ensure_correct_packages_file
  69. ensure_correct_contents_file
  70. testsuccessequal ' Misses in Cache: 0
  71. dists/test/Contents-i386: Misses in Cache: 0' grep Misses stats-out.txt
  72. # and again (with removing the Packages file)
  73. rm -f ./aptarchive/dists/test/main/binary-i386/*
  74. rm -f ./aptarchive/dists/test/Contents-i386
  75. testsuccess aptftparchive generate ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1
  76. cp rootdir/tmp/testsuccess.output stats-out.txt
  77. ensure_correct_packages_file
  78. ensure_correct_contents_file
  79. testsuccessequal ' Misses in Cache: 0
  80. dists/test/Contents-i386: New 402 B Misses in Cache: 0' grep Misses stats-out.txt
  81. # and clean
  82. rm -rf aptarchive/pool/main/*
  83. testsuccessequal "packages-main-i386.db" aptftparchive clean ftparchive.conf
  84. testsuccess aptftparchive clean ftparchive.conf -o Debug::APT::FTPArchive::Clean=1
  85. cp rootdir/tmp/testsuccess.output clean-out.txt
  86. testsuccessequal "0 Number of unique keys in the tree" grep unique clean-out.txt
  87. testsuccessequal "packages-main-i386.db" grep packages-main-i386.db clean-out.txt