[PATCH] Bug in apt-ftparchive when scanning packages for different architectures in the same pool dir
Hi APT Development Team,
I noticed that running `apt-ftparchive generate' produces Packages files
with multiple architectures in the same Packages file when the packages
for different architectures all reside in the same pool directory. The
low-level dpkg-scanpackages tool handles this situation properly because
it scans for *_arch.deb and *_all.deb in stead of simply *.deb when a -a
parameter is specified. The apt-ftparchive tool apparently does not work
that way now.
I patched apt 0.7.25.3 to fix this. The patch is attached. Please
consider merging this patch (or your own fix) in a subsequent release.
Regards,
Stephan.
diff -uNr apt-0.7.25.3.old/ftparchive/apt-ftparchive.cc apt-0.7.25.3.new/ftparchive/apt-ftparchive.cc
--- apt-0.7.25.3.old/ftparchive/apt-ftparchive.cc 2010-02-01 20:44:41.000000000 +0100
+++ apt-0.7.25.3.new/ftparchive/apt-ftparchive.cc 2010-02-07 19:49:42.000000000 +0100
@@ -333,7 +333,7 @@
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)
diff -uNr apt-0.7.25.3.old/ftparchive/writer.cc apt-0.7.25.3.new/ftparchive/writer.cc
--- apt-0.7.25.3.old/ftparchive/writer.cc 2010-02-01 20:44:41.000000000 +0100
+++ apt-0.7.25.3.new/ftparchive/writer.cc 2010-02-07 19:51:07.000000000 +0100
@@ -54,7 +54,7 @@
// FTWScanner::FTWScanner - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-FTWScanner::FTWScanner()
+FTWScanner::FTWScanner(string aArch): Arch(aArch)
{
ErrorPrinted = false;
NoLinkAct = !_config->FindB("APT::FTPArchive::DeLinkAct",true);
@@ -300,11 +300,10 @@
/* */
PackagesWriter::PackagesWriter(string DB,string Overrides,string ExtOverrides,
string aArch) :
- Db(DB),Stats(Db.Stats), Arch(aArch)
+ FTWScanner(aArch), 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
@@ -349,14 +348,22 @@
{
Length = Space-Start;
}
- AddPattern(string("*") + Vals.substr(Start, Length));
+ if ( Arch != "" )
+ {
+ AddPattern(string("*_") + Arch + Vals.substr(Start, Length));
+ AddPattern(string("*_all") + Vals.substr(Start, Length));
+ }
+ else
+ {
+ AddPattern(string("*") + Vals.substr(Start, Length));
+ }
Start += Length + 1;
}
return true;
}
+ /*}}}*/
- /*}}}*/
// PackagesWriter::DoPackage - Process a single package /*{{{*/
// ---------------------------------------------------------------------
/* This method takes a package and gets its control information and
@@ -766,8 +773,8 @@
// ContentsWriter::ContentsWriter - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-ContentsWriter::ContentsWriter(string DB) :
- Db(DB), Stats(Db.Stats)
+ContentsWriter::ContentsWriter(string DB, string aArch) :
+ FTWScanner(aArch), Db(DB), Stats(Db.Stats)
{
AddPattern("*.deb");
diff -uNr apt-0.7.25.3.old/ftparchive/writer.h apt-0.7.25.3.new/ftparchive/writer.h
--- apt-0.7.25.3.old/ftparchive/writer.h 2010-02-01 20:44:41.000000000 +0100
+++ apt-0.7.25.3.new/ftparchive/writer.h 2010-02-07 19:49:42.000000000 +0100
@@ -36,6 +36,8 @@
vector<string> Patterns;
const char *OriginalPath;
bool ErrorPrinted;
+
+ string Arch;
// Stuff for the delinker
bool NoLinkAct;
@@ -68,7 +70,7 @@
void AddPattern(string Pattern) { Patterns.push_back(Pattern); };
bool SetExts(string Vals);
- FTWScanner();
+ FTWScanner(string aArch=string());
};
class PackagesWriter : public FTWScanner
@@ -91,7 +93,6 @@
string DirStrip;
FILE *Output;
struct CacheDB::Stats &Stats;
- string Arch;
inline bool ReadOverride(string File) {return Over.ReadOverride(File);};
inline bool ReadExtraOverride(string File)
@@ -99,7 +100,7 @@
virtual bool DoPackage(string FileName);
PackagesWriter(string DB,string Overrides,string ExtOverrides=string(),
- string Arch=string());
+ string aArch=string());
virtual ~PackagesWriter() {};
};
@@ -124,7 +125,7 @@
void Finish() {Gen.Print(Output);};
inline bool ReadyDB(string DB) {return Db.ReadyDB(DB);};
- ContentsWriter(string DB);
+ ContentsWriter(string DB, string aArch=string());
virtual ~ContentsWriter() {};
};
Reply to: