Sets the binary override file. The override file
contains section, priority and maintainer address information.
</VarListEntry>
-
+
<VarListEntry><term>SrcOverride</term>
<ListItem><Para>
Sets the source override file. The override file
contains section information.
</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>
</refsect2>
Sets the Contents file output. (Optional)
</VarListEntry>
- <VarListEntry><term>Binoverride</term>
+ <VarListEntry><term>BinOverride</term>
<ListItem><Para>
Sets the binary override file.
</VarListEntry>
Sets the source override file.
</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>
<ListItem><Para>
Sets the cache DB.
package name, the second is the section to assign it.
</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</>
&apt-cmdblurb;
// -*- mode: cpp; mode: fold -*-
// 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
string PkgFile;
string BinCacheDB;
string BinOverride;
+ string ExtraOverride;
// Stuff for the Source File
string SrcFile;
string SrcOverride;
+ string SrcExtraOverride;
// Contents
string Contents;
// Create a package writer object.
PackagesWriter Packages(flCombine(CacheDir,BinCacheDB),
- flCombine(OverrideDir,BinOverride));
+ flCombine(OverrideDir,BinOverride),
+ flCombine(OverrideDir,ExtraOverride));
if (PkgExt.empty() == false && Packages.SetExts(PkgExt) == false)
return _error->Error("Package extension list is too long");
if (_error->PendingError() == true)
Packages.Stats.DeLinkBytes = Stats.DeLinkBytes;
Packages.DeLinkLimit = DeLinkLimit;
-
+
// Create a compressor object
MultiCompress Comp(flCombine(ArchiveDir,PkgFile),
PkgCompress,Permissions);
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. */
bool PackageMap::GenSources(Configuration &Setup,struct CacheDB::Stats &Stats)
// Create a package writer object.
SourcesWriter Sources(flCombine(OverrideDir,BinOverride),
- flCombine(OverrideDir,SrcOverride));
+ flCombine(OverrideDir,SrcOverride),
+ flCombine(OverrideDir,SrcExtraOverride));
if (SrcExt.empty() == false && Sources.SetExts(SrcExt) == false)
return _error->Error("Source extension list is too long");
if (_error->PendingError() == true)
Itm.SrcFile = SubstVar(Block.Find("Sources",DSources.c_str()),Vars);
Itm.Tag = SubstVar("$(DIST)/$(SECTION)/source",Vars);
Itm.FLFile = SubstVar(Block.Find("SourceFileList",DSFLFile.c_str()),Vars);
+ Itm.SrcExtraOverride = SubstVar(Block.Find("SrcExtraOverride"),Vars);
}
else
{
Itm.Contents = SubstVar(Block.Find("Contents",DContents.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.ExtraOverride = SubstVar(Block.Find("ExtraOverride"),Vars);
}
Itm.GetGeneral(Setup,Block);
Itm.SrcFile = Block.Find("Sources");
Itm.BinCacheDB = Block.Find("BinCacheDB");
Itm.BinOverride = Block.Find("BinOverride");
+ Itm.ExtraOverride = Block.Find("ExtraOverride");
+ Itm.SrcExtraOverride = Block.Find("SrcExtraOverride");
Itm.SrcOverride = Block.Find("SrcOverride");
Itm.BaseDir = Top->Tag;
Itm.FLFile = Block.Find("FileList");
// Create a package writer object.
PackagesWriter Packages(_config->Find("APT::FTPArchive::DB"),
- Override);
+ Override, "");
if (_error->PendingError() == true)
return false;
// -*- mode: cpp; mode: fold -*-
// 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
continue;
}
*End = 0;
- Itm.Section = Start;
+ Itm.FieldOverride["Section"] = Start;
// Source override files only have the two columns
if (Source == true)
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))
_error->Errno("fgets","Failed to read the override file %s",File.c_str());
fclose(F);
// -*- mode: cpp; mode: fold -*-
// 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
struct Item
{
string Priority;
- string Section;
string OldMaint;
string NewMaint;
-
+
+ map<string,string> FieldOverride;
string SwapMaint(string Orig,bool &Failed);
};
};
bool ReadOverride(string File,bool Source = false);
+ bool ReadExtraOverride(string File,bool Source = false);
};
-
+
#endif
// -*- mode: cpp; mode: fold -*-
// 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
using namespace std;
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 /*{{{*/
// ---------------------------------------------------------------------
/* */
// PackagesWriter::PackagesWriter - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-PackagesWriter::PackagesWriter(string DB,string Overrides) :
+PackagesWriter::PackagesWriter(string DB,string Overrides,string ExtOverrides) :
Db(DB),Stats(Db.Stats)
{
Output = stdout;
if (Db.Loaded() == false)
DoContents = false;
-
+
// Read the override file
if (Overrides.empty() == false && Over.ReadOverride(Overrides) == false)
return;
else
NoOverride = true;
+
+ if (ExtOverrides.empty() == false)
+ Over.ReadExtraOverride(ExtOverrides);
+
_error->DumpErrors();
}
/*}}}*/
}
OverItem = &Tmp;
- Tmp.Section = Tags.FindS("Section");
+ Tmp.FieldOverride["Section"] = Tags.FindS("Section");
Tmp.Priority = Tags.FindS("Priority");
}
NewFileName = flCombine(PathPrefix,NewFileName);
// 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;
- 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
bool MaintFailed;
string NewMaint = OverItem->SwapMaint(Tags.FindS("Maintainer"),MaintFailed);
}
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
dpkg-scanpackages does.. Well sort of. dpkg-scanpackages just does renaming
{
if (Tags.FindS("Suggests").empty() == false)
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.
if (TFRewrite(Output,Tags,TFRewritePackageOrder,Changes) == false)
return false;
// SourcesWriter::SourcesWriter - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-SourcesWriter::SourcesWriter(string BOverrides,string SOverrides)
+SourcesWriter::SourcesWriter(string BOverrides,string SOverrides,
+ string ExtOverrides)
{
Output = stdout;
Ext[0] = ".dsc";
return;
else
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 /*{{{*/
Directory.erase(Directory.end()-1);
// 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;
- 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
bool MaintFailed;
}
}
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.
if (TFRewrite(Output,Tags,TFRewriteSourceOrder,Changes) == false)
// -*- mode: cpp; mode: fold -*-
// 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
#include <string>
#include <stdio.h>
#include <iostream>
+#include <vector>
#include "cachedb.h"
#include "override.h"
struct CacheDB::Stats &Stats;
inline bool ReadOverride(string File) {return Over.ReadOverride(File);};
+ inline bool ReadExtraOverride(string File)
+ {return Over.ReadExtraOverride(File);};
virtual bool DoPackage(string FileName);
- PackagesWriter(string DB,string Overrides);
+ PackagesWriter(string DB,string Overrides,string ExtOverrides=string());
virtual ~PackagesWriter() {};
};
FILE *Output;
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);
- SourcesWriter(string BOverrides,string SOverrides);
+ SourcesWriter(string BOverrides,string SOverrides,
+ string ExtOverrides=string());
virtual ~SourcesWriter() {free(Buffer);};
};