Bläddra i källkod

AJ's patch for extra override
Author: jgg
Date: 2001-06-26 02:50:20 GMT
AJ's patch for extra override

Arch Librarian 22 år sedan
förälder
incheckning
64177f1732
6 ändrade filer med 194 tillägg och 60 borttagningar
  1. 29 2
      doc/apt-ftparchive.1.sgml
  2. 14 6
      ftparchive/apt-ftparchive.cc
  3. 76 2
      ftparchive/override.cc
  4. 5 4
      ftparchive/override.h
  5. 63 41
      ftparchive/writer.cc
  6. 7 5
      ftparchive/writer.h

+ 29 - 2
doc/apt-ftparchive.1.sgml

@@ -345,12 +345,22 @@ for i in Sections do
       Sets the binary override file. The override file 
       Sets the binary override file. The override file 
       contains section, priority and maintainer address information.
       contains section, priority and maintainer address information.
       </VarListEntry>
       </VarListEntry>
-      
+
       <VarListEntry><term>SrcOverride</term>
       <VarListEntry><term>SrcOverride</term>
       <ListItem><Para>
       <ListItem><Para>
       Sets the source override file. The override file 
       Sets the source override file. The override file 
       contains section information.
       contains section information.
       </VarListEntry>
       </VarListEntry>
+      
+      <VarListEntry><term>ExtraOverride</term>
+      <ListItem><Para>
+      Sets the binary extra override file. 
+      </VarListEntry>
+      
+      <VarListEntry><term>SrcExtraOverride</term>
+      <ListItem><Para>
+      Sets the source extra override file. 
+      </VarListEntry>
      </VariableList>
      </VariableList>
    </refsect2>
    </refsect2>
    
    
@@ -378,7 +388,7 @@ for i in Sections do
       Sets the Contents file output. (Optional)
       Sets the Contents file output. (Optional)
       </VarListEntry>
       </VarListEntry>
       
       
-      <VarListEntry><term>Binoverride</term>
+      <VarListEntry><term>BinOverride</term>
       <ListItem><Para>
       <ListItem><Para>
       Sets the binary override file.
       Sets the binary override file.
       </VarListEntry>
       </VarListEntry>
@@ -388,6 +398,16 @@ for i in Sections do
       Sets the source override file.
       Sets the source override file.
       </VarListEntry>
       </VarListEntry>
       
       
+      <VarListEntry><term>ExtraOverride</term>
+      <ListItem><Para>
+      Sets the binary extra override file.
+      </VarListEntry>
+      
+      <VarListEntry><term>SrcExtraOverride</term>
+      <ListItem><Para>
+      Sets the source extra override file.
+      </VarListEntry>
+      
       <VarListEntry><term>BinCacheDB</term>
       <VarListEntry><term>BinCacheDB</term>
       <ListItem><Para>
       <ListItem><Para>
       Sets the cache DB.
       Sets the cache DB.
@@ -431,6 +451,13 @@ for i in Sections do
    package name, the second is the section to assign it.
    package name, the second is the section to assign it.
  </RefSect1>   
  </RefSect1>   
 
 
+ <RefSect1><title>The Extra Override File</>
+   <para>
+   The extra override file allows any arbitary tag to be added or replaced
+   in the output. It has 3 columns, the first is the package, the second is
+   the tag and the remainder of the line is the new value.
+ </RefSect1>   
+
  <RefSect1><Title>Options</>
  <RefSect1><Title>Options</>
    &apt-cmdblurb;
    &apt-cmdblurb;
    
    

+ 14 - 6
ftparchive/apt-ftparchive.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: apt-ftparchive.cc,v 1.3 2001/05/29 04:39:31 jgg Exp $
+// $Id: apt-ftparchive.cc,v 1.4 2001/06/26 02:50:27 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    apt-scanpackages - Efficient work-alike for dpkg-scanpackages
    apt-scanpackages - Efficient work-alike for dpkg-scanpackages
