summaryrefslogtreecommitdiff
path: root/ftparchive/writer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ftparchive/writer.cc')
-rw-r--r--ftparchive/writer.cc51
1 files changed, 49 insertions, 2 deletions
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc
index 9e5b7d4f3..b395903b7 100644
--- a/ftparchive/writer.cc
+++ b/ftparchive/writer.cc
@@ -300,7 +300,7 @@ bool FTWScanner::Delink(string &FileName,const char *OriginalPath,
/* */
PackagesWriter::PackagesWriter(string const &DB,string const &Overrides,string const &ExtOverrides,
string const &Arch) :
- FTWScanner(Arch), Db(DB), Stats(Db.Stats)
+ FTWScanner(Arch), Db(DB), Stats(Db.Stats), TransWriter(NULL)
{
Output = stdout;
SetExts(".deb .udeb");
@@ -317,7 +317,7 @@ PackagesWriter::PackagesWriter(string const &DB,string const &Overrides,string c
if (Db.Loaded() == false)
DoContents = false;
-
+
// Read the override file
if (Overrides.empty() == false && Over.ReadOverride(Overrides) == false)
return;
@@ -448,6 +448,8 @@ bool PackagesWriter::DoPackage(string FileName)
descmd5.Add(desc.c_str());
DescriptionMd5 = descmd5.Result().Value();
SetTFRewriteData(Changes[End++], "Description-md5", DescriptionMd5.c_str());
+ if (TransWriter != NULL)
+ TransWriter->DoPackage(Package, desc, DescriptionMd5);
}
// Rewrite the maintainer field if necessary
@@ -494,6 +496,51 @@ bool PackagesWriter::DoPackage(string FileName)
}
/*}}}*/
+// TranslationWriter::TranslationWriter - Constructor /*{{{*/
+// ---------------------------------------------------------------------
+/* Create a Translation-Master file for this Packages file */
+TranslationWriter::TranslationWriter(string const &File) : Output(NULL),
+ RefCounter(0)
+{
+ if (File.empty() == true)
+ return;
+
+ Output = fopen(File.c_str(), "w");
+}
+ /*}}}*/
+// TranslationWriter::DoPackage - Process a single package /*{{{*/
+// ---------------------------------------------------------------------
+/* Create a Translation-Master file for this Packages file */
+bool TranslationWriter::DoPackage(string const &Pkg, string const &Desc,
+ string const &MD5)
+{
+ if (Output == NULL)
+ return true;
+
+ // Different archs can include different versions and therefore
+ // different descriptions - so we need to check for both name and md5.
+ string const Record = Pkg + ":" + MD5;
+
+ if (Included.find(Record) != Included.end())
+ return true;
+
+ fprintf(Output, "Package: %s\nDescription-md5: %s\nDescription-en: %s\n",
+ Pkg.c_str(), MD5.c_str(), Desc.c_str());
+
+ Included.insert(Record);
+ return true;
+}
+ /*}}}*/
+// TranslationWriter::~TranslationWriter - Destructor /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+TranslationWriter::~TranslationWriter()
+{
+ if (Output != NULL)
+ fclose(Output);
+}
+ /*}}}*/
+
// SourcesWriter::SourcesWriter - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */