- add --arch option for apt-ftparchive packages and contents commands
authorDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 17 Feb 2010 23:05:14 +0000 (00:05 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 17 Feb 2010 23:05:14 +0000 (00:05 +0100)
  - if an arch is given accept only *_all.deb and *_arch.deb instead
    of *.deb. Thanks Stephan Bosch for the patch! (Closes: #319710)

debian/changelog
doc/apt-ftparchive.1.xml
ftparchive/apt-ftparchive.cc
ftparchive/writer.cc
ftparchive/writer.h

index baa1fff..10cccda 100644 (file)
@@ -15,6 +15,9 @@ apt (0.7.26) UNRELEASED; urgency=low
     - allow also to skip the last patch if target is reached,
       thanks Bernhard R. Link! (Closes: #545699)
   * ftparchive/writer.{cc,h}:
+    - add --arch option for packages and contents commands
+    - if an arch is given accept only *_all.deb and *_arch.deb instead
+      of *.deb. Thanks Stephan Bosch for the patch! (Closes: #319710)
     - 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)
index eb61eae..f88dbe6 100644 (file)
@@ -39,6 +39,7 @@
       <arg><option>--delink</option></arg>
       <arg><option>--readonly</option></arg>
       <arg><option>--contents</option></arg>
+      <arg><option>--arch <replaceable>architecture</replaceable></option></arg>
       <arg><option>-o <replaceable>config</replaceable>=<replaceable>string</replaceable></option></arg>
       <arg><option>-c=<replaceable>file</replaceable></option></arg>      
       <group choice="req">
@@ -542,11 +543,18 @@ for i in Sections do
      <listitem><para>
      Make the caching databases read only. 
      Configuration Item: <literal>APT::FTPArchive::ReadOnlyDB</literal>.</para></listitem>
-     </varlistentry>   
+     </varlistentry>
+
+     <varlistentry><term><option>-a</option></term><term><option>--arch</option></term>
+     <listitem><para>Accept in the <literal>packages</literal> and <literal>contents</literal>
+     commands only package files matching <literal>*_arch.deb</literal> or
+     <literal>*_all.deb</literal> instead of all package files in the given path.
+     Configuration Item: <literal>APT::FTPArchive::Architecture</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
+     &apt-ftparchive; caches as much as possible of metadata in a 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.
index 5b6b394..f1a182e 100644 (file)
@@ -333,7 +333,7 @@ bool PackageMap::GenContents(Configuration &Setup,
    gettimeofday(&StartTime,0);   
    
    // Create a package writer object.
-   ContentsWriter Contents("");
+   ContentsWriter Contents("", Arch);
    if (PkgExt.empty() == false && Contents.SetExts(PkgExt) == false)
       return _error->Error(_("Package extension list is too long"));
    if (_error->PendingError() == true)
@@ -606,7 +606,7 @@ bool SimpleGenPackages(CommandLine &CmdL)
    
    // Create a package writer object.
    PackagesWriter Packages(_config->Find("APT::FTPArchive::DB"),
-                          Override, "");   
+                          Override, "", _config->Find("APT::FTPArchive::Architecture"));
    if (_error->PendingError() == true)
       return false;
    
@@ -629,7 +629,7 @@ bool SimpleGenContents(CommandLine &CmdL)
       return ShowHelp(CmdL);
    
    // Create a package writer object.
-   ContentsWriter Contents(_config->Find("APT::FTPArchive::DB"));
+   ContentsWriter Contents(_config->Find("APT::FTPArchive::DB"), _config->Find("APT::FTPArchive::Architecture"));
    if (_error->PendingError() == true)
       return false;
    
@@ -910,6 +910,7 @@ int main(int argc, const char *argv[])
       {0,"delink","APT::FTPArchive::DeLinkAct",0},
       {0,"readonly","APT::FTPArchive::ReadOnlyDB",0},
       {0,"contents","APT::FTPArchive::Contents",0},
+      {'a',"arch","APT::FTPArchive::Architecture",CommandLine::HasArg},
       {'c',"config-file",0,CommandLine::ConfigFile},
       {'o',"option",0,CommandLine::ArbItem},
       {0,0,0,0}};
index 18a3de0..9e5b7d4 100644 (file)
@@ -54,7 +54,7 @@ inline void SetTFRewriteData(struct TFRewriteData &tfrd,
 // FTWScanner::FTWScanner - Constructor                                        /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-FTWScanner::FTWScanner()
+FTWScanner::FTWScanner(string const &Arch): Arch(Arch)
 {
    ErrorPrinted = false;
    NoLinkAct = !_config->FindB("APT::FTPArchive::DeLinkAct",true);
@@ -299,12 +299,11 @@ bool FTWScanner::Delink(string &FileName,const char *OriginalPath,
 // ---------------------------------------------------------------------
 /* */
 PackagesWriter::PackagesWriter(string const &DB,string const &Overrides,string const &ExtOverrides,
-                              string const &aArch) :
-   Db(DB),Stats(Db.Stats), Arch(aArch)
+                              string const &Arch) :
+   FTWScanner(Arch), Db(DB), Stats(Db.Stats)
 {
    Output = stdout;
-   SetExts(".deb .udeb .foo .bar .baz");
-   AddPattern("*.deb");
+   SetExts(".deb .udeb");
    DeLinkLimit = 0;
    
    // Process the command line options
@@ -340,17 +339,16 @@ bool FTWScanner::SetExts(string const &Vals)
    string::size_type Start = 0;
    while (Start <= Vals.length()-1)
    {
-      string::size_type Space = Vals.find(' ',Start);
-      string::size_type Length;
-      if (Space == string::npos)
+      string::size_type const Space = Vals.find(' ',Start);
+      string::size_type const Length = ((Space == string::npos) ? Vals.length() : Space) - Start;
+      if ( Arch.empty() == false )
       {
-         Length = Vals.length()-Start;
+        AddPattern(string("*_") + Arch + Vals.substr(Start, Length));
+        AddPattern(string("*_all") + Vals.substr(Start, Length));
       }
       else
-      {
-         Length = Space-Start;
-      }
-      AddPattern(string("*") + Vals.substr(Start, Length));
+        AddPattern(string("*") + Vals.substr(Start, Length));
+
       Start += Length + 1;
    }
 
@@ -767,11 +765,11 @@ bool SourcesWriter::DoPackage(string FileName)
 // ContentsWriter::ContentsWriter - Constructor                                /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-ContentsWriter::ContentsWriter(string const &DB) : 
-                   Db(DB), Stats(Db.Stats)
+ContentsWriter::ContentsWriter(string const &DB, string const &Arch) :
+                   FTWScanner(Arch), Db(DB), Stats(Db.Stats)
 
 {
-   AddPattern("*.deb");
+   SetExts(".deb");
    Output = stdout;
 }
                                                                        /*}}}*/
index 520e91d..af7ba4e 100644 (file)
@@ -34,6 +34,7 @@ class FTWScanner
 {
    protected:
    vector<string> Patterns;
+   string Arch;
    const char *OriginalPath;
    bool ErrorPrinted;
    
@@ -68,7 +69,7 @@ class FTWScanner
    void AddPattern(string const &Pattern) { Patterns.push_back(Pattern); };
    bool SetExts(string const &Vals);
       
-   FTWScanner();
+   FTWScanner(string const &Arch = string());
 };
 
 class PackagesWriter : public FTWScanner
@@ -92,7 +93,6 @@ class PackagesWriter : public FTWScanner
    string DirStrip;
    FILE *Output;
    struct CacheDB::Stats &Stats;
-   string Arch;
 
    inline bool ReadOverride(string const &File) {return Over.ReadOverride(File);};
    inline bool ReadExtraOverride(string const &File) 
@@ -125,7 +125,7 @@ class ContentsWriter : public FTWScanner
    void Finish() {Gen.Print(Output);};
    inline bool ReadyDB(string const &DB) {return Db.ReadyDB(DB);};
    
-   ContentsWriter(string const &DB);
+   ContentsWriter(string const &DB, string const &Arch = string());
    virtual ~ContentsWriter() {};
 };