@@ -55,10 +55,12 @@ struct PackageMap
    string PkgFile;
    string PkgFile;
    string BinCacheDB;
    string BinCacheDB;
    string BinOverride;
    string BinOverride;
+   string ExtraOverride;
    
    
    // Stuff for the Source File
    // Stuff for the Source File
    string SrcFile;
    string SrcFile;
    string SrcOverride;
    string SrcOverride;
+   string SrcExtraOverride;
 
 
    // Contents 
    // Contents 
    string Contents;
    string Contents;
@@ -155,7 +157,8 @@ bool PackageMap::GenPackages(Configuration &Setup,struct CacheDB::Stats &Stats)
    
    
    // Create a package writer object.
    // Create a package writer object.
    PackagesWriter Packages(flCombine(CacheDir,BinCacheDB),
    PackagesWriter Packages(flCombine(CacheDir,BinCacheDB),
-			   flCombine(OverrideDir,BinOverride));
+			   flCombine(OverrideDir,BinOverride),
+			   flCombine(OverrideDir,ExtraOverride));
    if (PkgExt.empty() == false && Packages.SetExts(PkgExt) == false)
    if (PkgExt.empty() == false && Packages.SetExts(PkgExt) == false)
       return _error->Error("Package extension list is too long");
       return _error->Error("Package extension list is too long");
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
@@ -167,7 +170,7 @@ bool PackageMap::GenPackages(Configuration &Setup,struct CacheDB::Stats &Stats)
 
 
    Packages.Stats.DeLinkBytes = Stats.DeLinkBytes;
    Packages.Stats.DeLinkBytes = Stats.DeLinkBytes;
    Packages.DeLinkLimit = DeLinkLimit;
    Packages.DeLinkLimit = DeLinkLimit;
-      
+
    // Create a compressor object
    // Create a compressor object
    MultiCompress Comp(flCombine(ArchiveDir,PkgFile),
    MultiCompress Comp(flCombine(ArchiveDir,PkgFile),
 		      PkgCompress,Permissions);
 		      PkgCompress,Permissions);
@@ -221,7 +224,7 @@ bool PackageMap::GenPackages(Configuration &Setup,struct CacheDB::Stats &Stats)
    return !_error->PendingError();
    return !_error->PendingError();
 }
 }
 									/*}}}*/
 									/*}}}*/
-// PackageMap::GenSources - Actually generate a Package file		/*{{{*/
+// PackageMap::GenSources - Actually generate a Source file		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This generates the Sources File described by this object. */
 /* This generates the Sources File described by this object. */
 bool PackageMap::GenSources(Configuration &Setup,struct CacheDB::Stats &Stats)
 bool PackageMap::GenSources(Configuration &Setup,struct CacheDB::Stats &Stats)
@@ -240,7 +243,8 @@ bool PackageMap::GenSources(Configuration &Setup,struct CacheDB::Stats &Stats)
    
    
    // Create a package writer object.
    // Create a package writer object.
    SourcesWriter Sources(flCombine(OverrideDir,BinOverride),
    SourcesWriter Sources(flCombine(OverrideDir,BinOverride),
-			  flCombine(OverrideDir,SrcOverride));
+			 flCombine(OverrideDir,SrcOverride),
+			 flCombine(OverrideDir,SrcExtraOverride));
    if (SrcExt.empty() == false && Sources.SetExts(SrcExt) == false)
    if (SrcExt.empty() == false && Sources.SetExts(SrcExt) == false)
       return _error->Error("Source extension list is too long");
       return _error->Error("Source extension list is too long");
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
@@ -476,6 +480,7 @@ void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
 	       Itm.SrcFile = SubstVar(Block.Find("Sources",DSources.c_str()),Vars);
 	       Itm.SrcFile = SubstVar(Block.Find("Sources",DSources.c_str()),Vars);
 	       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);
 	    }
 	    }
 	    else
 	    else
 	    {
 	    {
@@ -486,6 +491,7 @@ void LoadTree(vector<PackageMap> &PkgList,Configuration &Setup)
 	       Itm.Contents = SubstVar(Block.Find("Contents",DContents.c_str()),Vars);
 	       Itm.Contents = SubstVar(Block.Find("Contents",DContents.c_str()),Vars);
 	       Itm.ContentsHead = SubstVar(Block.Find("Contents::Header",DContentsH.c_str()),Vars);
 	       Itm.ContentsHead = SubstVar(Block.Find("Contents::Header",DContentsH.c_str()),Vars);
 	       Itm.FLFile = SubstVar(Block.Find("FileList",DFLFile.c_str()),Vars);
 	       Itm.FLFile = SubstVar(Block.Find("FileList",DFLFile.c_str()),Vars);
+	       Itm.ExtraOverride = SubstVar(Block.Find("ExtraOverride"),Vars);
 	    }
 	    }
 
 
  	    Itm.GetGeneral(Setup,Block);
  	    Itm.GetGeneral(Setup,Block);
