Procházet zdrojové kódy

Switch the TranslationWriter to use MultiCompress to be able to generate
the compressed files as we want them and to prevent the file to be
replaced without a reason which could save us from steady redownloads
of a file with the same content.

David Kalnischkies před 16 roky
rodič
revize
34f1d96cf5

+ 13 - 7
doc/apt-ftparchive.1.xml

@@ -224,7 +224,13 @@
       This is similar to <literal>Packages::Compress</literal> 
       This is similar to <literal>Packages::Compress</literal> 
       except that it controls the compression for the Contents files.</para></listitem>
       except that it controls the compression for the Contents files.</para></listitem>
       </varlistentry>
       </varlistentry>
-      
+
+      <varlistentry><term>Translation::Compress</term>
+      <listitem><para>
+      This is similar to <literal>Packages::Compress</literal> 
+      except that it controls the compression for the Translation-en master file.</para></listitem>
+      </varlistentry>
+
       <varlistentry><term>DeLinkLimit</term>
       <varlistentry><term>DeLinkLimit</term>
       <listitem><para>
       <listitem><para>
       Specifies the number of kilobytes to delink (and 
       Specifies the number of kilobytes to delink (and 
@@ -238,6 +244,12 @@
       defaults to 0644. All index files are set to this mode with no regard 
       defaults to 0644. All index files are set to this mode with no regard 
       to the umask.</para></listitem>
       to the umask.</para></listitem>
       </varlistentry>
       </varlistentry>
+
+      <varlistentry><term>LongDescription</term>
+      <listitem><para>
+      Sets if long descriptions should be included in the Packages file or split
+      out into a master Translation-en file.</para></listitem>
+      </varlistentry>
      </variablelist>
      </variablelist>
    </refsect2>
    </refsect2>
    
    
@@ -297,12 +309,6 @@
       <filename>$(DIST)/$(SECTION)/i18n/Translation-en</filename></para></listitem>
       <filename>$(DIST)/$(SECTION)/i18n/Translation-en</filename></para></listitem>
       </varlistentry>
       </varlistentry>
 
 
-      <varlistentry><term>LongDescription</term>
-      <listitem><para>
-      Sets if long descriptions should be included in the Packages file or split
-      out into a master Translation-en file.</para></listitem>
-      </varlistentry>
-
       <varlistentry><term>InternalPrefix</term>
       <varlistentry><term>InternalPrefix</term>
       <listitem><para>
       <listitem><para>
       Sets the path prefix that causes a symlink to be
       Sets the path prefix that causes a symlink to be

+ 8 - 5
ftparchive/apt-ftparchive.cc

@@ -134,8 +134,6 @@ void PackageMap::GetGeneral(Configuration &Setup,Configuration &Block)
    PkgExt = Block.Find("Packages::Extensions",
    PkgExt = Block.Find("Packages::Extensions",
 		       Setup.Find("Default::Packages::Extensions",".deb").c_str());
 		       Setup.Find("Default::Packages::Extensions",".deb").c_str());
    
    
-   Permissions = Setup.FindI("Default::FileMode",0644);
-   
    if (FLFile.empty() == false)
    if (FLFile.empty() == false)
       FLFile = flCombine(Setup.Find("Dir::FileListDir"),FLFile);
       FLFile = flCombine(Setup.Find("Dir::FileListDir"),FLFile);
    
    
@@ -458,8 +456,11 @@ void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
    string DFLFile = Setup.Find("TreeDefault::FileList", "");
    string DFLFile = Setup.Find("TreeDefault::FileList", "");
    string DSFLFile = Setup.Find("TreeDefault::SourceFileList", "");
    string DSFLFile = Setup.Find("TreeDefault::SourceFileList", "");
 
 
-   bool const LongDescription = Setup.FindB("TreeDefault::LongDescription",
+   int const Permissions = Setup.FindI("Default::FileMode",0644);
+
+   bool const LongDescription = Setup.FindB("Default::LongDescription",
 					_config->FindB("APT::FTPArchive::LongDescription", true));
 					_config->FindB("APT::FTPArchive::LongDescription", true));
+   string const TranslationCompress = Setup.Find("Default::Translation::Compress",". gzip").c_str();
 
 
    // Process 'tree' type sections
    // Process 'tree' type sections
    const Configuration::Item *Top = Setup.Tree("tree");
    const Configuration::Item *Top = Setup.Tree("tree");
@@ -479,13 +480,15 @@ void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
 					 {"$(SECTION)",&Section},
 					 {"$(SECTION)",&Section},
 					 {"$(ARCH)",&Arch},
 					 {"$(ARCH)",&Arch},
 					 {}};
 					 {}};
