]> git.saurik.com Git - apt.git/commitdiff
add APT::FTPArchive::AlwaysStat to disable the too aggressive
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 28 Nov 2009 01:12:36 +0000 (02:12 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 28 Nov 2009 01:12:36 +0000 (02:12 +0100)
caching if versions are build multiply times (not recommend)
Patch by Christoph Goehre, thanks! (Closes: #463260)

debian/changelog
doc/apt-ftparchive.1.xml
doc/po/apt-doc.pot
ftparchive/cachedb.cc
ftparchive/cachedb.h
ftparchive/writer.cc
ftparchive/writer.h
po/apt-all.pot

index fdd7bd24be0018f9caf6546f50b97d3dd30db014..85ee97713ad4155899cafb5c078388cb2b3df4ba 100644 (file)
@@ -80,6 +80,9 @@ apt (0.7.25) UNRELEASED; urgency=low
     - add https options which default to http ones (Closes: #557085)
   * ftparchive/writer.{cc,h}:
     - add APT::FTPArchive::LongDescription to be able to disable them
     - add https options which default to http ones (Closes: #557085)
   * ftparchive/writer.{cc,h}:
     - add APT::FTPArchive::LongDescription to be able to disable them
+    - add APT::FTPArchive::AlwaysStat to disable the too aggressive
+      caching if versions are build multiply times (not recommend)
+      Patch by Christoph Goehre, thanks! (Closes: #463260)
   * apt-pkg/deb/debsrcrecords.cc:
     - use "diff" filetype for .debian.tar.* files (Closes: #554898)
 
   * apt-pkg/deb/debsrcrecords.cc:
     - use "diff" filetype for .debian.tar.* files (Closes: #554898)
 
index d47df957acdcff191451788f580b24ccbdf32c34..e2eab0fb27d426dca29fcd7afa9f2b0bc120895f 100644 (file)
@@ -544,6 +544,18 @@ for i in Sections do
      Configuration Item: <literal>APT::FTPArchive::ReadOnlyDB</literal>.</para></listitem>
      </varlistentry>   
 
      Configuration Item: <literal>APT::FTPArchive::ReadOnlyDB</literal>.</para></listitem>
      </varlistentry>   
 
+     <varlistentry><term><option>APT::FTPArchive::AlwaysStat</option></term>
+     <listitem><para>
+     &apt-ftparchive; caches as much as possible of metadata in it is cachedb. If packages
+     are recompiled and/or republished with the same version again, this will lead to problems
+     as the now outdated cached metadata like size and checksums will be used. With this option
+     enabled this will no longer happen as it will be checked if the file was changed.
+     Note that this option is set to "<literal>false</literal>" by default as it is not recommend
+     to upload multiply versions/builds of a package with the same versionnumber, so in theory
+     nobody will have these problems and therefore all these extra checks are useless.
+     </para></listitem>
+     </varlistentry>
+
      <varlistentry><term><option>APT::FTPArchive::LongDescription</option></term>
      <listitem><para>
      This configuration option defaults to "<literal>true</literal>" and should only be set to
      <varlistentry><term><option>APT::FTPArchive::LongDescription</option></term>
      <listitem><para>
      This configuration option defaults to "<literal>true</literal>" and should only be set to
index 46febf8ca8573d75d8204803d5b87f2ef269f173..5172f7f84914d7b40dd13e9bd13707ad4664be68 100644 (file)
@@ -7,7 +7,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2009-11-27 00:18+0100\n"
+"POT-Creation-Date: 2009-11-28 02:08+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1411,7 +1411,7 @@ msgid ""
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><variablelist>
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><variablelist>
-#: apt-cache.8.xml:356 apt-cdrom.8.xml:150 apt-config.8.xml:98 apt-extracttemplates.1.xml:67 apt-ftparchive.1.xml:556 apt-get.8.xml:554 apt-sortpkgs.1.xml:64
+#: apt-cache.8.xml:356 apt-cdrom.8.xml:150 apt-config.8.xml:98 apt-extracttemplates.1.xml:67 apt-ftparchive.1.xml:568 apt-get.8.xml:554 apt-sortpkgs.1.xml:64
 msgid "&apt-commonoptions;"
 msgstr ""
 
 msgid "&apt-commonoptions;"
 msgstr ""
 
@@ -1426,7 +1426,7 @@ msgid "&file-sourceslist; &file-statelists;"
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><title>
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><title>
-#: apt-cache.8.xml:368 apt-cdrom.8.xml:155 apt-config.8.xml:103 apt-extracttemplates.1.xml:74 apt-ftparchive.1.xml:572 apt-get.8.xml:569 apt-key.8.xml:162 apt-mark.8.xml:133 apt-secure.8.xml:181 apt-sortpkgs.1.xml:69 apt.conf.5.xml:1023 apt_preferences.5.xml:622 sources.list.5.xml:233
+#: apt-cache.8.xml:368 apt-cdrom.8.xml:155 apt-config.8.xml:103 apt-extracttemplates.1.xml:74 apt-ftparchive.1.xml:584 apt-get.8.xml:569 apt-key.8.xml:162 apt-mark.8.xml:133 apt-secure.8.xml:181 apt-sortpkgs.1.xml:69 apt.conf.5.xml:1023 apt_preferences.5.xml:622 sources.list.5.xml:233
 msgid "See Also"
 msgstr ""
 
 msgid "See Also"
 msgstr ""
 
@@ -1436,7 +1436,7 @@ msgid "&apt-conf;, &sources-list;, &apt-get;"
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><title>
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><title>
-#: apt-cache.8.xml:373 apt-cdrom.8.xml:160 apt-config.8.xml:108 apt-extracttemplates.1.xml:78 apt-ftparchive.1.xml:576 apt-get.8.xml:575 apt-mark.8.xml:137 apt-sortpkgs.1.xml:73
+#: apt-cache.8.xml:373 apt-cdrom.8.xml:160 apt-config.8.xml:108 apt-extracttemplates.1.xml:78 apt-ftparchive.1.xml:588 apt-get.8.xml:575 apt-mark.8.xml:137 apt-sortpkgs.1.xml:73
 msgid "Diagnostics"
 msgstr ""
 
 msgid "Diagnostics"
 msgstr ""
 
@@ -1735,7 +1735,7 @@ msgid "Just show the contents of the configuration space."
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><para>
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><para>
-#: apt-config.8.xml:104 apt-extracttemplates.1.xml:75 apt-ftparchive.1.xml:573 apt-sortpkgs.1.xml:70
+#: apt-config.8.xml:104 apt-extracttemplates.1.xml:75 apt-ftparchive.1.xml:585 apt-sortpkgs.1.xml:70
 msgid "&apt-conf;"
 msgstr ""
 
 msgid "&apt-conf;"
 msgstr ""
 
@@ -2690,12 +2690,31 @@ msgstr ""
 
 #. type: Content of: <refentry><refsect1><variablelist><varlistentry><term>
 #: apt-ftparchive.1.xml:547
 
 #. type: Content of: <refentry><refsect1><variablelist><varlistentry><term>
 #: apt-ftparchive.1.xml:547
-msgid "<option>APT::FTPArchive::LongDescription</option>"
+msgid "<option>APT::FTPArchive::AlwaysStat</option>"
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><variablelist><varlistentry><listitem><para>
 #: apt-ftparchive.1.xml:549
 msgid ""
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><variablelist><varlistentry><listitem><para>
 #: apt-ftparchive.1.xml:549
 msgid ""
+"&apt-ftparchive; caches as much as possible of metadata in it is cachedb. If "
+"packages are recompiled and/or republished with the same version again, this "
+"will lead to problems as the now outdated cached metadata like size and "
+"checksums will be used. With this option enabled this will no longer happen "
+"as it will be checked if the file was changed.  Note that this option is set "
+"to \"<literal>false</literal>\" by default as it is not recommend to upload "
+"multiply versions/builds of a package with the same versionnumber, so in "
+"theory nobody will have these problems and therefore all these extra checks "
+"are useless."
+msgstr ""
+
+#. type: Content of: <refentry><refsect1><variablelist><varlistentry><term>
+#: apt-ftparchive.1.xml:559
+msgid "<option>APT::FTPArchive::LongDescription</option>"
+msgstr ""
+
+#. type: Content of: <refentry><refsect1><variablelist><varlistentry><listitem><para>
+#: apt-ftparchive.1.xml:561
+msgid ""
 "This configuration option defaults to \"<literal>true</literal>\" and should "
 "only be set to <literal>\"false\"</literal> if the Archive generated with "
 "&apt-ftparchive; also provides <filename>Translation</filename> files. Note "
 "This configuration option defaults to \"<literal>true</literal>\" and should "
 "only be set to <literal>\"false\"</literal> if the Archive generated with "
 "&apt-ftparchive; also provides <filename>Translation</filename> files. Note "
@@ -2704,12 +2723,12 @@ msgid ""
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><title>
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><title>
-#: apt-ftparchive.1.xml:561 apt.conf.5.xml:1011 apt_preferences.5.xml:462 sources.list.5.xml:193
+#: apt-ftparchive.1.xml:573 apt.conf.5.xml:1011 apt_preferences.5.xml:462 sources.list.5.xml:193
 msgid "Examples"
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><para><programlisting>
 msgid "Examples"
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><para><programlisting>
-#: apt-ftparchive.1.xml:567
+#: apt-ftparchive.1.xml:579
 #, no-wrap
 msgid ""
 "<command>apt-ftparchive</command> packages "
 #, no-wrap
 msgid ""
 "<command>apt-ftparchive</command> packages "
@@ -2718,14 +2737,14 @@ msgid ""
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><para>
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><para>
-#: apt-ftparchive.1.xml:563
+#: apt-ftparchive.1.xml:575
 msgid ""
 "To create a compressed Packages file for a directory containing binary "
 "packages (.deb): <placeholder type=\"programlisting\" id=\"0\"/>"
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><para>
 msgid ""
 "To create a compressed Packages file for a directory containing binary "
 "packages (.deb): <placeholder type=\"programlisting\" id=\"0\"/>"
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><para>
-#: apt-ftparchive.1.xml:577
+#: apt-ftparchive.1.xml:589
 msgid ""
 "<command>apt-ftparchive</command> returns zero on normal operation, decimal "
 "100 on error."
 msgid ""
 "<command>apt-ftparchive</command> returns zero on normal operation, decimal "
 "100 on error."
index dfda827b6b0b362af8218f2b9d359d1b88876587..c352aa53ca858cd97ed9237ed5c9d6656041c65b 100644 (file)
@@ -102,9 +102,9 @@ bool CacheDB::OpenFile()
 // ---------------------------------------------------------------------
 /* This gets the size from the database if it's there.  If we need
  * to look at the file, also get the mtime from the file. */
 // ---------------------------------------------------------------------
 /* This gets the size from the database if it's there.  If we need
  * to look at the file, also get the mtime from the file. */
-bool CacheDB::GetFileStat()
+bool CacheDB::GetFileStat(bool const &doStat)
 {
 {
-       if ((CurStat.Flags & FlSize) == FlSize)
+       if ((CurStat.Flags & FlSize) == FlSize && doStat == false)
        {
                /* Already worked out the file size */
        }
        {
                /* Already worked out the file size */
        }
@@ -162,7 +162,7 @@ bool CacheDB::GetCurStat()
 // ---------------------------------------------------------------------
 bool CacheDB::GetFileInfo(string FileName, bool DoControl, bool DoContents,
                                bool GenContentsOnly, 
 // ---------------------------------------------------------------------
 bool CacheDB::GetFileInfo(string FileName, bool DoControl, bool DoContents,
                                bool GenContentsOnly, 
-                               bool DoMD5, bool DoSHA1, bool DoSHA256)
+                               bool DoMD5, bool DoSHA1, bool DoSHA256, bool const &checkMtime)
 {
        this->FileName = FileName;
 
 {
        this->FileName = FileName;
 
@@ -171,14 +171,18 @@ bool CacheDB::GetFileInfo(string FileName, bool DoControl, bool DoContents,
                return false;
    }   
    OldStat = CurStat;
                return false;
    }   
    OldStat = CurStat;
-       
-       if (GetFileStat() == false)
+
+       if (GetFileStat(checkMtime) == false)
        {
                delete Fd;
                Fd = NULL;
                return 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++;
 
        Stats.Bytes += CurStat.FileSize;
        Stats.Packages++;
 
index c10f41eccc5300769f51009935382156c117d504..15add459ce3a117ddeb1f60b8d18bd4d32eaaa95 100644 (file)
@@ -63,7 +63,7 @@ class CacheDB
       return true;
    }
    bool OpenFile();
       return true;
    }
    bool OpenFile();
-   bool GetFileStat();
+   bool GetFileStat(bool const &doStat = false);
    bool GetCurStat();
    bool LoadControl();
    bool LoadContents(bool GenOnly);
    bool GetCurStat();
    bool LoadControl();
    bool LoadContents(bool GenOnly);
@@ -125,7 +125,7 @@ class CacheDB
    
    bool SetFile(string FileName,struct stat St,FileFd *Fd);
    bool GetFileInfo(string FileName, bool DoControl, bool DoContents,
    
    bool SetFile(string FileName,struct stat St,FileFd *Fd);
    bool GetFileInfo(string FileName, bool DoControl, bool DoContents,
-                  bool GenContentsOnly, bool DoMD5, bool DoSHA1, bool DoSHA256);
+                  bool GenContentsOnly, bool DoMD5, bool DoSHA1, bool DoSHA256, bool const &checkMtime = false);
    bool Finish();   
    
    bool Clean();
    bool Finish();   
    
    bool Clean();
index b2ebdca8a30190c6fda77cdc0fd7bcbf90a0fd3c..6756021f8bffc6378043be5ebe773a77bf47b55e 100644 (file)
@@ -306,6 +306,7 @@ PackagesWriter::PackagesWriter(string DB,string Overrides,string ExtOverrides,
    DoMD5 = _config->FindB("APT::FTPArchive::MD5",true);
    DoSHA1 = _config->FindB("APT::FTPArchive::SHA1",true);
    DoSHA256 = _config->FindB("APT::FTPArchive::SHA256",true);
    DoMD5 = _config->FindB("APT::FTPArchive::MD5",true);
    DoSHA1 = _config->FindB("APT::FTPArchive::SHA1",true);
    DoSHA256 = _config->FindB("APT::FTPArchive::SHA256",true);
+   DoAlwaysStat = _config->FindB("APT::FTPArchive::AlwaysStat", false);
    DoContents = _config->FindB("APT::FTPArchive::Contents",true);
    NoOverride = _config->FindB("APT::FTPArchive::NoOverrideMsg",false);
    LongDescription = _config->FindB("APT::FTPArchive::LongDescription",true);
    DoContents = _config->FindB("APT::FTPArchive::Contents",true);
    NoOverride = _config->FindB("APT::FTPArchive::NoOverrideMsg",false);
    LongDescription = _config->FindB("APT::FTPArchive::LongDescription",true);
@@ -360,7 +361,7 @@ bool FTWScanner::SetExts(string Vals)
 bool PackagesWriter::DoPackage(string FileName)
 {      
    // Pull all the data we need form the DB
 bool PackagesWriter::DoPackage(string FileName)
 {      
    // Pull all the data we need form the DB
-   if (Db.GetFileInfo(FileName, true, DoContents, true, DoMD5, DoSHA1, DoSHA256
+   if (Db.GetFileInfo(FileName, true, DoContents, true, DoMD5, DoSHA1, DoSHA256, DoAlwaysStat)
                  == false)
    {
       return false;
                  == false)
    {
       return false;
@@ -753,7 +754,7 @@ ContentsWriter::ContentsWriter(string DB) :
    determine what the package name is. */
 bool ContentsWriter::DoPackage(string FileName,string Package)
 {
    determine what the package name is. */
 bool ContentsWriter::DoPackage(string FileName,string Package)
 {
-   if (!Db.GetFileInfo(FileName, Package.empty(), true, false, false, false, false))
+   if (!Db.GetFileInfo(FileName, Package.empty(), true, false, false, false, false, false))
    {
       return false;
    }
    {
       return false;
    }
index e7643890056fed1c0a54c2ea2a72e044f70673da..8864461d504e4b410691aa729935c68fa8e8baae 100644 (file)
@@ -84,6 +84,7 @@ class PackagesWriter : public FTWScanner
    bool DoMD5;
    bool DoSHA1;
    bool DoSHA256;
    bool DoMD5;
    bool DoSHA1;
    bool DoSHA256;
+   bool DoAlwaysStat;
    bool NoOverride;
    bool DoContents;
    bool LongDescription;
    bool NoOverride;
    bool DoContents;
    bool LongDescription;
index 3cb5ba379da2bafc7a6bc6f5c3d91a85610a4759..b6610a19135cd36675cb0c37c8ff33d46284ece1 100644 (file)
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-11-27 09:49+0100\n"
+"POT-Creation-Date: 2009-11-28 02:10+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -357,11 +357,11 @@ msgstr ""
 msgid "Failed to stat %s"
 msgstr ""
 
 msgid "Failed to stat %s"
 msgstr ""
 
-#: ftparchive/cachedb.cc:238
+#: ftparchive/cachedb.cc:242
 msgid "Archive has no control record"
 msgstr ""
 
 msgid "Archive has no control record"
 msgstr ""
 
-#: ftparchive/cachedb.cc:444
+#: ftparchive/cachedb.cc:448
 msgid "Unable to get a cursor"
 msgstr ""
 
 msgid "Unable to get a cursor"
 msgstr ""
 
@@ -426,26 +426,26 @@ msgstr ""
 msgid " DeLink limit of %sB hit.\n"
 msgstr ""
 
 msgid " DeLink limit of %sB hit.\n"
 msgstr ""
 
-#: ftparchive/writer.cc:388
+#: ftparchive/writer.cc:389
 msgid "Archive had no package field"
 msgstr ""
 
 msgid "Archive had no package field"
 msgstr ""
 
-#: ftparchive/writer.cc:396 ftparchive/writer.cc:627
+#: ftparchive/writer.cc:397 ftparchive/writer.cc:628
 #, c-format
 msgid "  %s has no override entry\n"
 msgstr ""
 
 #, c-format
 msgid "  %s has no override entry\n"
 msgstr ""
 
-#: ftparchive/writer.cc:457 ftparchive/writer.cc:715
+#: ftparchive/writer.cc:458 ftparchive/writer.cc:716
 #, c-format
 msgid "  %s maintainer is %s not %s\n"
 msgstr ""
 
 #, c-format
 msgid "  %s maintainer is %s not %s\n"
 msgstr ""
 
-#: ftparchive/writer.cc:637
+#: ftparchive/writer.cc:638
 #, c-format
 msgid "  %s has no source override entry\n"
 msgstr ""
 
 #, c-format
 msgid "  %s has no source override entry\n"
 msgstr ""
 
-#: ftparchive/writer.cc:641
+#: ftparchive/writer.cc:642
 #, c-format
 msgid "  %s has no binary override entry either\n"
 msgstr ""
 #, c-format
 msgid "  %s has no binary override entry either\n"
 msgstr ""
@@ -1764,22 +1764,22 @@ msgstr ""
 msgid "Connecting to %s"
 msgstr ""
 
 msgid "Connecting to %s"
 msgstr ""
 
-#: methods/connect.cc:165 methods/connect.cc:184
+#: methods/connect.cc:166 methods/connect.cc:185
 #, c-format
 msgid "Could not resolve '%s'"
 msgstr ""
 
 #, c-format
 msgid "Could not resolve '%s'"
 msgstr ""
 
-#: methods/connect.cc:190
+#: methods/connect.cc:191
 #, c-format
 msgid "Temporary failure resolving '%s'"
 msgstr ""
 
 #, c-format
 msgid "Temporary failure resolving '%s'"
 msgstr ""
 
-#: methods/connect.cc:193
+#: methods/connect.cc:194
 #, c-format
 msgid "Something wicked happened resolving '%s:%s' (%i - %s)"
 msgstr ""
 
 #, c-format
 msgid "Something wicked happened resolving '%s:%s' (%i - %s)"
 msgstr ""
 
-#: methods/connect.cc:240
+#: methods/connect.cc:241
 #, c-format
 msgid "Unable to connect to %s:%s:"
 msgstr ""
 #, c-format
 msgid "Unable to connect to %s:%s:"
 msgstr ""