@@ -513,6 +519,8 @@ void LoadBinDir(vector<PackageMap> &PkgList,Configuration &Setup)
       Itm.SrcFile = Block.Find("Sources");
       Itm.SrcFile = Block.Find("Sources");
       Itm.BinCacheDB = Block.Find("BinCacheDB");
       Itm.BinCacheDB = Block.Find("BinCacheDB");
       Itm.BinOverride = Block.Find("BinOverride");
       Itm.BinOverride = Block.Find("BinOverride");
+      Itm.ExtraOverride = Block.Find("ExtraOverride");
+      Itm.SrcExtraOverride = Block.Find("SrcExtraOverride");
       Itm.SrcOverride = Block.Find("SrcOverride");
       Itm.SrcOverride = Block.Find("SrcOverride");
       Itm.BaseDir = Top->Tag;
       Itm.BaseDir = Top->Tag;
       Itm.FLFile = Block.Find("FileList");
       Itm.FLFile = Block.Find("FileList");
@@ -594,7 +602,7 @@ bool SimpleGenPackages(CommandLine &CmdL)
    
    
    // Create a package writer object.
    // Create a package writer object.
    PackagesWriter Packages(_config->Find("APT::FTPArchive::DB"),
    PackagesWriter Packages(_config->Find("APT::FTPArchive::DB"),
-			   Override);   
+			   Override, "");   
    if (_error->PendingError() == true)
    if (_error->PendingError() == true)
       return false;
       return false;
    
    

+ 76 - 2
ftparchive/override.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: override.cc,v 1.2 2001/02/20 07:03:18 jgg Exp $
+// $Id: override.cc,v 1.3 2001/06/26 02:50:27 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Override
    Override
@@ -93,7 +93,7 @@ bool Override::ReadOverride(string File,bool Source)
 	 continue;
 	 continue;
       }      
       }      
       *End = 0;
       *End = 0;
-      Itm.Section = Start;
+      Itm.FieldOverride["Section"] = Start;
 
 
       // Source override files only have the two columns
       // Source override files only have the two columns
       if (Source == true)
       if (Source == true)
@@ -126,6 +126,80 @@ bool Override::ReadOverride(string File,bool Source)
       Mapping[Pkg] = Itm;
       Mapping[Pkg] = Itm;
    }
    }
 
 
