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.
 
 
 
 
 
 

94 lines
2.5 KiB

  1. #!/bin/sh
  2. set -e
  3. ensure_correct_packages_file() {
  4. testequal "Package: foo
  5. Priority: optional
  6. Section: others
  7. Installed-Size: 29
  8. Maintainer: Joe Sixpack <joe@example.org>
  9. Architecture: i386
  10. Version: 1
  11. Filename: pool/main/foo_1_i386.deb" head -n8 ./aptarchive/dists/test/main/binary-i386/Packages
  12. }
  13. ensure_correct_contents_file() {
  14. testequal "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" cat ./aptarchive/dists/test/Contents-i386
  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. aptftparchive generate ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1 2> stats-out.txt
  60. ensure_correct_packages_file
  61. ensure_correct_contents_file
  62. testequal " Misses in Cache: 2
  63. dists/test/Contents-i386: New 402 B Misses in Cache: 0" grep Misses stats-out.txt
  64. # generate again
  65. aptftparchive generate ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1 2> stats-out.txt
  66. ensure_correct_packages_file
  67. ensure_correct_contents_file
  68. testequal " Misses in Cache: 0
  69. dists/test/Contents-i386: Misses in Cache: 0" grep Misses stats-out.txt
  70. # and again (with removing the Packages file)
  71. rm -f ./aptarchive/dists/test/main/binary-i386/*
  72. rm -f ./aptarchive/dists/test/Contents-i386
  73. aptftparchive generate ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1 2> stats-out.txt
  74. ensure_correct_packages_file
  75. ensure_correct_contents_file
  76. testequal " Misses in Cache: 0
  77. dists/test/Contents-i386: New 402 B Misses in Cache: 0" grep Misses stats-out.txt