+	 mode_t const Perms = Block.FindI("FileMode", Permissions);
 	 bool const LongDesc = Block.FindB("LongDescription", LongDescription);
 	 bool const LongDesc = Block.FindB("LongDescription", LongDescription);
 	 TranslationWriter *TransWriter;
 	 TranslationWriter *TransWriter;
 	 if (DTrans.empty() == false && LongDesc == false)
 	 if (DTrans.empty() == false && LongDesc == false)
 	 {
 	 {
 	    string const TranslationFile = flCombine(Setup.FindDir("Dir::ArchiveDir"),
 	    string const TranslationFile = flCombine(Setup.FindDir("Dir::ArchiveDir"),
 			SubstVar(Block.Find("Translation", DTrans.c_str()), Vars));
 			SubstVar(Block.Find("Translation", DTrans.c_str()), Vars));
-	    TransWriter = new TranslationWriter(TranslationFile);
+	    string const TransCompress = Block.Find("Translation::Compress", TranslationCompress);
+	    TransWriter = new TranslationWriter(TranslationFile, TransCompress, Perms);
 	 }
 	 }
 	 else
 	 else
 	    TransWriter = NULL;
 	    TransWriter = NULL;
@@ -495,7 +498,7 @@ void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
 	 while (ParseQuoteWord(Archs,Arch) == true)
 	 while (ParseQuoteWord(Archs,Arch) == true)
 	 {
 	 {
 	    PackageMap Itm;
 	    PackageMap Itm;
-	    
+	    Itm.Permissions = Perms;
 	    Itm.BinOverride = SubstVar(Block.Find("BinOverride"),Vars);
 	    Itm.BinOverride = SubstVar(Block.Find("BinOverride"),Vars);
 	    Itm.InternalPrefix = SubstVar(Block.Find("InternalPrefix",DIPrfx.c_str()),Vars);
 	    Itm.InternalPrefix = SubstVar(Block.Find("InternalPrefix",DIPrfx.c_str()),Vars);
 
 

+ 8 - 4
ftparchive/writer.cc

@@ -499,13 +499,15 @@ bool PackagesWriter::DoPackage(string FileName)
 // TranslationWriter::TranslationWriter - Constructor			/*{{{*/
 // TranslationWriter::TranslationWriter - Constructor			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* Create a Translation-Master file for this Packages file */
 /* Create a Translation-Master file for this Packages file */
-TranslationWriter::TranslationWriter(string const &File) : Output(NULL),
+TranslationWriter::TranslationWriter(string const &File, string const &TransCompress,
+					mode_t const &Permissions) : Output(NULL),
 							RefCounter(0)
 							RefCounter(0)
 {
 {
    if (File.empty() == true)
    if (File.empty() == true)
       return;
       return;
 
 
-   Output = fopen(File.c_str(), "w");
+   Comp = new MultiCompress(File, TransCompress, Permissions);
+   Output = Comp->Input;
 }
 }
 									/*}}}*/
 									/*}}}*/
 // TranslationWriter::DoPackage - Process a single package		/*{{{*/
 // TranslationWriter::DoPackage - Process a single package		/*{{{*/
@@ -536,8 +538,10 @@ bool TranslationWriter::DoPackage(string const &Pkg, string const &Desc,
 /* */
 /* */
 TranslationWriter::~TranslationWriter()
 TranslationWriter::~TranslationWriter()
 {
 {
-   if (Output != NULL)
-      fclose(Output);
+   if (Comp == NULL)
+      return;
+
+   delete Comp;
 }
 }
 									/*}}}*/
 									/*}}}*/
 
 

+ 4 - 2
ftparchive/writer.h

@@ -22,6 +22,7 @@
 #include <set>
 #include <set>
 
 
 #include "cachedb.h"
 #include "cachedb.h"
+#include "multicompress.h"
 #include "override.h"
 #include "override.h"
 #include "apt-ftparchive.h"
 #include "apt-ftparchive.h"
 
 
@@ -75,6 +76,7 @@ class FTWScanner
 
 
 class TranslationWriter
 class TranslationWriter
 {
 {
+   MultiCompress *Comp;
    FILE *Output;
    FILE *Output;
    std::set<string> Included;
    std::set<string> Included;
    unsigned short RefCounter;
    unsigned short RefCounter;
@@ -85,8 +87,8 @@ class TranslationWriter
    unsigned short GetRefCounter() const { return RefCounter; };
    unsigned short GetRefCounter() const { return RefCounter; };
    bool DoPackage(string const &Pkg, string const &Desc, string const &MD5);
    bool DoPackage(string const &Pkg, string const &Desc, string const &MD5);
 
 
-   TranslationWriter(string const &File);
-   TranslationWriter() : Output(NULL), RefCounter(0) {};
+   TranslationWriter(string const &File, string const &TransCompress, mode_t const &Permissions);
+   TranslationWriter() : Comp(NULL), Output(NULL), RefCounter(0) {};
    ~TranslationWriter();
    ~TranslationWriter();
 };
 };