+   if (ferror(F))
+      _error->Errno("fgets","Failed to read the override file %s",File.c_str());
+   fclose(F);
+   return true;
+}
+									/*}}}*/
+// Override::ReadExtraOverride - Read the extra override file		/*{{{*/
+// ---------------------------------------------------------------------
+/* This parses the extra override file and reads it into the map */
+bool Override::ReadExtraOverride(string File,bool Source)
+{
+   if (File.empty() == true)
+      return true;
+   
+   FILE *F = fopen(File.c_str(),"r");
+   if (F == 0)
+      return _error->Errno("fopen","Unable to open %s",File.c_str());
+  
+   char Line[500];
+   unsigned long Counter = 0;
+   while (fgets(Line,sizeof(Line),F) != 0)
+   {
+      Counter++;
+
+      // Silence 
+      for (char *I = Line; *I != 0; I++)
+	 if (*I == '#')
+	    *I = 0;
+
+      // Strip space leading up to the package name, skip blank lines
+      char *Pkg = Line;
+      for (; isspace(*Pkg) && *Pkg != 0;Pkg++);
+      if (Pkg == 0)
+	 continue;
+
+      // Find the package and zero..
+      char *End = Pkg;
+      for (; isspace(*End) == 0 && *End != 0; End++);
+      if (*End == 0)
+      {
+	 _error->Warning("Malformed override %s line %lu #1",File.c_str(),
+			 Counter);
+	 continue;
+      }      
+      *End = 0;
+
+      // Find the field
+      for (End++; isspace(*End) != 0 && *End != 0; End++);
+      char *Field = End;
+      for (; isspace(*End) == 0 && *End != 0; End++);
+      if (*End == 0)
+      {
+	 _error->Warning("Malformed override %s line %lu #2",File.c_str(),
+			 Counter);
+	 continue;
+      }
+      *End = 0;
+      
+      // Find the field value 
+      for (End++; isspace(*End) != 0 && *End != 0; End++);
+      char *Value = End;
+      for (; *End != 0; End++);
+      for (; isspace(*(End-1)) && End > Value; End--);
+      if (End == Value)
+      {
+	 _error->Warning("Malformed override %s line %lu #3",File.c_str(),
+			 Counter);
+	 continue;
+      }      
+      *End = 0;
+
+      Mapping[Pkg].FieldOverride[Field] = Value;
+   }
+
    if (ferror(F))
    if (ferror(F))
       _error->Errno("fgets","Failed to read the override file %s",File.c_str());
       _error->Errno("fgets","Failed to read the override file %s",File.c_str());
    fclose(F);
    fclose(F);

+ 5 - 4
ftparchive/override.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: override.h,v 1.3 2001/05/29 03:49:53 jgg Exp $
+// $Id: override.h,v 1.4 2001/06/26 02:50:27 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Override
    Override
@@ -29,10 +29,10 @@ class Override
    struct Item
    struct Item
    {
    {
       string Priority;
       string Priority;
-      string Section;
       string OldMaint;
       string OldMaint;
       string NewMaint;
       string NewMaint;
-      
+
+      map<string,string> FieldOverride;
       string SwapMaint(string Orig,bool &Failed);
       string SwapMaint(string Orig,bool &Failed);
    };
    };
    
    
@@ -47,7 +47,8 @@ class Override
    };
    };
    
    
    bool ReadOverride(string File,bool Source = false);
    bool ReadOverride(string File,bool Source = false);
+   bool ReadExtraOverride(string File,bool Source = false);
 };
 };
-    
+
 #endif
 #endif
     
     

+ 63 - 41
ftparchive/writer.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: writer.cc,v 1.3 2001/05/29 04:08:09 jgg Exp $
+// $Id: writer.cc,v 1.4 2001/06/26 02:50:27 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Writer 
    Writer 
@@ -36,6 +36,20 @@
 using namespace std;
 using namespace std;
 FTWScanner *FTWScanner::Owner;
 FTWScanner *FTWScanner::Owner;
 
 
+// SetTFRewriteData - Helper for setting rewrite lists			/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+inline void SetTFRewriteData(struct TFRewriteData &tfrd,
+			     const char *tag,
+			     const char *rewrite,
+			     const char *newtag = 0)
+{
+    tfrd.Tag = tag;
+    tfrd.Rewrite = rewrite;
+    tfrd.NewTag = newtag;
+}
+									/*}}}*/
+
 // FTWScanner::FTWScanner - Constructor					/*{{{*/
 // FTWScanner::FTWScanner - Constructor					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
