Selaa lähdekoodia

Merge remote-tracking branch 'upstream/debian/sid' into bugfix/update-progress-reporting

Michael Vogt 12 vuotta sitten
vanhempi
commit
caa8a9f1e7
73 muutettua tiedostoa jossa 61215 lisäystä ja 60802 poistoa
  1. 2 0
      apt-pkg/acquire-item.cc
  2. 1 1
      apt-pkg/contrib/hashes.cc
  3. 2 0
      apt-pkg/contrib/hashes.h
  4. 1 1
      configure.ac
  5. 0 1
      debian/apt.dirs
  6. 31 0
      debian/changelog
  7. 0 2
      debian/rules
  8. 1 1
      doc/apt-verbatim.ent
  9. 3 3
      doc/po/apt-doc.pot
  10. 11 2
      doc/po/de.po
  11. 2 2
      doc/po/es.po
  12. 2 2
      doc/po/fr.po
  13. 2 2
      doc/po/it.po
  14. 2 2
      doc/po/ja.po
  15. 2 2
      doc/po/pl.po
  16. 2 2
      doc/po/pt.po
  17. 2 2
      doc/po/pt_BR.po
  18. 47 5
      ftparchive/apt-ftparchive.cc
  19. 187 131
      ftparchive/cachedb.cc
  20. 39 4
      ftparchive/cachedb.h
  21. 1 1
      ftparchive/makefile
  22. 47 0
      ftparchive/sources.cc
  23. 32 0
      ftparchive/sources.h
  24. 54 53
      ftparchive/writer.cc
  25. 1 1
      ftparchive/writer.h
  26. 1213 1214
      po/ar.po
  27. 1422 1423
      po/ast.po
  28. 1426 1427
      po/bg.po
  29. 1139 1140
      po/bs.po
  30. 1420 1421
      po/ca.po
  31. 1425 1426
      po/cs.po
  32. 1435 1436
      po/cy.po
  33. 1427 1428
      po/da.po
  34. 1459 1460
      po/de.po
  35. 1414 1415
      po/dz.po
  36. 1427 1428
      po/el.po
  37. 1432 1433
      po/es.po
  38. 1401 1402
      po/eu.po
  39. 1404 1405
      po/fi.po
  40. 1433 1434
      po/fr.po
  41. 1423 1424
      po/gl.po
  42. 1420 1421
      po/hu.po
  43. 1447 1448
      po/it.po
  44. 1424 1425
      po/ja.po
  45. 1401 1402
      po/km.po
  46. 1428 1429
      po/ko.po
  47. 1211 1212
      po/ku.po
  48. 1359 1360
      po/lt.po
  49. 1424 1425
      po/mr.po
  50. 1416 1417
      po/nb.po
  51. 1407 1408
      po/ne.po
  52. 1459 1460
      po/nl.po
  53. 1418 1419
      po/nn.po
  54. 1429 1430
      po/pl.po
  55. 1424 1425
      po/pt.po
  56. 1427 1428
      po/pt_BR.po
  57. 1429 1430
      po/ro.po
  58. 1430 1431
      po/ru.po
  59. 1425 1426
      po/sk.po
  60. 1407 1408
      po/sl.po
  61. 1427 1428
      po/sv.po
  62. 1404 1405
      po/th.po
  63. 1425 1426
      po/tl.po
  64. 1424 1425
      po/tr.po
  65. 1431 1432
      po/uk.po
  66. 1429 1430
      po/vi.po
  67. 1417 1418
      po/zh_CN.po
  68. 1400 1401
      po/zh_TW.po
  69. 0 95
      share/bash-completions/apt
  70. 4 1
      test/integration/framework
  71. 2 1
      test/integration/run-tests
  72. 100 0
      test/integration/test-apt-ftparchive-cachedb
  73. 193 0
      test/integration/test-apt-ftparchive-src-cachedb

+ 2 - 0
apt-pkg/acquire-item.cc

@@ -936,6 +936,8 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
    }
    }
    CompressionExtension = comprExt;
    CompressionExtension = comprExt;
 
 
+   Verify = true;
+
    Init(URI, URIDesc, ShortDesc);
    Init(URI, URIDesc, ShortDesc);
 }
 }
 pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,
 pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,

+ 1 - 1
apt-pkg/contrib/hashes.cc