@@ -276,7 +290,7 @@ bool FTWScanner::SetExts(string Vals)
 // PackagesWriter::PackagesWriter - Constructor				/*{{{*/
 // PackagesWriter::PackagesWriter - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-PackagesWriter::PackagesWriter(string DB,string Overrides) :
+PackagesWriter::PackagesWriter(string DB,string Overrides,string ExtOverrides) :
 		    Db(DB),Stats(Db.Stats)
 		    Db(DB),Stats(Db.Stats)
 {
 {
    Output = stdout;
    Output = stdout;
@@ -291,12 +305,16 @@ PackagesWriter::PackagesWriter(string DB,string Overrides) :
 
 
    if (Db.Loaded() == false)
    if (Db.Loaded() == false)
       DoContents = false;
       DoContents = false;
-       
+      
    // Read the override file
    // Read the override file
    if (Overrides.empty() == false && Over.ReadOverride(Overrides) == false)
    if (Overrides.empty() == false && Over.ReadOverride(Overrides) == false)
       return;
       return;
    else
    else
       NoOverride = true;
       NoOverride = true;
+
+   if (ExtOverrides.empty() == false)
+      Over.ReadExtraOverride(ExtOverrides);
+
    _error->DumpErrors();
    _error->DumpErrors();
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -347,7 +365,7 @@ bool PackagesWriter::DoPackage(string FileName)
       }
       }
       
       
       OverItem = &Tmp;
       OverItem = &Tmp;
-      Tmp.Section = Tags.FindS("Section");
+      Tmp.FieldOverride["Section"] = Tags.FindS("Section");
       Tmp.Priority = Tags.FindS("Priority");
       Tmp.Priority = Tags.FindS("Priority");
    }
    }
 
 
@@ -367,19 +385,17 @@ bool PackagesWriter::DoPackage(string FileName)
       NewFileName = flCombine(PathPrefix,NewFileName);
       NewFileName = flCombine(PathPrefix,NewFileName);
           
           
    // This lists all the changes to the fields we are going to make.
    // This lists all the changes to the fields we are going to make.
-   TFRewriteData Changes[] = {{"Size",Size},
-                              {"MD5sum",MD5Res.c_str()},
-                              {"Filename",NewFileName.c_str()},
-                              {"Section",OverItem->Section.c_str()},
-                              {"Priority",OverItem->Priority.c_str()},
-                              {"Status",0},
-                              {"Optional",0},
-                              {},  // For maintainer
-                              {},  // For Suggests
-	                      {}};
+   // (7 hardcoded + maintainer + suggests + end marker)
+   TFRewriteData Changes[6+2+OverItem->FieldOverride.size()+1];
+
    unsigned int End = 0;
    unsigned int End = 0;
-   for (End = 0; Changes[End].Tag != 0; End++);
-   
+   SetTFRewriteData(Changes[End++], "Size", Size);
+   SetTFRewriteData(Changes[End++], "MD5sum", MD5Res.c_str());
+   SetTFRewriteData(Changes[End++], "Filename", NewFileName.c_str());
+   SetTFRewriteData(Changes[End++], "Priority", OverItem->Priority.c_str());
+   SetTFRewriteData(Changes[End++], "Status", 0);
+   SetTFRewriteData(Changes[End++], "Optional", 0);
+
    // Rewrite the maintainer field if necessary
    // Rewrite the maintainer field if necessary
    bool MaintFailed;
    bool MaintFailed;
    string NewMaint = OverItem->SwapMaint(Tags.FindS("Maintainer"),MaintFailed);
    string NewMaint = OverItem->SwapMaint(Tags.FindS("Maintainer"),MaintFailed);
@@ -395,10 +411,7 @@ bool PackagesWriter::DoPackage(string FileName)
    }
    }
    
    
    if (NewMaint.empty() == false)
    if (NewMaint.empty() == false)
-   {
-      Changes[End].Rewrite = NewMaint.c_str();
-      Changes[End++].Tag = "Maintainer";
-   }
+      SetTFRewriteData(Changes[End++], "Maintainer", NewMaint.c_str());
    
    
    /* Get rid of the Optional tag. This is an ugly, ugly, ugly hack that
    /* Get rid of the Optional tag. This is an ugly, ugly, ugly hack that
       dpkg-scanpackages does.. Well sort of. dpkg-scanpackages just does renaming
       dpkg-scanpackages does.. Well sort of. dpkg-scanpackages just does renaming
@@ -410,10 +423,15 @@ bool PackagesWriter::DoPackage(string FileName)
    {
    {
       if (Tags.FindS("Suggests").empty() == false)
       if (Tags.FindS("Suggests").empty() == false)
 	 OptionalStr = Tags.FindS("Suggests") + ", " + OptionalStr;
 	 OptionalStr = Tags.FindS("Suggests") + ", " + OptionalStr;
-      Changes[End].Rewrite = OptionalStr.c_str();
-      Changes[End++].Tag = "Suggests";
+      SetTFRewriteData(Changes[End++], "Suggests", OptionalStr.c_str());
    }
    }
-   
+
+   for (map<string,string>::iterator I = OverItem->FieldOverride.begin(); 
+        I != OverItem->FieldOverride.end(); I++) 
+      SetTFRewriteData(Changes[End++],I->first.c_str(),I->second.c_str());
+
+   SetTFRewriteData(Changes[End++], 0, 0);
+
    // Rewrite and store the fields.
    // Rewrite and store the fields.
    if (TFRewrite(Output,Tags,TFRewritePackageOrder,Changes) == false)
    if (TFRewrite(Output,Tags,TFRewritePackageOrder,Changes) == false)
       return false;
       return false;
@@ -426,7 +444,8 @@ bool PackagesWriter::DoPackage(string FileName)
 // SourcesWriter::SourcesWriter - Constructor				/*{{{*/
 // SourcesWriter::SourcesWriter - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-SourcesWriter::SourcesWriter(string BOverrides,string SOverrides)
+SourcesWriter::SourcesWriter(string BOverrides,string SOverrides,
+			     string ExtOverrides)
 {
 {
    Output = stdout;
    Output = stdout;
    Ext[0] = ".dsc";
    Ext[0] = ".dsc";
@@ -443,11 +462,12 @@ SourcesWriter::SourcesWriter(string BOverrides,string SOverrides)
       return;
       return;
    else
    else
       NoOverride = true;
       NoOverride = true;
+
+   if (ExtOverrides.empty() == false)
+      SOver.ReadExtraOverride(ExtOverrides);
    
    
-   if (SOverrides.empty() == false && FileExists(SOverrides) == true &&
-       SOver.ReadOverride(SOverrides,true) == false)
-      return;
-//   _error->DumpErrors();
+   if (SOverrides.empty() == false && FileExists(SOverrides) == true)
+      SOver.ReadOverride(SOverrides,true);
 }
 }
 									/*}}}*/
 									/*}}}*/
 // SourcesWriter::DoPackage - Process a single package			/*{{{*/
 // SourcesWriter::DoPackage - Process a single package			/*{{{*/
@@ -615,16 +635,15 @@ bool SourcesWriter::DoPackage(string FileName)
       Directory.erase(Directory.end()-1);
       Directory.erase(Directory.end()-1);
       
       
    // This lists all the changes to the fields we are going to make.
    // This lists all the changes to the fields we are going to make.
-   TFRewriteData Changes[] = {{"Source",Package.c_str(),"Package"},
-                              {"Files",Files},
-                              {"Directory",Directory.c_str()},
-                              {"Section",SOverItem->Section.c_str()},
-                              {"Priority",BestPrio.c_str()},
-                              {"Status",0},
-                              {},  // For maintainer
-	                      {}};
+   // (5 hardcoded + maintainer + end marker)
+   TFRewriteData Changes[5+1+SOverItem->FieldOverride.size()+1];
+
    unsigned int End = 0;
    unsigned int End = 0;