@@ -133,7 +133,7 @@ bool Hashes::AddFD(int const Fd,unsigned long long Size, bool const addMD5,
 		   bool const addSHA1, bool const addSHA256, bool const addSHA512)
 		   bool const addSHA1, bool const addSHA256, bool const addSHA512)
 {
 {
    unsigned char Buf[64*64];
    unsigned char Buf[64*64];
-   bool const ToEOF = (Size == 0);
+   bool const ToEOF = (Size == UntilEOF);
    while (Size != 0 || ToEOF)
    while (Size != 0 || ToEOF)
    {
    {
       unsigned long long n = sizeof(Buf);
       unsigned long long n = sizeof(Buf);

+ 2 - 0
apt-pkg/contrib/hashes.h

@@ -78,6 +78,8 @@ class Hashes
    SHA256Summation SHA256;
    SHA256Summation SHA256;
    SHA512Summation SHA512;
    SHA512Summation SHA512;
    
    
+   static const int UntilEOF = 0;
+
    inline bool Add(const unsigned char *Data,unsigned long long Size)
    inline bool Add(const unsigned char *Data,unsigned long long Size)
    {
    {
       return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size) && SHA512.Add(Data,Size);
       return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size) && SHA512.Add(Data,Size);

+ 1 - 1
configure.ac

@@ -18,7 +18,7 @@ AC_CONFIG_AUX_DIR(buildlib)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 
 
 PACKAGE="apt"
 PACKAGE="apt"
-PACKAGE_VERSION="1.0.2"
+PACKAGE_VERSION="1.0.3"
 PACKAGE_MAIL="APT Development Team <deity@lists.debian.org>"
 PACKAGE_MAIL="APT Development Team <deity@lists.debian.org>"
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_DEFINE_UNQUOTED(PACKAGE_VERSION,"$PACKAGE_VERSION")
 AC_DEFINE_UNQUOTED(PACKAGE_VERSION,"$PACKAGE_VERSION")

+ 0 - 1
debian/apt.dirs

@@ -15,4 +15,3 @@ var/lib/apt/mirrors/partial
 var/lib/apt/periodic
 var/lib/apt/periodic
 var/log/apt
 var/log/apt
 usr/share/bug/apt
 usr/share/bug/apt
-usr/share/bash-completion/completions/

+ 31 - 0
debian/changelog

@@ -1,3 +1,34 @@
+apt (1.0.3) unstable; urgency=medium
+
+  [ Michael Vogt ]
+  * reduce delta to ubuntu
+  * provide support for vendor specific config files
+  * debian/apt-doc.docs: remove README.MultiArch
+  * Fix missing ScreenWidth check in apt.cc
+  * Only do openpty() if both stdin/stdout are terminals (Closes: 746434)
+
+  [ David Kalnischkies ]
+  * add a README for vendor information
+  * remove outdated README.MultiArch
+  * build http request in a stringstream
+  * enforce LFS for partial files in https range requests
+  * handle pkgnames shorter than modifiers (Closes: 744940)
+  * allow vendors to install configuration files
+
+  [ John Ogness ]
+  * properly undo CD-ROM mount in all error cases
+
+  [ Mahyuddin Ramli ]
+  * add vendor information for BlankOn (Closes: 743595)
+
+  [ Adam Conrad ]
+  * fix FileFd::Size bitswap on big-endian architectures (Closes: 745866)
+
+  [ Trần Ngọc Quân ]
+  * l10n: vi.po: Update one new string
+
+ -- Michael Vogt <mvo@debian.org>  Mon, 05 May 2014 14:03:15 +0200
+
 apt (1.0.2) unstable; urgency=medium
 apt (1.0.2) unstable; urgency=medium
 
 
   [ Michael Vogt ]
   [ Michael Vogt ]

+ 0 - 2
debian/rules

@@ -189,8 +189,6 @@ apt: build-binary build-manpages debian/apt.install
 	cp debian/apt.conf.autoremove debian/$@/etc/apt/apt.conf.d/01autoremove
 	cp debian/apt.conf.autoremove debian/$@/etc/apt/apt.conf.d/01autoremove
 	cp debian/apt.auto-removal.sh debian/$@/etc/kernel/postinst.d/apt-auto-removal
 	cp debian/apt.auto-removal.sh debian/$@/etc/kernel/postinst.d/apt-auto-removal
 	chmod 755 debian/$@/etc/kernel/postinst.d/apt-auto-removal
 	chmod 755 debian/$@/etc/kernel/postinst.d/apt-auto-removal
-	# install bash completion
-	cp share/bash-completions/* debian/$@/usr/share/bash-completion/completions/
 	# install vendor specific apt confs
 	# install vendor specific apt confs
 	find -L vendor/current -name 'apt.conf-*' | while read conf; do cp "$${conf}" "debian/$@/etc/apt/apt.conf.d/$${conf#*-}"; done
 	find -L vendor/current -name 'apt.conf-*' | while read conf; do cp "$${conf}" "debian/$@/etc/apt/apt.conf.d/$${conf#*-}"; done
 
 

+ 1 - 1
doc/apt-verbatim.ent

@@ -225,7 +225,7 @@
 ">
 ">
 
 
 <!-- this will be updated by 'prepare-release' -->
 <!-- this will be updated by 'prepare-release' -->
-<!ENTITY apt-product-version "1.0.2">
+<!ENTITY apt-product-version "1.0.3">
 
 
 <!-- (Code)names for various things used all over the place -->
 <!-- (Code)names for various things used all over the place -->
 <!ENTITY oldstable-codename "squeeze">
 <!ENTITY oldstable-codename "squeeze">

+ 3 - 3
doc/po/apt-doc.pot

@@ -6,9 +6,9 @@
 #, fuzzy
 #, fuzzy
 msgid ""
 msgid ""
 msgstr ""
 msgstr ""
-"Project-Id-Version: apt-doc 1.0.1\n"
+"Project-Id-Version: apt-doc 1.0.3\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
-"POT-Creation-Date: 2014-04-25 13:17+0200\n"
+"POT-Creation-Date: 2014-05-05 16:26+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -6242,7 +6242,7 @@ msgstr ""
 #: guide.sgml:163
 #: guide.sgml:163
 msgid ""
 msgid ""
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
-"its man page, <manref name=\"apt-get\" section=\"8\">. The most useful "
+"its man page, <manref section=\"8\" name=\"apt-get\">. The most useful "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "system has to download a large number of package it would be undesired to "
 "system has to download a large number of package it would be undesired to "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "

+ 11 - 2
doc/po/de.po

@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 msgstr ""
 "Project-Id-Version: apt-doc 0.9.16\n"
 "Project-Id-Version: apt-doc 0.9.16\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
-"POT-Creation-Date: 2014-04-25 13:17+0200\n"
+"POT-Creation-Date: 2014-05-05 16:26+0200\n"
 "PO-Revision-Date: 2014-04-01 14:00+0200\n"
 "PO-Revision-Date: 2014-04-01 14:00+0200\n"
 "Last-Translator: Chris Leick <c.leick@vollbio.de>\n"
 "Last-Translator: Chris Leick <c.leick@vollbio.de>\n"
 "Language-Team: German <debian-l10n-german@lists.debian.org>\n"
 "Language-Team: German <debian-l10n-german@lists.debian.org>\n"
@@ -8836,9 +8836,18 @@ msgstr ""
 
 
 #. type: <p></p>
 #. type: <p></p>
 #: guide.sgml:163
 #: guide.sgml:163
+#, fuzzy
+#| msgid ""
+#| "<prgn>apt-get</prgn> has several command line options that are detailed "
+#| "in its man page, <manref name=\"apt-get\" section=\"8\">. The most useful "
+#| "option is <tt>-d</tt> which does not install the fetched files. If the "
+#| "system has to download a large number of package it would be undesired to "
+#| "start installing them in case something goes wrong. When <tt>-d</tt> is "
+#| "used the downloaded archives can be installed by simply running the "
+#| "command that caused them to be downloaded again without <tt>-d</tt>."
 msgid ""
 msgid ""
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
-"its man page, <manref name=\"apt-get\" section=\"8\">. The most useful "
+"its man page, <manref section=\"8\" name=\"apt-get\">. The most useful "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "system has to download a large number of package it would be undesired to "
 "system has to download a large number of package it would be undesired to "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "

+ 2 - 2
doc/po/es.po

@@ -38,7 +38,7 @@ msgid ""
 msgstr ""
 msgstr ""
 "Project-Id-Version: apt 0.9.7.1\n"
 "Project-Id-Version: apt 0.9.7.1\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
-"POT-Creation-Date: 2014-04-25 13:17+0200\n"
+"POT-Creation-Date: 2014-05-05 16:26+0200\n"
 "PO-Revision-Date: 2014-04-01 14:00+0200\n"
 "PO-Revision-Date: 2014-04-01 14:00+0200\n"
 "Last-Translator: Omar Campagne <ocampagne@gmail.com>\n"
 "Last-Translator: Omar Campagne <ocampagne@gmail.com>\n"
 "Language-Team: Debian l10n Spanish <debian-l10n-spanish@lists.debian.org>\n"
 "Language-Team: Debian l10n Spanish <debian-l10n-spanish@lists.debian.org>\n"
@@ -8897,7 +8897,7 @@ msgstr ""
 #| "command that caused them to be downloaded again without <tt>-d</tt>."
 #| "command that caused them to be downloaded again without <tt>-d</tt>."
 msgid ""
 msgid ""
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
-"its man page, <manref name=\"apt-get\" section=\"8\">. The most useful "
+"its man page, <manref section=\"8\" name=\"apt-get\">. The most useful "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "system has to download a large number of package it would be undesired to "
 "system has to download a large number of package it would be undesired to "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "

+ 2 - 2
doc/po/fr.po

@@ -10,7 +10,7 @@ msgid ""
 msgstr ""
 msgstr ""
 "Project-Id-Version: \n"
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
-"POT-Creation-Date: 2014-04-25 13:17+0200\n"
+"POT-Creation-Date: 2014-05-05 16:26+0200\n"
 "PO-Revision-Date: 2014-04-01 14:00+0200\n"
 "PO-Revision-Date: 2014-04-01 14:00+0200\n"
 "Last-Translator: Christian Perrier <bubulle@debian.org>\n"
 "Last-Translator: Christian Perrier <bubulle@debian.org>\n"
 "Language-Team: French <debian-l10n-french@lists.debian.org>\n"
 "Language-Team: French <debian-l10n-french@lists.debian.org>\n"
@@ -8857,7 +8857,7 @@ msgstr ""
 #| "command that caused them to be downloaded again without <tt>-d</tt>."
 #| "command that caused them to be downloaded again without <tt>-d</tt>."
 msgid ""
 msgid ""
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
-"its man page, <manref name=\"apt-get\" section=\"8\">. The most useful "
+"its man page, <manref section=\"8\" name=\"apt-get\">. The most useful "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "system has to download a large number of package it would be undesired to "
 "system has to download a large number of package it would be undesired to "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "

+ 2 - 2
doc/po/it.po

@@ -10,7 +10,7 @@ msgid ""
 msgstr ""
 msgstr ""
 "Project-Id-Version: \n"
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
-"POT-Creation-Date: 2014-04-25 13:17+0200\n"
+"POT-Creation-Date: 2014-05-05 16:26+0200\n"
 "PO-Revision-Date: 2014-04-01 14:00+0200\n"
 "PO-Revision-Date: 2014-04-01 14:00+0200\n"
 "Last-Translator: Beatrice Torracca <beatricet@libero.it>\n"
 "Last-Translator: Beatrice Torracca <beatricet@libero.it>\n"
 "Language-Team: Italian <debian-l10n-italian@lists.debian.org>\n"
 "Language-Team: Italian <debian-l10n-italian@lists.debian.org>\n"
@@ -8817,7 +8817,7 @@ msgstr ""
 #| "command that caused them to be downloaded again without <tt>-d</tt>."
 #| "command that caused them to be downloaded again without <tt>-d</tt>."
 msgid ""
 msgid ""
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
-"its man page, <manref name=\"apt-get\" section=\"8\">. The most useful "
+"its man page, <manref section=\"8\" name=\"apt-get\">. The most useful "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "system has to download a large number of package it would be undesired to "
 "system has to download a large number of package it would be undesired to "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "

+ 2 - 2
doc/po/ja.po

@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 msgstr ""
 "Project-Id-Version: apt 0.7.25.3\n"
 "Project-Id-Version: apt 0.7.25.3\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
-"POT-Creation-Date: 2014-04-25 13:17+0200\n"
+"POT-Creation-Date: 2014-05-05 16:26+0200\n"
 "PO-Revision-Date: 2014-04-01 14:00+0200\n"
 "PO-Revision-Date: 2014-04-01 14:00+0200\n"
 "Last-Translator: KURASAWA Nozomu <nabetaro@debian.or.jp>\n"
 "Last-Translator: KURASAWA Nozomu <nabetaro@debian.or.jp>\n"
 "Language-Team: Debian Japanese List <debian-japanese@lists.debian.org>\n"
 "Language-Team: Debian Japanese List <debian-japanese@lists.debian.org>\n"
@@ -8440,7 +8440,7 @@ msgstr ""
 #: guide.sgml:163
 #: guide.sgml:163
 msgid ""
 msgid ""
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
-"its man page, <manref name=\"apt-get\" section=\"8\">. The most useful "
+"its man page, <manref section=\"8\" name=\"apt-get\">. The most useful "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "system has to download a large number of package it would be undesired to "
 "system has to download a large number of package it would be undesired to "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "

+ 2 - 2
doc/po/pl.po

@@ -11,7 +11,7 @@ msgid ""
 msgstr ""
 msgstr ""
 "Project-Id-Version: apt 0.9.7.3\n"
 "Project-Id-Version: apt 0.9.7.3\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
-"POT-Creation-Date: 2014-04-25 13:17+0200\n"
+"POT-Creation-Date: 2014-05-05 16:26+0200\n"
 "PO-Revision-Date: 2014-04-01 13:59+0200\n"
 "PO-Revision-Date: 2014-04-01 13:59+0200\n"
 "Last-Translator: Robert Luberda <robert@debian.org>\n"
 "Last-Translator: Robert Luberda <robert@debian.org>\n"
 "Language-Team: Polish <manpages-pl-list@lists.sourceforge.net>\n"
 "Language-Team: Polish <manpages-pl-list@lists.sourceforge.net>\n"
@@ -8097,7 +8097,7 @@ msgstr ""
 #| "command that caused them to be downloaded again without <tt>-d</tt>."
 #| "command that caused them to be downloaded again without <tt>-d</tt>."
 msgid ""
 msgid ""
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
-"its man page, <manref name=\"apt-get\" section=\"8\">. The most useful "
+"its man page, <manref section=\"8\" name=\"apt-get\">. The most useful "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "system has to download a large number of package it would be undesired to "
 "system has to download a large number of package it would be undesired to "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "

+ 2 - 2
doc/po/pt.po

@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 msgstr ""
 "Project-Id-Version: apt 0.9.7.1\n"
 "Project-Id-Version: apt 0.9.7.1\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
-"POT-Creation-Date: 2014-04-25 13:17+0200\n"
+"POT-Creation-Date: 2014-05-05 16:26+0200\n"
 "PO-Revision-Date: 2014-04-01 13:59+0200\n"
 "PO-Revision-Date: 2014-04-01 13:59+0200\n"
 "Last-Translator: Américo Monteiro <a_monteiro@netcabo.pt>\n"
 "Last-Translator: Américo Monteiro <a_monteiro@netcabo.pt>\n"
 "Language-Team: Portuguese <l10n@debianpt.org>\n"
 "Language-Team: Portuguese <l10n@debianpt.org>\n"
@@ -8806,7 +8806,7 @@ msgstr ""
 #| "command that caused them to be downloaded again without <tt>-d</tt>."
 #| "command that caused them to be downloaded again without <tt>-d</tt>."
 msgid ""
 msgid ""
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
-"its man page, <manref name=\"apt-get\" section=\"8\">. The most useful "
+"its man page, <manref section=\"8\" name=\"apt-get\">. The most useful "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "system has to download a large number of package it would be undesired to "
 "system has to download a large number of package it would be undesired to "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "

+ 2 - 2
doc/po/pt_BR.po

@@ -10,7 +10,7 @@ msgid ""
 msgstr ""
 msgstr ""
 "Project-Id-Version: apt\n"
 "Project-Id-Version: apt\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
 "Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
-"POT-Creation-Date: 2014-04-25 13:17+0200\n"
+"POT-Creation-Date: 2014-05-05 16:26+0200\n"
 "PO-Revision-Date: 2004-09-20 17:02+0000\n"
 "PO-Revision-Date: 2004-09-20 17:02+0000\n"
 "Last-Translator: André Luís Lopes <andrelop@debian.org>\n"
 "Last-Translator: André Luís Lopes <andrelop@debian.org>\n"
 "Language-Team: <debian-l10n-portuguese@lists.debian.org>\n"
 "Language-Team: <debian-l10n-portuguese@lists.debian.org>\n"
@@ -6647,7 +6647,7 @@ msgstr ""
 #: guide.sgml:163
 #: guide.sgml:163
 msgid ""
 msgid ""
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
 "<prgn>apt-get</prgn> has several command line options that are detailed in "
-"its man page, <manref name=\"apt-get\" section=\"8\">. The most useful "
+"its man page, <manref section=\"8\" name=\"apt-get\">. The most useful "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "option is <tt>-d</tt> which does not install the fetched files. If the "
 "system has to download a large number of package it would be undesired to "
 "system has to download a large number of package it would be undesired to "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "
 "start installing them in case something goes wrong. When <tt>-d</tt> is used "

+ 47 - 5
ftparchive/apt-ftparchive.cc

@@ -62,6 +62,7 @@ struct PackageMap
    // Stuff for the Package File
    // Stuff for the Package File
    string PkgFile;
    string PkgFile;
    string BinCacheDB;
    string BinCacheDB;
+   string SrcCacheDB;
    string BinOverride;
    string BinOverride;
    string ExtraOverride;
    string ExtraOverride;
 
 
@@ -106,6 +107,12 @@ struct PackageMap
       inline bool operator() (const PackageMap &x,const PackageMap &y)
       inline bool operator() (const PackageMap &x,const PackageMap &y)
       {return x.BinCacheDB < y.BinCacheDB;};
       {return x.BinCacheDB < y.BinCacheDB;};
    };  
    };  
+
+   struct SrcDBCompare : public binary_function<PackageMap,PackageMap,bool>
+   {
+      inline bool operator() (const PackageMap &x,const PackageMap &y)
+      {return x.SrcCacheDB < y.SrcCacheDB;};
+   };
    
    
    void GetGeneral(Configuration &Setup,Configuration &Block);
    void GetGeneral(Configuration &Setup,Configuration &Block);
    bool GenPackages(Configuration &Setup,struct CacheDB::Stats &Stats);
    bool GenPackages(Configuration &Setup,struct CacheDB::Stats &Stats);
@@ -232,11 +239,14 @@ bool PackageMap::GenPackages(Configuration &Setup,struct CacheDB::Stats &Stats)
    gettimeofday(&NewTime,0);
    gettimeofday(&NewTime,0);
    double Delta = NewTime.tv_sec - StartTime.tv_sec + 
    double Delta = NewTime.tv_sec - StartTime.tv_sec + 
                   (NewTime.tv_usec - StartTime.tv_usec)/1000000.0;
                   (NewTime.tv_usec - StartTime.tv_usec)/1000000.0;
-   
+
    c0out << Packages.Stats.Packages << " files " <<
    c0out << Packages.Stats.Packages << " files " <<
 /*      SizeToStr(Packages.Stats.MD5Bytes) << "B/" << */
 /*      SizeToStr(Packages.Stats.MD5Bytes) << "B/" << */
       SizeToStr(Packages.Stats.Bytes) << "B " <<
       SizeToStr(Packages.Stats.Bytes) << "B " <<
       TimeToStr((long)Delta) << endl;
       TimeToStr((long)Delta) << endl;
+
+   if(_config->FindB("APT::FTPArchive::ShowCacheMisses", false) == true)
+     c0out << " Misses in Cache: " << Packages.Stats.Misses<< endl;
    
    
    Stats.Add(Packages.Stats);
    Stats.Add(Packages.Stats);
    Stats.DeLinkBytes = Packages.Stats.DeLinkBytes;
    Stats.DeLinkBytes = Packages.Stats.DeLinkBytes;
@@ -263,7 +273,7 @@ bool PackageMap::GenSources(Configuration &Setup,struct CacheDB::Stats &Stats)
    SrcDone = true;
    SrcDone = true;
    
    
    // Create a package writer object.
    // Create a package writer object.
-   SourcesWriter Sources(_config->Find("APT::FTPArchive::DB"),
+   SourcesWriter Sources(flCombine(CacheDir, SrcCacheDB),
 			 flCombine(OverrideDir,BinOverride),
 			 flCombine(OverrideDir,BinOverride),
 			 flCombine(OverrideDir,SrcOverride),
 			 flCombine(OverrideDir,SrcOverride),
 			 flCombine(OverrideDir,SrcExtraOverride));
 			 flCombine(OverrideDir,SrcExtraOverride));
@@ -323,6 +333,9 @@ bool PackageMap::GenSources(Configuration &Setup,struct CacheDB::Stats &Stats)
    c0out << Sources.Stats.Packages << " pkgs in " <<
    c0out << Sources.Stats.Packages << " pkgs in " <<
       TimeToStr((long)Delta) << endl;
       TimeToStr((long)Delta) << endl;
 
 
+   if(_config->FindB("APT::FTPArchive::ShowCacheMisses", false) == true)
+     c0out << " Misses in Cache: " << Sources.Stats.Misses << endl;
+
    Stats.Add(Sources.Stats);
    Stats.Add(Sources.Stats);
    Stats.DeLinkBytes = Sources.Stats.DeLinkBytes;
    Stats.DeLinkBytes = Sources.Stats.DeLinkBytes;
    
    
@@ -435,6 +448,9 @@ bool PackageMap::GenContents(Configuration &Setup,
    double Delta = NewTime.tv_sec - StartTime.tv_sec + 
    double Delta = NewTime.tv_sec - StartTime.tv_sec + 
                   (NewTime.tv_usec - StartTime.tv_usec)/1000000.0;
                   (NewTime.tv_usec - StartTime.tv_usec)/1000000.0;
    
    
+   if(_config->FindB("APT::FTPArchive::ShowCacheMisses", false) == true)
+     c0out << " Misses in Cache: " << Contents.Stats.Misses<< endl;
+
    c0out << Contents.Stats.Packages << " files " <<
    c0out << Contents.Stats.Packages << " files " <<
       SizeToStr(Contents.Stats.Bytes) << "B " <<
       SizeToStr(Contents.Stats.Bytes) << "B " <<
       TimeToStr((long)Delta) << endl;
       TimeToStr((long)Delta) << endl;
@@ -465,6 +481,8 @@ static void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
    string DContentsH = Setup.Find("TreeDefault::Contents::Header","");
    string DContentsH = Setup.Find("TreeDefault::Contents::Header","");
    string DBCache = Setup.Find("TreeDefault::BinCacheDB",
    string DBCache = Setup.Find("TreeDefault::BinCacheDB",
 			       "packages-$(ARCH).db");
 			       "packages-$(ARCH).db");
+   string SrcDBCache = Setup.Find("TreeDefault::SrcCacheDB",
+			       "sources-$(SECTION).db");
    string DSources = Setup.Find("TreeDefault::Sources",
    string DSources = Setup.Find("TreeDefault::Sources",
 				"$(DIST)/$(SECTION)/source/Sources");
 				"$(DIST)/$(SECTION)/source/Sources");
    string DFLFile = Setup.Find("TreeDefault::FileList", "");
    string DFLFile = Setup.Find("TreeDefault::FileList", "");
@@ -524,6 +542,7 @@ static void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
 	       Itm.Tag = SubstVar("$(DIST)/$(SECTION)/source",Vars);
 	       Itm.Tag = SubstVar("$(DIST)/$(SECTION)/source",Vars);
 	       Itm.FLFile = SubstVar(Block.Find("SourceFileList",DSFLFile.c_str()),Vars);
 	       Itm.FLFile = SubstVar(Block.Find("SourceFileList",DSFLFile.c_str()),Vars);
 	       Itm.SrcExtraOverride = SubstVar(Block.Find("SrcExtraOverride"),Vars);
 	       Itm.SrcExtraOverride = SubstVar(Block.Find("SrcExtraOverride"),Vars);
+	       Itm.SrcCacheDB = SubstVar(Block.Find("SrcCacheDB",SrcDBCache.c_str()),Vars);
 	    }
 	    }
 	    else
 	    else
 	    {
 	    {
@@ -573,6 +592,7 @@ static void LoadBinDir(vector<PackageMap> &PkgList,Configuration &Setup)
       Itm.PkgFile = Block.Find("Packages");
       Itm.PkgFile = Block.Find("Packages");
       Itm.SrcFile = Block.Find("Sources");
       Itm.SrcFile = Block.Find("Sources");
       Itm.BinCacheDB = Block.Find("BinCacheDB");
       Itm.BinCacheDB = Block.Find("BinCacheDB");
+      Itm.SrcCacheDB = Block.Find("SrcCacheDB");
       Itm.BinOverride = Block.Find("BinOverride");
       Itm.BinOverride = Block.Find("BinOverride");
       Itm.ExtraOverride = Block.Find("ExtraOverride");
       Itm.ExtraOverride = Block.Find("ExtraOverride");
       Itm.SrcExtraOverride = Block.Find("SrcExtraOverride");
       Itm.SrcExtraOverride = Block.Find("SrcExtraOverride");
@@ -670,6 +690,10 @@ static bool SimpleGenPackages(CommandLine &CmdL)
    if (Packages.RecursiveScan(CmdL.FileList[1]) == false)
    if (Packages.RecursiveScan(CmdL.FileList[1]) == false)
       return false;
       return false;
 
 
+   // Give some stats if asked for
+   if(_config->FindB("APT::FTPArchive::ShowCacheMisses", false) == true)
+     c0out << " Misses in Cache: " << Packages.Stats.Misses<< endl;
+
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -726,6 +750,10 @@ static bool SimpleGenSources(CommandLine &CmdL)
    if (Sources.RecursiveScan(CmdL.FileList[1]) == false)
    if (Sources.RecursiveScan(CmdL.FileList[1]) == false)
       return false;
       return false;
 
 
+   // Give some stats if asked for
+   if(_config->FindB("APT::FTPArchive::ShowCacheMisses", false) == true)
+     c0out << " Misses in Cache: " << Sources.Stats.Misses<< endl;
+
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -777,6 +805,7 @@ static bool Generate(CommandLine &CmdL)
 
 
    // Sort by cache DB to improve IO locality.
    // Sort by cache DB to improve IO locality.
    stable_sort(PkgList.begin(),PkgList.end(),PackageMap::DBCompare());
    stable_sort(PkgList.begin(),PkgList.end(),PackageMap::DBCompare());
+   stable_sort(PkgList.begin(),PkgList.end(),PackageMap::SrcDBCompare());
 		
 		
    // Generate packages
    // Generate packages
    if (CmdL.FileSize() <= 2)
    if (CmdL.FileSize() <= 2)
@@ -936,20 +965,33 @@ static bool Clean(CommandLine &CmdL)
 
 
    // Sort by cache DB to improve IO locality.
    // Sort by cache DB to improve IO locality.
    stable_sort(PkgList.begin(),PkgList.end(),PackageMap::DBCompare());
    stable_sort(PkgList.begin(),PkgList.end(),PackageMap::DBCompare());
+   stable_sort(PkgList.begin(),PkgList.end(),PackageMap::SrcDBCompare());
 
 
    string CacheDir = Setup.FindDir("Dir::CacheDir");
    string CacheDir = Setup.FindDir("Dir::CacheDir");
    
    
    for (vector<PackageMap>::iterator I = PkgList.begin(); I != PkgList.end(); )
    for (vector<PackageMap>::iterator I = PkgList.begin(); I != PkgList.end(); )
    {
    {
-      c0out << I->BinCacheDB << endl;
+      if(I->BinCacheDB != "")
+         c0out << I->BinCacheDB << endl;
+      if(I->SrcCacheDB != "")
+         c0out << I->SrcCacheDB << endl;
       CacheDB DB(flCombine(CacheDir,I->BinCacheDB));
       CacheDB DB(flCombine(CacheDir,I->BinCacheDB));
+      CacheDB DB_SRC(flCombine(CacheDir,I->SrcCacheDB));
       if (DB.Clean() == false)
       if (DB.Clean() == false)
 	 _error->DumpErrors();
 	 _error->DumpErrors();
+      if (DB_SRC.Clean() == false)
+	 _error->DumpErrors();
       
       
       string CacheDB = I->BinCacheDB;
       string CacheDB = I->BinCacheDB;
-      for (; I != PkgList.end() && I->BinCacheDB == CacheDB; ++I);
+      string SrcCacheDB = I->SrcCacheDB;
+      while(I != PkgList.end() && 
+            I->BinCacheDB == CacheDB && 
+            I->SrcCacheDB == SrcCacheDB)
+         ++I;
+
    }
    }
-   
+
+  
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 187 - 131
ftparchive/cachedb.cc

@@ -20,6 +20,7 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/debfile.h>
 #include <apt-pkg/debfile.h>
+#include <apt-pkg/gpgv.h>
 
 
 #include <netinet/in.h>       // htonl, etc
 #include <netinet/in.h>       // htonl, etc
 #include <ctype.h>
 #include <ctype.h>
@@ -96,14 +97,64 @@ bool CacheDB::ReadyDB(std::string const &DB)
 /* */
 /* */
 bool CacheDB::OpenFile()
 bool CacheDB::OpenFile()
 {
 {
-	Fd = new FileFd(FileName,FileFd::ReadOnly);
-	if (_error->PendingError() == true)
-	{
-		delete Fd;
-		Fd = NULL;
-		return false;
-	}
-	return true;
+   // its open already
+   if(Fd && Fd->Name() == this->FileName)
+      return true;
+
+   // a different file is open, close it first
+   if(Fd && Fd->Name() != this->FileName)
+      CloseFile();
+
+   // open a new file
+   Fd = new FileFd(FileName,FileFd::ReadOnly);
+   if (_error->PendingError() == true)
+   {
+      CloseFile();
+      return false;
+   }
+   return true;
+}
+									/*}}}*/
+// CacheDB::CloseFile - Close the file					/*{{{*/
+void CacheDB::CloseFile()
+{
+   if(Fd != NULL)
+   {
+      delete Fd;
+      Fd = NULL;
+   }
+}
+									/*}}}*/
+// CacheDB::OpenDebFile - Open a debfile				/*{{{*/
+bool CacheDB::OpenDebFile()
+{
+   // debfile is already open
+   if(DebFile && &DebFile->GetFile() == Fd)
+      return true;
+
+   // a different debfile is open, close it first
+   if(DebFile && &DebFile->GetFile() != Fd)
+      CloseDebFile();
+
+   // first open the fd, then pass it to the debDebFile
+   if(OpenFile() == false)
+      return false;
+   DebFile = new debDebFile(*Fd);
+   if (_error->PendingError() == true)
+      return false;
+   return true;
+}
+									/*}}}*/
+// CacheDB::CloseDebFile - Close a debfile again 			/*{{{*/
+void CacheDB::CloseDebFile()
+{
+   CloseFile();
+
+   if(DebFile != NULL)
+   {
+      delete DebFile;
+      DebFile = NULL;
+   }
 }
 }
 									/*}}}*/
 									/*}}}*/
 // CacheDB::GetFileStat - Get stats from the file 			/*{{{*/
 // CacheDB::GetFileStat - Get stats from the file 			/*{{{*/
@@ -112,29 +163,26 @@ bool CacheDB::OpenFile()
  * to look at the file, also get the mtime from the file. */
  * to look at the file, also get the mtime from the file. */
 bool CacheDB::GetFileStat(bool const &doStat)
 bool CacheDB::GetFileStat(bool const &doStat)
 {
 {
-	if ((CurStat.Flags & FlSize) == FlSize && doStat == false)
-	{
-		/* Already worked out the file size */
-	}
-	else
-	{
-		/* Get it from the file. */
-		if (Fd == NULL && OpenFile() == false)
-		{
-			return false;
-		}
-		// Stat the file
-		struct stat St;
-		if (fstat(Fd->Fd(),&St) != 0)
-		{
-			return _error->Errno("fstat",
-				_("Failed to stat %s"),FileName.c_str());
-		}
-		CurStat.FileSize = St.st_size;
-		CurStat.mtime = htonl(St.st_mtime);
-		CurStat.Flags |= FlSize;
-	}
-	return true;
+   if ((CurStat.Flags & FlSize) == FlSize && doStat == false)
+      return true;
+
+   /* Get it from the file. */
+   if (OpenFile() == false)
+      return false;
+   
+   // Stat the file
+   struct stat St;
+   if (fstat(Fd->Fd(),&St) != 0)
+   {
+      CloseFile();
+      return _error->Errno("fstat",
+                           _("Failed to stat %s"),FileName.c_str());
+   }
+   CurStat.FileSize = St.st_size;
+   CurStat.mtime = htonl(St.st_mtime);
+   CurStat.Flags |= FlSize;
+   
+   return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
 // CacheDB::GetCurStat - Set the CurStat variable.			/*{{{*/
 // CacheDB::GetCurStat - Set the CurStat variable.			/*{{{*/
@@ -145,79 +193,100 @@ bool CacheDB::GetCurStat()
 {
 {
    memset(&CurStat,0,sizeof(CurStat));
    memset(&CurStat,0,sizeof(CurStat));
    
    
-	if (DBLoaded)
-	{
-		/* First see if there is anything about it
-		   in the database */
-
-		/* Get the flags (and mtime) */
-   InitQuery("st");
-   // Ensure alignment of the returned structure
-   Data.data = &CurStat;
-   Data.ulen = sizeof(CurStat);
-   Data.flags = DB_DBT_USERMEM;
-		if (Get() == false)
+   if (DBLoaded)
+   {
+      /* First see if there is anything about it
+         in the database */
+      
+      /* Get the flags (and mtime) */
+      InitQueryStats();
+      // Ensure alignment of the returned structure
+      Data.data = &CurStat;
+      Data.ulen = sizeof(CurStat);
+      Data.flags = DB_DBT_USERMEM;
+      if (Get() == false)
       {
       {
 	 CurStat.Flags = 0;
 	 CurStat.Flags = 0;
       }      
       }      
-		CurStat.Flags = ntohl(CurStat.Flags);
-		CurStat.FileSize = ntohl(CurStat.FileSize);
+      CurStat.Flags = ntohl(CurStat.Flags);
+      CurStat.FileSize = ntohl(CurStat.FileSize);
    }      
    }      
-	return true;
+   return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
 // CacheDB::GetFileInfo - Get all the info about the file		/*{{{*/
 // CacheDB::GetFileInfo - Get all the info about the file		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
-bool CacheDB::GetFileInfo(std::string const &FileName, bool const &DoControl, bool const &DoContents,
-				bool const &GenContentsOnly, bool const &DoMD5, bool const &DoSHA1,
-				bool const &DoSHA256, 	bool const &DoSHA512, 
+bool CacheDB::GetFileInfo(std::string const &FileName, bool const &DoControl, 
+                          bool const &DoContents,
+                          bool const &GenContentsOnly, 
+                          bool const &DoSource,
+                          bool const &DoMD5, bool const &DoSHA1,
+                          bool const &DoSHA256, bool const &DoSHA512, 
                           bool const &checkMtime)
                           bool const &checkMtime)
 {
 {
-	this->FileName = FileName;
+   bool result = true;
+   this->FileName = FileName;
 
 
-	if (GetCurStat() == false)
-   {
-		return false;
-   }   
+   if (GetCurStat() == false)
+      return false;
    OldStat = CurStat;
    OldStat = CurStat;
 
 
-	if (GetFileStat(checkMtime) == false)
-	{
-		delete Fd;
-		Fd = NULL;
-		return false;	
-	}
-
-    /* if mtime changed, update CurStat from disk */
-    if (checkMtime == true && OldStat.mtime != CurStat.mtime)
-        CurStat.Flags = FlSize;
-
-	Stats.Bytes += CurStat.FileSize;
-	Stats.Packages++;
-
-	if ((DoControl && LoadControl() == false)
-		|| (DoContents && LoadContents(GenContentsOnly) == false)
-		|| (DoMD5 && GetMD5(false) == false)
-		|| (DoSHA1 && GetSHA1(false) == false)
-		|| (DoSHA256 && GetSHA256(false) == false)
-		|| (DoSHA512 && GetSHA512(false) == false)
-           )
-	{
-		delete Fd;
-		Fd = NULL;
-		delete DebFile;
-		DebFile = NULL;
-		return false;	
-	}
-
-	delete Fd;
-	Fd = NULL;
-	delete DebFile;
-	DebFile = NULL;
+   if (GetFileStat(checkMtime) == false)
+      return false;	
 
 
-   return true;
+   /* if mtime changed, update CurStat from disk */
+   if (checkMtime == true && OldStat.mtime != CurStat.mtime)
+      CurStat.Flags = FlSize;
+
+   Stats.Bytes += CurStat.FileSize;
+   Stats.Packages++;
+
+   if ((DoControl && LoadControl() == false)
+       || (DoContents && LoadContents(GenContentsOnly) == false)
+       || (DoSource && LoadSource() == false)
+       || (DoMD5 && GetMD5(false) == false)
+       || (DoSHA1 && GetSHA1(false) == false)
+       || (DoSHA256 && GetSHA256(false) == false)
+       || (DoSHA512 && GetSHA512(false) == false) )
+   {
+      result = false;
+   }
+    
+   return result;
 }
 }
 									/*}}}*/
 									/*}}}*/
+
+bool CacheDB::LoadSource()
+{
+   // Try to read the control information out of the DB.
+   if ((CurStat.Flags & FlSource) == FlSource)
+   {
+      // Lookup the control information
+      InitQuerySource();
+      if (Get() == true && Dsc.TakeDsc(Data.data, Data.size) == true)
+      {
+	    return true;
+      }
+      CurStat.Flags &= ~FlSource;
+   }
+   if (OpenFile() == false)
+      return false;
+
+   Stats.Misses++;
+   if (Dsc.Read(FileName) == false)
+      return false;
+
+   if (Dsc.Data == 0)
+      return _error->Error(_("Failed to read .dsc"));
+   
+   // Write back the control information
+   InitQuerySource();
+   if (Put(Dsc.Data, Dsc.Length) == true)
+      CurStat.Flags |= FlSource;
+
+   return true;
+}
+
 // CacheDB::LoadControl - Load Control information			/*{{{*/
 // CacheDB::LoadControl - Load Control information			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
@@ -227,23 +296,14 @@ bool CacheDB::LoadControl()
    if ((CurStat.Flags & FlControl) == FlControl)
    if ((CurStat.Flags & FlControl) == FlControl)
    {
    {
       // Lookup the control information
       // Lookup the control information
-      InitQuery("cl");
+      InitQueryControl();
       if (Get() == true && Control.TakeControl(Data.data,Data.size) == true)
       if (Get() == true && Control.TakeControl(Data.data,Data.size) == true)
 	    return true;
 	    return true;
       CurStat.Flags &= ~FlControl;
       CurStat.Flags &= ~FlControl;
    }
    }
    
    
-   if (Fd == NULL && OpenFile() == false)
-   {
+   if(OpenDebFile() == false)
       return false;
       return false;
-   }
-   // Create a deb instance to read the archive
-   if (DebFile == 0)
-   {
-      DebFile = new debDebFile(*Fd);
-      if (_error->PendingError() == true)
-	 return false;
-   }
    
    
    Stats.Misses++;
    Stats.Misses++;
    if (Control.Read(*DebFile) == false)
    if (Control.Read(*DebFile) == false)
@@ -253,7 +313,7 @@ bool CacheDB::LoadControl()
       return _error->Error(_("Archive has no control record"));
       return _error->Error(_("Archive has no control record"));
    
    
    // Write back the control information
    // Write back the control information
-   InitQuery("cl");
+   InitQueryControl();
    if (Put(Control.Control,Control.Length) == true)
    if (Put(Control.Control,Control.Length) == true)
       CurStat.Flags |= FlControl;
       CurStat.Flags |= FlControl;
    return true;
    return true;
@@ -271,7 +331,7 @@ bool CacheDB::LoadContents(bool const &GenOnly)
 	 return true;
 	 return true;
       
       
       // Lookup the contents information
       // Lookup the contents information
-      InitQuery("cn");
+      InitQueryContent();
       if (Get() == true)
       if (Get() == true)
       {
       {
 	 if (Contents.TakeContents(Data.data,Data.size) == true)
 	 if (Contents.TakeContents(Data.data,Data.size) == true)
@@ -281,23 +341,15 @@ bool CacheDB::LoadContents(bool const &GenOnly)
       CurStat.Flags &= ~FlContents;
       CurStat.Flags &= ~FlContents;
    }
    }
    
    
-   if (Fd == NULL && OpenFile() == false)
-   {
+   if(OpenDebFile() == false)
       return false;
       return false;
-   }
-   // Create a deb instance to read the archive
-   if (DebFile == 0)
-   {
-      DebFile = new debDebFile(*Fd);
-      if (_error->PendingError() == true)
-	 return false;
-   }
 
 
+   Stats.Misses++;
    if (Contents.Read(*DebFile) == false)
    if (Contents.Read(*DebFile) == false)
       return false;	    
       return false;	    
    
    
    // Write back the control information
    // Write back the control information
-   InitQuery("cn");
+   InitQueryContent();
    if (Put(Contents.Data,Contents.CurSize) == true)
    if (Put(Contents.Data,Contents.CurSize) == true)
       CurStat.Flags |= FlContents;
       CurStat.Flags |= FlContents;
    return true;
    return true;
@@ -347,14 +399,13 @@ bool CacheDB::GetMD5(bool const &GenOnly)
       
       
       MD5Res = bytes2hex(CurStat.MD5, sizeof(CurStat.MD5));
       MD5Res = bytes2hex(CurStat.MD5, sizeof(CurStat.MD5));
 	 return true;
 	 return true;
-      }
+   }
    
    
    Stats.MD5Bytes += CurStat.FileSize;
    Stats.MD5Bytes += CurStat.FileSize;
 	 
 	 
-   if (Fd == NULL && OpenFile() == false)
-   {
+   if (OpenFile() == false)
       return false;
       return false;
-   }
+
    MD5Summation MD5;
    MD5Summation MD5;
    if (Fd->Seek(0) == false || MD5.AddFD(*Fd, CurStat.FileSize) == false)
    if (Fd->Seek(0) == false || MD5.AddFD(*Fd, CurStat.FileSize) == false)
       return false;
       return false;
@@ -382,10 +433,9 @@ bool CacheDB::GetSHA1(bool const &GenOnly)
    
    
    Stats.SHA1Bytes += CurStat.FileSize;
    Stats.SHA1Bytes += CurStat.FileSize;
 	 
 	 
-   if (Fd == NULL && OpenFile() == false)
-   {
+   if (OpenFile() == false)
       return false;
       return false;
-   }
+
    SHA1Summation SHA1;
    SHA1Summation SHA1;
    if (Fd->Seek(0) == false || SHA1.AddFD(*Fd, CurStat.FileSize) == false)
    if (Fd->Seek(0) == false || SHA1.AddFD(*Fd, CurStat.FileSize) == false)
       return false;
       return false;
@@ -413,10 +463,9 @@ bool CacheDB::GetSHA256(bool const &GenOnly)
    
    
    Stats.SHA256Bytes += CurStat.FileSize;
    Stats.SHA256Bytes += CurStat.FileSize;
 	 
 	 
-   if (Fd == NULL && OpenFile() == false)
-   {
+   if (OpenFile() == false)
       return false;
       return false;
-   }
+
    SHA256Summation SHA256;
    SHA256Summation SHA256;
    if (Fd->Seek(0) == false || SHA256.AddFD(*Fd, CurStat.FileSize) == false)
    if (Fd->Seek(0) == false || SHA256.AddFD(*Fd, CurStat.FileSize) == false)
       return false;
       return false;
@@ -444,10 +493,9 @@ bool CacheDB::GetSHA512(bool const &GenOnly)
    
    
    Stats.SHA512Bytes += CurStat.FileSize;
    Stats.SHA512Bytes += CurStat.FileSize;
 	 
 	 
-   if (Fd == NULL && OpenFile() == false)
-   {
+   if (OpenFile() == false)
       return false;
       return false;
-   }
+
    SHA512Summation SHA512;
    SHA512Summation SHA512;
    if (Fd->Seek(0) == false || SHA512.AddFD(*Fd, CurStat.FileSize) == false)
    if (Fd->Seek(0) == false || SHA512.AddFD(*Fd, CurStat.FileSize) == false)
       return false;
       return false;
@@ -467,11 +515,11 @@ bool CacheDB::Finish()
    if (CurStat.Flags == OldStat.Flags &&
    if (CurStat.Flags == OldStat.Flags &&
        CurStat.mtime == OldStat.mtime)
        CurStat.mtime == OldStat.mtime)
       return true;
       return true;
-   
+
    // Write the stat information
    // Write the stat information
    CurStat.Flags = htonl(CurStat.Flags);
    CurStat.Flags = htonl(CurStat.Flags);
    CurStat.FileSize = htonl(CurStat.FileSize);
    CurStat.FileSize = htonl(CurStat.FileSize);
-   InitQuery("st");
+   InitQueryStats();
    Put(&CurStat,sizeof(CurStat));
    Put(&CurStat,sizeof(CurStat));
    CurStat.Flags = ntohl(CurStat.Flags);
    CurStat.Flags = ntohl(CurStat.Flags);
    CurStat.FileSize = ntohl(CurStat.FileSize);
    CurStat.FileSize = ntohl(CurStat.FileSize);
@@ -504,16 +552,24 @@ bool CacheDB::Clean()
       {
       {
          if (stringcmp(Colon + 1, (char *)Key.data+Key.size,"st") == 0 ||
          if (stringcmp(Colon + 1, (char *)Key.data+Key.size,"st") == 0 ||
              stringcmp(Colon + 1, (char *)Key.data+Key.size,"cl") == 0 ||
              stringcmp(Colon + 1, (char *)Key.data+Key.size,"cl") == 0 ||
+             stringcmp(Colon + 1, (char *)Key.data+Key.size,"cs") == 0 ||
              stringcmp(Colon + 1, (char *)Key.data+Key.size,"cn") == 0)
              stringcmp(Colon + 1, (char *)Key.data+Key.size,"cn") == 0)
 	 {
 	 {
-            if (FileExists(std::string((const char *)Key.data,Colon)) == true)
-		continue;	     
+            std::string FileName = std::string((const char *)Key.data,Colon);
+            if (FileExists(FileName) == true) {
+		continue;
+            }
 	 }
 	 }
       }
       }
-      
       Cursor->c_del(Cursor,0);
       Cursor->c_del(Cursor,0);
    }
    }
-   Dbp->compact(Dbp, NULL, NULL, NULL, NULL, DB_FREE_SPACE, NULL);
+   int res = Dbp->compact(Dbp, NULL, NULL, NULL, NULL, DB_FREE_SPACE, NULL);
+   if (res < 0)
+      _error->Warning("compact failed with result %i", res);
+
+   if(_config->FindB("Debug::APT::FTPArchive::Clean", false) == true)
+      Dbp->stat_print(Dbp, 0);
+
 
 
    return true;
    return true;
 }
 }

+ 39 - 4
ftparchive/cachedb.h

@@ -22,9 +22,11 @@
 #include <stdio.h>
 #include <stdio.h>
 
 
 #include "contents.h"
 #include "contents.h"
+#include "sources.h"
 
 
 class FileFd;
 class FileFd;
 
 
+
 class CacheDB
 class CacheDB
 {
 {
    protected:
    protected:
@@ -39,7 +41,7 @@ class CacheDB
    std::string DBFile;
    std::string DBFile;
 
 
    // Generate a key for the DB of a given type
    // Generate a key for the DB of a given type
-   inline void InitQuery(const char *Type)
+   void _InitQuery(const char *Type)
    {
    {
       memset(&Key,0,sizeof(Key));
       memset(&Key,0,sizeof(Key));
       memset(&Data,0,sizeof(Data));
       memset(&Data,0,sizeof(Data));
@@ -47,6 +49,19 @@ class CacheDB
       Key.size = snprintf(TmpKey,sizeof(TmpKey),"%s:%s",FileName.c_str(), Type);
       Key.size = snprintf(TmpKey,sizeof(TmpKey),"%s:%s",FileName.c_str(), Type);
    }
    }
    
    
+   void InitQueryStats() {
+      _InitQuery("st");
+   }
+   void InitQuerySource() {
+      _InitQuery("cs");
+   }
+   void InitQueryControl() {
+      _InitQuery("cl");
+   }
+   void InitQueryContent() {
+      _InitQuery("cn");
+   }
+
    inline bool Get() 
    inline bool Get() 
    {
    {
       return Dbp->get(Dbp,0,&Key,&Data,0) == 0;
       return Dbp->get(Dbp,0,&Key,&Data,0) == 0;
@@ -65,10 +80,16 @@ class CacheDB
       return true;
       return true;
    }
    }
    bool OpenFile();
    bool OpenFile();
+   void CloseFile();
+
+   bool OpenDebFile();
+   void CloseDebFile();
+
    bool GetFileStat(bool const &doStat = false);
    bool GetFileStat(bool const &doStat = false);
    bool GetCurStat();
    bool GetCurStat();
    bool LoadControl();
    bool LoadControl();
    bool LoadContents(bool const &GenOnly);
    bool LoadContents(bool const &GenOnly);
+   bool LoadSource();
    bool GetMD5(bool const &GenOnly);
    bool GetMD5(bool const &GenOnly);
    bool GetSHA1(bool const &GenOnly);
    bool GetSHA1(bool const &GenOnly);
    bool GetSHA256(bool const &GenOnly);
    bool GetSHA256(bool const &GenOnly);
@@ -77,7 +98,8 @@ class CacheDB
    // Stat info stored in the DB, Fixed types since it is written to disk.
    // Stat info stored in the DB, Fixed types since it is written to disk.
    enum FlagList {FlControl = (1<<0),FlMD5=(1<<1),FlContents=(1<<2),
    enum FlagList {FlControl = (1<<0),FlMD5=(1<<1),FlContents=(1<<2),
                   FlSize=(1<<3), FlSHA1=(1<<4), FlSHA256=(1<<5), 
                   FlSize=(1<<3), FlSHA1=(1<<4), FlSHA256=(1<<5), 
-                  FlSHA512=(1<<6)};
+                  FlSHA512=(1<<6), FlSource=(1<<7),
+   };
 
 
    struct StatStore
    struct StatStore
    {
    {
@@ -101,6 +123,8 @@ class CacheDB
    // Data collection helpers
    // Data collection helpers
    debDebFile::MemControlExtract Control;
    debDebFile::MemControlExtract Control;
    ContentsExtract Contents;
    ContentsExtract Contents;
+   DscExtract Dsc;
+
    std::string MD5Res;
    std::string MD5Res;
    std::string SHA1Res;
    std::string SHA1Res;
    std::string SHA256Res;
    std::string SHA256Res;
@@ -139,8 +163,19 @@ class CacheDB
    inline unsigned long long GetFileSize(void) {return CurStat.FileSize;}
    inline unsigned long long GetFileSize(void) {return CurStat.FileSize;}
    
    
    bool SetFile(std::string const &FileName,struct stat St,FileFd *Fd);
    bool SetFile(std::string const &FileName,struct stat St,FileFd *Fd);
-   bool GetFileInfo(std::string const &FileName, bool const &DoControl, bool const &DoContents, bool const &GenContentsOnly,
-		    bool const &DoMD5, bool const &DoSHA1, bool const &DoSHA256, bool const &DoSHA512, bool const &checkMtime = false);
+
+   // terrible old overloaded interface
+   bool GetFileInfo(std::string const &FileName, 
+                    bool const &DoControl, 
+                    bool const &DoContents, 
+                    bool const &GenContentsOnly, 
+                    bool const &DoSource,
+		    bool const &DoMD5, 
+                    bool const &DoSHA1, 
+                    bool const &DoSHA256, 
+                    bool const &DoSHA512, 
+                    bool const &checkMtime = false);
+
    bool Finish();   
    bool Finish();   
    
    
    bool Clean();
    bool Clean();

+ 1 - 1
ftparchive/makefile

@@ -12,7 +12,7 @@ PROGRAM=apt-ftparchive
 SLIBS = -lapt-pkg -lapt-inst $(BDBLIB) $(INTLLIBS)
 SLIBS = -lapt-pkg -lapt-inst $(BDBLIB) $(INTLLIBS)
 LIB_MAKES = apt-pkg/makefile apt-inst/makefile
 LIB_MAKES = apt-pkg/makefile apt-inst/makefile
 SOURCE = apt-ftparchive.cc cachedb.cc writer.cc contents.cc override.cc \
 SOURCE = apt-ftparchive.cc cachedb.cc writer.cc contents.cc override.cc \
-         multicompress.cc
+         multicompress.cc sources.cc
 include $(PROGRAM_H)
 include $(PROGRAM_H)
 else
 else
 PROGRAM=apt-ftparchive
 PROGRAM=apt-ftparchive

+ 47 - 0
ftparchive/sources.cc

@@ -0,0 +1,47 @@
+#include <string>
+#include <iostream>
+
+// for memcpy
+#include <cstring>
+
+#include <apt-pkg/error.h>
+#include <apt-pkg/gpgv.h>
+
+#include "sources.h"
+
+bool DscExtract::TakeDsc(const void *newData, unsigned long newSize)
+{
+   if(newSize > maxSize)
+     return _error->Error("DSC data is too large %lu!", newSize);
+
+   if (newSize == 0)
+   {
+      Length = 0;
+      return true;
+   }
+   memcpy(Data, newData, newSize);
+   Length = newSize;
+
+   return true;
+}
+
+bool DscExtract::Read(std::string FileName)
+{
+   FileFd F;
+   if (OpenMaybeClearSignedFile(FileName, F) == false)
+      return false;
+   
+   unsigned long long const FSize = F.FileSize();
+   if(FSize > maxSize)
+     return _error->Error("DSC file '%s' is too large!",FileName.c_str());
+
+   if (F.Read(Data, FSize) == false)
+      return false;
+   Length = FSize;
+
+   IsClearSigned = (FileName != F.Name());
+
+   return true;
+}
+
+

+ 32 - 0
ftparchive/sources.h

@@ -0,0 +1,32 @@
+#ifndef SOURCES_H
+#define SOURCES_H
+
+#include <apt-pkg/tagfile.h>
+
+class DscExtract 
+{
+ public:
+   //FIXME: do we really need to enforce a maximum size of the dsc file?
+   static const int maxSize = 128*1024;
+
+   char *Data;
+   pkgTagSection Section;
+   unsigned long Length;
+   bool IsClearSigned;
+
+   bool TakeDsc(const void *Data, unsigned long Size);
+   bool Read(std::string FileName);
+   
+   DscExtract() : Data(0), Length(0) {
+     Data = new char[maxSize];
+   };
+   ~DscExtract() { 
+      if(Data != NULL) {
+         delete [] Data;
+         Data = NULL;
+      } 
+   };
+};
+
+
+#endif

+ 54 - 53
ftparchive/writer.cc

@@ -385,10 +385,14 @@ bool FTWScanner::SetExts(string const &Vals)
 bool PackagesWriter::DoPackage(string FileName)
 bool PackagesWriter::DoPackage(string FileName)
 {      
 {      
    // Pull all the data we need form the DB
    // Pull all the data we need form the DB
-   if (Db.GetFileInfo(FileName, true, DoContents, true, DoMD5, DoSHA1, DoSHA256, DoSHA512, DoAlwaysStat)
-		  == false)
+   if (Db.GetFileInfo(FileName, 
+                      true,   /* DoControl */
+                      DoContents, 
+                      true,   /* GenContentsOnly */
+                      false,  /* DoSource */
+                      DoMD5, DoSHA1, DoSHA256, DoSHA512, DoAlwaysStat) == false)
    {
    {
-      return false;
+     return false;
    }
    }
 
 
    unsigned long long FileSize = Db.GetFileSize();
    unsigned long long FileSize = Db.GetFileSize();
@@ -614,59 +618,36 @@ SourcesWriter::SourcesWriter(string const &DB, string const &BOverrides,string c
 /* */
 /* */
 bool SourcesWriter::DoPackage(string FileName)
 bool SourcesWriter::DoPackage(string FileName)
 {
 {
-   // Open the archive
-   FileFd F;
-   if (OpenMaybeClearSignedFile(FileName, F) == false)
-      return false;
-
-   unsigned long long const FSize = F.FileSize();
-   //FIXME: do we really need to enforce a maximum size of the dsc file?
-   if (FSize > 128*1024)
-      return _error->Error("DSC file '%s' is too large!",FileName.c_str());
-
-   if (BufSize < FSize + 2)
+   // Pull all the data we need form the DB
+   if (Db.GetFileInfo(FileName,
+                      false,  /* DoControl */
+                      false,  /* DoContents */
+                      false,  /* GenContentsOnly */
+                      true,   /* DoSource */
+                      DoMD5, DoSHA1, DoSHA256, DoSHA512, DoAlwaysStat) == false)
    {
    {
-      BufSize = FSize + 2;
-      Buffer = (char *)realloc(Buffer , BufSize);
-   }
-
-   if (F.Read(Buffer, FSize) == false)
       return false;
       return false;
+   }
 
 
-   // Stat the file for later (F might be clearsigned, so not F.FileSize())
-   struct stat St;
-   if (stat(FileName.c_str(), &St) != 0)
-      return _error->Errno("fstat","Failed to stat %s",FileName.c_str());
+   // we need to perform a "write" here (this is what finish is doing)
+   // because the call to Db.GetFileInfo() in the loop will change
+   // the "db cursor"
+   Db.Finish();
 
 
-   // Hash the file
-   char *Start = Buffer;
-   char *BlkEnd = Buffer + FSize;
-
-   Hashes DscHashes;
-   if (FSize == (unsigned long long) St.st_size)
-   {
-      if (DoMD5 == true)
-	 DscHashes.MD5.Add((unsigned char *)Start,BlkEnd - Start);
-      if (DoSHA1 == true)
-	 DscHashes.SHA1.Add((unsigned char *)Start,BlkEnd - Start);
-      if (DoSHA256 == true)
-	 DscHashes.SHA256.Add((unsigned char *)Start,BlkEnd - Start);
-      if (DoSHA512 == true)
-	 DscHashes.SHA512.Add((unsigned char *)Start,BlkEnd - Start);
-   }
-   else
-   {
-      FileFd DscFile(FileName, FileFd::ReadOnly);
-      DscHashes.AddFD(DscFile, St.st_size, DoMD5, DoSHA1, DoSHA256, DoSHA512);
-   }
+   // read stuff
+   char *Start = Db.Dsc.Data;
+   char *BlkEnd = Db.Dsc.Data + Db.Dsc.Length;
 
 
    // Add extra \n to the end, just in case (as in clearsigned they are missing)
    // Add extra \n to the end, just in case (as in clearsigned they are missing)
    *BlkEnd++ = '\n';
    *BlkEnd++ = '\n';
    *BlkEnd++ = '\n';
    *BlkEnd++ = '\n';
 
 
    pkgTagSection Tags;
    pkgTagSection Tags;
-   if (Tags.Scan(Start,BlkEnd - Start) == false || Tags.Exists("Source") == false)
+   if (Tags.Scan(Start,BlkEnd - Start) == false)
       return _error->Error("Could not find a record in the DSC '%s'",FileName.c_str());
       return _error->Error("Could not find a record in the DSC '%s'",FileName.c_str());
+   
+   if (Tags.Exists("Source") == false)
+      return _error->Error("Could not find a Source entry in the DSC '%s'",FileName.c_str());
    Tags.Trim();
    Tags.Trim();
 
 
    // Lookup the overide information, finding first the best priority.
    // Lookup the overide information, finding first the best priority.
@@ -714,6 +695,10 @@ bool SourcesWriter::DoPackage(string FileName)
       OverItem = auto_ptr<Override::Item>(new Override::Item);
       OverItem = auto_ptr<Override::Item>(new Override::Item);
    }
    }
    
    
+   struct stat St;
+   if (stat(FileName.c_str(), &St) != 0)
+      return _error->Errno("fstat","Failed to stat %s",FileName.c_str());
+
    auto_ptr<Override::Item> SOverItem(SOver.GetItem(Tags.FindS("Source")));
    auto_ptr<Override::Item> SOverItem(SOver.GetItem(Tags.FindS("Source")));
    // const auto_ptr<Override::Item> autoSOverItem(SOverItem);
    // const auto_ptr<Override::Item> autoSOverItem(SOverItem);
    if (SOverItem.get() == 0)
    if (SOverItem.get() == 0)
@@ -732,23 +717,23 @@ bool SourcesWriter::DoPackage(string FileName)
    string const strippedName = flNotDir(FileName);
    string const strippedName = flNotDir(FileName);
    std::ostringstream ostreamFiles;
    std::ostringstream ostreamFiles;
    if (DoMD5 == true && Tags.Exists("Files"))
    if (DoMD5 == true && Tags.Exists("Files"))
-      ostreamFiles << "\n " << string(DscHashes.MD5.Result()) << " " << St.st_size << " "
+      ostreamFiles << "\n " << Db.MD5Res.c_str() << " " << St.st_size << " "
 		   << strippedName << "\n " << Tags.FindS("Files");
 		   << strippedName << "\n " << Tags.FindS("Files");
    string const Files = ostreamFiles.str();
    string const Files = ostreamFiles.str();
 
 
    std::ostringstream ostreamSha1;
    std::ostringstream ostreamSha1;
    if (DoSHA1 == true && Tags.Exists("Checksums-Sha1"))
    if (DoSHA1 == true && Tags.Exists("Checksums-Sha1"))
-      ostreamSha1 << "\n " << string(DscHashes.SHA1.Result()) << " " << St.st_size << " "
+      ostreamSha1 << "\n " << string(Db.SHA1Res.c_str()) << " " << St.st_size << " "
 		   << strippedName << "\n " << Tags.FindS("Checksums-Sha1");
 		   << strippedName << "\n " << Tags.FindS("Checksums-Sha1");
 
 
    std::ostringstream ostreamSha256;
    std::ostringstream ostreamSha256;
    if (DoSHA256 == true && Tags.Exists("Checksums-Sha256"))
    if (DoSHA256 == true && Tags.Exists("Checksums-Sha256"))
-      ostreamSha256 << "\n " << string(DscHashes.SHA256.Result()) << " " << St.st_size << " "
+      ostreamSha256 << "\n " << string(Db.SHA256Res.c_str()) << " " << St.st_size << " "
 		   << strippedName << "\n " << Tags.FindS("Checksums-Sha256");
 		   << strippedName << "\n " << Tags.FindS("Checksums-Sha256");
 
 
    std::ostringstream ostreamSha512;
    std::ostringstream ostreamSha512;
    if (DoSHA512 == true && Tags.Exists("Checksums-Sha512"))
    if (DoSHA512 == true && Tags.Exists("Checksums-Sha512"))
-      ostreamSha512 << "\n " << string(DscHashes.SHA512.Result()) << " " << St.st_size << " "
+      ostreamSha512 << "\n " << string(Db.SHA512Res.c_str()) << " " << St.st_size << " "
 		   << strippedName << "\n " << Tags.FindS("Checksums-Sha512");
 		   << strippedName << "\n " << Tags.FindS("Checksums-Sha512");
 
 
    // Strip the DirStrip prefix from the FileName and add the PathPrefix
    // Strip the DirStrip prefix from the FileName and add the PathPrefix
@@ -785,8 +770,13 @@ bool SourcesWriter::DoPackage(string FileName)
           (DoSHA256 == true && !Tags.Exists("Checksums-Sha256")) ||
           (DoSHA256 == true && !Tags.Exists("Checksums-Sha256")) ||
           (DoSHA512 == true && !Tags.Exists("Checksums-Sha512")))
           (DoSHA512 == true && !Tags.Exists("Checksums-Sha512")))
       {
       {
-         if (Db.GetFileInfo(OriginalPath, false, false, false, DoMD5, DoSHA1, DoSHA256, DoSHA512, DoAlwaysStat)
-               == false)
+         if (Db.GetFileInfo(OriginalPath, 
+                            false, /* DoControl */
+                            false, /* DoContents */
+                            false, /* GenContentsOnly */
+                            false, /* DoSource */
+                            DoMD5, DoSHA1, DoSHA256, DoSHA512,
+                            DoAlwaysStat) == false)
          {
          {
             return _error->Error("Error getting file info");
             return _error->Error("Error getting file info");
          }
          }
@@ -802,6 +792,9 @@ bool SourcesWriter::DoPackage(string FileName)
          if (DoSHA512 == true && !Tags.Exists("Checksums-Sha512"))
          if (DoSHA512 == true && !Tags.Exists("Checksums-Sha512"))
             ostreamSha512 << "\n " << string(Db.SHA512Res) << " "
             ostreamSha512 << "\n " << string(Db.SHA512Res) << " "
                << Db.GetFileSize() << " " << ParseJnk;
                << Db.GetFileSize() << " " << ParseJnk;
+
+         // write back the GetFileInfo() stats data 
+         Db.Finish();
       }
       }
 
 
       // Perform the delinking operation
       // Perform the delinking operation
@@ -872,7 +865,7 @@ bool SourcesWriter::DoPackage(string FileName)
 
 
    Stats.Packages++;
    Stats.Packages++;
    
    
-   return Db.Finish();
+   return true;
 }
 }
 									/*}}}*/
 									/*}}}*/
 
 
@@ -893,7 +886,15 @@ ContentsWriter::ContentsWriter(string const &DB, string const &Arch) :
    determine what the package name is. */
    determine what the package name is. */
 bool ContentsWriter::DoPackage(string FileName, string Package)
 bool ContentsWriter::DoPackage(string FileName, string Package)
 {
 {
-   if (!Db.GetFileInfo(FileName, Package.empty(), true, false, false, false, false, false))
+   if (!Db.GetFileInfo(FileName, 
+                       Package.empty(), /* DoControl */
+                       true,            /* DoContents */
+                       false,           /* GenContentsOnly */
+                       false,           /* DoSource */
+                       false,           /* DoMD5 */
+                       false,           /* DoSHA1 */
+                       false,           /* DoSHA256 */
+                       false))          /* DoSHA512 */
    {
    {
       return false;
       return false;
    }
    }

+ 1 - 1
ftparchive/writer.h

@@ -174,7 +174,7 @@ class SourcesWriter : public FTWScanner
    string PathPrefix;
    string PathPrefix;
    string DirStrip;
    string DirStrip;
    FILE *Output;
    FILE *Output;
-   struct CacheDB::Stats Stats;
+   struct CacheDB::Stats &Stats;
 
 
    virtual bool DoPackage(string FileName);
    virtual bool DoPackage(string FileName);
 
 

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1213 - 1214
po/ar.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1422 - 1423
po/ast.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1426 - 1427
po/bg.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1139 - 1140
po/bs.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1420 - 1421
po/ca.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1425 - 1426
po/cs.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1435 - 1436
po/cy.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1427 - 1428
po/da.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1459 - 1460
po/de.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1414 - 1415
po/dz.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1427 - 1428
po/el.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1432 - 1433
po/es.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1401 - 1402
po/eu.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1404 - 1405
po/fi.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1433 - 1434
po/fr.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1423 - 1424
po/gl.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1420 - 1421
po/hu.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1447 - 1448
po/it.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1424 - 1425
po/ja.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1401 - 1402
po/km.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1428 - 1429
po/ko.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1211 - 1212
po/ku.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1359 - 1360
po/lt.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1424 - 1425
po/mr.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1416 - 1417
po/nb.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1407 - 1408
po/ne.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1459 - 1460
po/nl.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1418 - 1419
po/nn.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1429 - 1430
po/pl.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1424 - 1425
po/pt.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1427 - 1428
po/pt_BR.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1429 - 1430
po/ro.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1430 - 1431
po/ru.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1425 - 1426
po/sk.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1407 - 1408
po/sl.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1427 - 1428
po/sv.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1404 - 1405
po/th.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1425 - 1426
po/tl.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1424 - 1425
po/tr.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1431 - 1432
po/uk.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1429 - 1430
po/vi.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1417 - 1418
po/zh_CN.po


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1400 - 1401
po/zh_TW.po


+ 0 - 95
share/bash-completions/apt

@@ -1,95 +0,0 @@
-# Debian apt(8) completion                             -*- shell-script -*-
-
-_apt()
-{
-    local sourcesdir="/etc/apt/sources.list.d"
-    local cur prev words cword
-    _init_completion || return
-
-    # see if the user selected a command already
-    local COMMANDS=("install" "remove" "purge" "show" "list"
-                    "update" "upgrade" "full-upgrade" "dist-upgrade"
-                    "edit-sources" "help")
-
-    local command i
-    for (( i=0; i < ${#words[@]}-1; i++ )); do
-        if [[ ${COMMANDS[@]} =~ ${words[i]} ]]; then
-            command=${words[i]}
-            break
-        fi
-    done
-
-    # supported options per command
-    if [[ "$cur" == -* ]]; then
-        case $command in
-            install|remove|purge|upgrade|full-upgrade)
-                COMPREPLY=( $( compgen -W '--show-progress
-                  --fix-broken --purge --verbose-versions --auto-remove
-                  --simulate --dry-run
-                  --download
-                  --fix-missing
-                  --fix-policy
-                  --ignore-hold
-                  --force-yes
-                  --trivial-only
-                  --reinstall --solver' -- "$cur" ) )
-                return 0
-                ;;
-            update)
-                COMPREPLY=( $( compgen -W '--list-cleanup 
-                  ' -- "$cur" ) )
-                return 0
-                ;;
-            list)
-                COMPREPLY=( $( compgen -W '--installed --upgradable 
-                  --manual-installed
-                  -v --verbose
-                  -a --all-versions
-                  ' -- "$cur" ) )
-                return 0
-                ;;
-            show)
-                COMPREPLY=( $( compgen -W '-a --all-versions
-                  ' -- "$cur" ) )
-                return 0
-                ;;
-        esac
-    fi
-
-    # specific command arguments
-    if [[ -n $command ]]; then
-        case $command in
-            remove|purge)
-                if [[ -f /etc/debian_version ]]; then
-                    # Debian system
-                    COMPREPLY=( $( \
-                        _xfunc dpkg _comp_dpkg_installed_packages $cur ) )
-                else
-                    # assume RPM based
-                    _xfunc rpm _rpm_installed_packages
-                fi
-                return 0
-                ;;
-            install|show|list)
-                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
-                    2> /dev/null ) )
-                return 0
-                ;;
-            edit-sources)
-                COMPREPLY=( $( compgen -W '$( command ls $sourcesdir )' \
-                    -- "$cur" ) )
-                return 0
-                ;;
-        esac
-    fi
-
-    # no command yet, show what commands we have
-    if [ "$command" = "" ]; then
-        COMPREPLY=( $( compgen -W '${COMMANDS[@]}' -- "$cur" ) )
-    fi
-
-    return 0
-} &&
-complete -F _apt apt
-
-# ex: ts=4 sw=4 et filetype=sh

+ 4 - 1
test/integration/framework

@@ -128,7 +128,10 @@ dpkgcheckbuilddeps() {
 }
 }
 gdb() {
 gdb() {
 	echo "gdb: run »$*«"
 	echo "gdb: run »$*«"
-	APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${LIBRARYPATH} command gdb ${BUILDDIRECTORY}/$1 --args "$@"
+	CMD="$1"
+	shift
+
+	APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${LIBRARYPATH} command gdb ${BUILDDIRECTORY}/$CMD --args ${BUILDDIRECTORY}/$CMD "$@"
 }
 }
 gpg() {
 gpg() {
 	# see apt-key for the whole trickery. Setup is done in setupenvironment
 	# see apt-key for the whole trickery. Setup is done in setupenvironment

+ 2 - 1
test/integration/run-tests

@@ -36,11 +36,12 @@ else
 	CRESET=''
 	CRESET=''
 fi
 fi
 
 
+TOTAL="$(run-parts --list $DIR | grep '/test-' | wc -l)"
 for testcase in $(run-parts --list $DIR | grep '/test-'); do
 for testcase in $(run-parts --list $DIR | grep '/test-'); do
 	if [ "$MSGLEVEL" -le 2 ]; then
 	if [ "$MSGLEVEL" -le 2 ]; then
 		echo -n "${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: "
 		echo -n "${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: "
 	else
 	else
-		echo "${CTEST}Run Testcase ${CHIGH}$(basename ${testcase})${CRESET}"
+		echo "${CTEST}Run Testcase ($(($ALL+1))/${TOTAL}) ${CHIGH}$(basename ${testcase})${CRESET}"
 	fi
 	fi
 	if ! ${testcase}; then
 	if ! ${testcase}; then
 		FAIL=$((FAIL+1))
 		FAIL=$((FAIL+1))

+ 100 - 0
test/integration/test-apt-ftparchive-cachedb

@@ -0,0 +1,100 @@
+#!/bin/sh
+set -e
+
+ensure_correct_packages_file() {
+    testequal "Package: foo
+Priority: optional
+Section: others
+Installed-Size: 29
+Maintainer: Joe Sixpack <joe@example.org>
+Architecture: i386
+Version: 1
+Filename: pool/main/foo_1_i386.deb" head -n8 ./aptarchive/dists/test/main/binary-i386/Packages 
+}
+
+ensure_correct_contents_file() {
+    testequal "usr/bin/foo-i386					    others/foo
+usr/share/doc/foo/FEATURES				    others/foo
+usr/share/doc/foo/changelog				    others/foo
+usr/share/doc/foo/copyright				    others/foo" cat ./aptarchive/dists/test/Contents-i386
+}
+
+#
+# main()
+#
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture "i386"
+
+mkdir -p aptarchive/dists/test/main/i18n/
+mkdir -p aptarchive/dists/test/main/source/
+mkdir -p aptarchive/dists/test/main/binary-i386
+mkdir -p aptarchive/pool/main
+
+mkdir aptarchive-overrides
+mkdir aptarchive-cache
+cat > ftparchive.conf <<"EOF"
+Dir {
+  ArchiveDir "./aptarchive";
+  OverrideDir "./aptarchive-overrides";
+  CacheDir "./aptarchive-cache";
+};
+
+Default {
+ Packages::Compress ". gzip bzip2";
+ Contents::Compress ". gzip bzip2";
+ LongDescription "false";
+};
+
+TreeDefault {
+ BinCacheDB "packages-$(SECTION)-$(ARCH).db";
+
+ Directory  "pool/$(SECTION)";
+ SrcDirectory "pool/$(SECTION)";
+
+ Packages   "$(DIST)/$(SECTION)/binary-$(ARCH)/Packages";
+ Contents    "$(DIST)/Contents-$(ARCH)";
+};
+
+Tree "dists/test" {
+  Sections "main";
+  Architectures "i386";
+
+};
+EOF
+
+# build one pacakge
+buildsimplenativepackage 'foo' 'i386' '1' 'test'
+mv incoming/* aptarchive/pool/main/
+
+# generate (empty cachedb)
+aptftparchive generate ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1 2> stats-out.txt
+ensure_correct_packages_file
+ensure_correct_contents_file
+testequal " Misses in Cache: 2
+ dists/test/Contents-i386: New 402 B  Misses in Cache: 0" grep Misses stats-out.txt
+
+# generate again
+aptftparchive generate ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1 2> stats-out.txt
+ensure_correct_packages_file
+ensure_correct_contents_file
+testequal " Misses in Cache: 0
+ dists/test/Contents-i386:  Misses in Cache: 0" grep Misses stats-out.txt
+
+# and again (with removing the Packages file)
+rm -f ./aptarchive/dists/test/main/binary-i386/*
+rm -f ./aptarchive/dists/test/Contents-i386
+aptftparchive generate ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1 2> stats-out.txt
+ensure_correct_packages_file
+ensure_correct_contents_file
+testequal " Misses in Cache: 0
+ dists/test/Contents-i386: New 402 B  Misses in Cache: 0" grep Misses stats-out.txt
+
+# and clean
+rm -rf aptarchive/pool/main/*
+testequal "packages-main-i386.db" aptftparchive clean ftparchive.conf
+aptftparchive clean ftparchive.conf -o Debug::APT::FTPArchive::Clean=1 > clean-out.txt 2>&1 
+testequal "0	Number of unique keys in the tree" grep unique clean-out.txt
+testequal "packages-main-i386.db" grep packages-main-i386.db clean-out.txt
+

+ 193 - 0
test/integration/test-apt-ftparchive-src-cachedb

@@ -0,0 +1,193 @@
+#!/bin/sh
+set -e
+
+assert_correct_sources_file() {
+    testequal "Package: bar
+Binary: bar
+Version: 1.0
+Architecture: all
+Format: 3.0 (native)
+Directory: pool/main
+Files:
+ 7b57dd065e51de5905288a5104d4bef5 406 bar_1.0.dsc
+ d41d8cd98f00b204e9800998ecf8427e 0 bar_1.0.tar.gz
+Package-List:
+ bar deb admin extra
+Checksums-Sha1:
+ 17a40b76715f393ab7fd6485c9392a02f1adf903 406 bar_1.0.dsc
+ da39a3ee5e6b4b0d3255bfef95601890afd80709 0 bar_1.0.tar.gz
+Checksums-Sha256:
+ d9d7507f66a89258b6920aca47747d7a30e0e64b09ecabbf02b2efbdabf840a9 406 bar_1.0.dsc
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 bar_1.0.tar.gz
+Checksums-Sha512:
+ ee0a9bfb6614159b45203fc29487d4f37387993ca0e6d6f27b80010498f3731d75753188ece307508ae9af0259bd11a6af15a1a38f0b87dbd5ea1273b7a7d53e 406 bar_1.0.dsc
+ cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e 0 bar_1.0.tar.gz
+
+Package: foo
+Binary: foo
+Version: 1.0
+Architecture: all
+Format: 3.0 (native)
+Directory: pool/main
+Files:
+ d144826e6f02831c1933e910c92cd7e0 171 foo_1.0.dsc
+ d41d8cd98f00b204e9800998ecf8427e 0 foo_1.0.tar.gz
+Package-List: 
+ foo deb admin extra
+Checksums-Sha1:
+ 979306aa3ccff3d61bba062bb6977e2493c6f907 171 foo_1.0.dsc
+ da39a3ee5e6b4b0d3255bfef95601890afd80709 0 foo_1.0.tar.gz
+Checksums-Sha256:
+ 8c780af8b5a6d5b3c2e2f9518940beebea52ac6d6ad7b52c082dc925cfe5b532 171 foo_1.0.dsc
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 foo_1.0.tar.gz
+Checksums-Sha512:
+ 3da0240fd764657c2f3661b4d750578a9a99b0580591b133756379d48117ebda87a5ed2467f513200d6e7eaf51422cbe91c15720eef7fb4bba2cc8ff81ebc547 171 foo_1.0.dsc
+ cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e 0 foo_1.0.tar.gz
+" cat ./aptarchive/dists/test/main/source/Sources
+}
+
+create_source_files() {
+    NAME="$1"
+    REQUEST_CLEARSIGN="$2"
+    
+    TARFILE="aptarchive/pool/main/${NAME}_1.0.tar.gz"
+    DSC_FILE="aptarchive/pool/main/${NAME}_1.0.dsc"
+    touch $TARFILE
+    if [ "$REQUEST_CLEARSIGN" = "CLEARSIGN" ]; then
+        printf -- "-----BEGIN PGP SIGNED MESSAGE-----\n\n" > $DSC_FILE
+    fi
+    cat >> $DSC_FILE << EOF
+Format: 3.0 (native)
+Source: $NAME
+Binary: $NAME
+Architecture: all
+Version: 1.0
+Package-List: 
+ $NAME deb admin extra
+Files: 
+ $(md5sum $TARFILE|cut -f1 -d' ') $(stat --print="%s" $TARFILE) ${NAME}_1.0.tar.gz
+EOF
+    if [ "$REQUEST_CLEARSIGN" = "CLEARSIGN" ]; then
+        cat >> $DSC_FILE <<EOF
+
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.11 (GNU/Linux)
+
+iEYEARECAAYFAk3k/VoACgkQliSD4VZixzQxlgCgpav7j68z48qNTDFuT9fLqwT5
+DFwAoIXatJFENEC371bMKTkUKlwZxQEk
+=iI9V
+-----END PGP SIGNATURE-----
+EOF
+    fi
+}
+
+create_clearsigned_source_files() {
+    NAME="$1"
+    create_source_files "$NAME" "CLEARSIGN"
+}
+
+#
+# main()
+#
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture "i386"
+
+msgtest 'Test apt-ftparchive source with missing hashes in .dsc'
+
+mkdir -p aptarchive/pool/main
+create_source_files foo
+create_clearsigned_source_files bar
+
+mkdir -p aptarchive/dists/test/main/i18n/
+mkdir -p aptarchive/dists/test/main/source/
+
+mkdir aptarchive-overrides
+mkdir aptarchive-cache
+
+
+
+# generate with --db option
+(cd aptarchive && aptftparchive --db ./test.db sources pool/main/ \
+    -o APT::FTPArchive::ShowCacheMisses=1  \
+    > dists/test/main/source/Sources \
+    2> stats-out.txt
+    testequal " Misses in Cache: 2" grep Misses stats-out.txt
+)
+assert_correct_sources_file
+
+# generate with --db option (again to ensure its in the cache)
+(cd aptarchive && aptftparchive --db ./test.db sources pool/main/ \
+    -o APT::FTPArchive::ShowCacheMisses=1  \
+    > dists/test/main/source/Sources \
+    2> stats-out.txt  
+    testequal " Misses in Cache: 0" grep Misses stats-out.txt
+)
+assert_correct_sources_file
+
+
+
+# get ready for the "apt-ftparchive generate" command
+cat > apt-ftparchive.conf <<"EOF"
+Dir {
+  ArchiveDir "./aptarchive";
+  OverrideDir "./aptarchive-overrides";
+  CacheDir "./aptarchive-cache";
+};
+
+Default {
+ Packages::Compress ". gzip bzip2";
+ Contents::Compress ". gzip bzip2";
+ LongDescription "false";
+};
+
+TreeDefault {
+ BinCacheDB "packages-$(SECTION)-$(ARCH).db";
+ SrcCacheDB "sources-$(SECTION).db";
+
+ Directory  "pool/$(SECTION)";
+ SrcDirectory "pool/$(SECTION)";
+
+ Sources    "$(DIST)/$(SECTION)/source/Sources";
+};
+
+Tree "dists/test" {
+  Sections "main";
+  Architectures "source";
+
+};
+EOF
+
+# generate (empty cachedb)
+aptftparchive generate apt-ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1 2> stats-out.txt
+testequal " Misses in Cache: 2" grep Misses stats-out.txt
+assert_correct_sources_file
+
+
+# generate again out of the cache
+rm -f ./aptarchive/dists/test/main/source/Sources
+aptftparchive generate apt-ftparchive.conf -o APT::FTPArchive::ShowCacheMisses=1  2> stats-out.txt
+testequal " Misses in Cache: 0" grep Misses stats-out.txt
+assert_correct_sources_file
+
+
+
+# generate invalid files
+mkdir aptarchive/pool/invalid
+printf "meep" > aptarchive/pool/invalid/invalid_1.0.dsc
+testequal "
+E: Could not find a Source entry in the DSC 'aptarchive/pool/invalid/invalid_1.0.dsc'" aptftparchive sources aptarchive/pool/invalid
+rm -f aptarchive/pool/invalid/invalid_1.0.dsc
+
+dd if=/dev/zero of="aptarchive/pool/invalid/toobig_1.0.dsc" bs=1k count=129 2>/dev/null
+testequal "
+E: DSC file 'aptarchive/pool/invalid/toobig_1.0.dsc' is too large!" aptftparchive sources aptarchive/pool/invalid
+
+# ensure clean works
+rm -f aptarchive/pool/main/*
+aptftparchive clean apt-ftparchive.conf -o Debug::APT::FTPArchive::Clean=1 > clean-out.txt 2>&1 
+testequal "0	Number of unique keys in the tree" grep unique clean-out.txt
+testequal "sources-main.db" grep sources-main.db clean-out.txt
+
+