-   for (End = 0; Changes[End].Tag != 0; End++);
+   SetTFRewriteData(Changes[End++],"Source",Package.c_str(),"Package");
+   SetTFRewriteData(Changes[End++],"Files",Files);
+   SetTFRewriteData(Changes[End++],"Directory",Directory.c_str());
+   SetTFRewriteData(Changes[End++],"Priority",BestPrio.c_str());
+   SetTFRewriteData(Changes[End++],"Status",0);
 
 
    // Rewrite the maintainer field if necessary
    // Rewrite the maintainer field if necessary
    bool MaintFailed;
    bool MaintFailed;
@@ -640,10 +659,13 @@ bool SourcesWriter::DoPackage(string FileName)
       }      
       }      
    }
    }
    if (NewMaint.empty() == false)
    if (NewMaint.empty() == false)
-   {
-      Changes[End].Rewrite = NewMaint.c_str();
-      Changes[End++].Tag = "Maintainer";
-   }
+      SetTFRewriteData(Changes[End++], "Maintainer", NewMaint.c_str());
+   
+   for (map<string,string>::iterator I = SOverItem->FieldOverride.begin(); 
+        I != SOverItem->FieldOverride.end(); I++) 
+      SetTFRewriteData(Changes[End++],I->first.c_str(),I->second.c_str());
+
+   SetTFRewriteData(Changes[End++], 0, 0);
       
       
    // Rewrite and store the fields.
    // Rewrite and store the fields.
    if (TFRewrite(Output,Tags,TFRewriteSourceOrder,Changes) == false)
    if (TFRewrite(Output,Tags,TFRewriteSourceOrder,Changes) == false)

+ 7 - 5
ftparchive/writer.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: writer.h,v 1.3 2001/05/29 04:08:09 jgg Exp $
+// $Id: writer.h,v 1.4 2001/06/26 02:50:27 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Writer 
    Writer 
@@ -20,6 +20,7 @@
 #include <string>
 #include <string>
 #include <stdio.h>
 #include <stdio.h>
 #include <iostream>
 #include <iostream>
+#include <vector>
 
 
 #include "cachedb.h"
 #include "cachedb.h"
 #include "override.h"
 #include "override.h"
@@ -90,9 +91,11 @@ class PackagesWriter : public FTWScanner
    struct CacheDB::Stats &Stats;
    struct CacheDB::Stats &Stats;
    
    
    inline bool ReadOverride(string File) {return Over.ReadOverride(File);};
    inline bool ReadOverride(string File) {return Over.ReadOverride(File);};
+   inline bool ReadExtraOverride(string File) 
+      {return Over.ReadExtraOverride(File);};
    virtual bool DoPackage(string FileName);
    virtual bool DoPackage(string FileName);
 
 
-   PackagesWriter(string DB,string Overrides);
+   PackagesWriter(string DB,string Overrides,string ExtOverrides=string());
    virtual ~PackagesWriter() {};
    virtual ~PackagesWriter() {};
 };
 };
 
 
@@ -138,11 +141,10 @@ class SourcesWriter : public FTWScanner
    FILE *Output;
    FILE *Output;
    struct CacheDB::Stats Stats;
    struct CacheDB::Stats Stats;
 
 
-/*   inline bool ReadBinOverride(string File) {return BOver.ReadOverride(File);};
-   bool ReadSrcOverride(string File); // {return BOver.ReadOverride(File);};*/
    virtual bool DoPackage(string FileName);
    virtual bool DoPackage(string FileName);
 
 
-   SourcesWriter(string BOverrides,string SOverrides);
+   SourcesWriter(string BOverrides,string SOverrides,
+		 string ExtOverrides=string());
    virtual ~SourcesWriter() {free(Buffer);};
    virtual ~SourcesWriter() {free(Buffer);};
 };
 };