diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2009-11-29 00:23:26 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2009-11-29 00:23:26 +0100 |
commit | 41c81fd85d43ed747375d8f1ee7a9b71fb3c7016 (patch) | |
tree | f975f84ddd0c5664523dfbb33b0cf9748f42b177 | |
parent | 9c562bc9357c1e5bf566110fe30265dcdfd815fd (diff) |
Ignore :qualifiers after package name in build dependencies
for now as long we don't understand them (Closes: #558103)
-rw-r--r-- | apt-pkg/deb/deblistparser.cc | 12 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.h | 3 | ||||
-rw-r--r-- | apt-pkg/deb/debsrcrecords.cc | 5 | ||||
-rw-r--r-- | apt-pkg/deb/debsrcrecords.h | 6 | ||||
-rw-r--r-- | apt-pkg/srcrecords.cc | 4 | ||||
-rw-r--r-- | apt-pkg/srcrecords.h | 8 | ||||
-rw-r--r-- | debian/changelog | 8 | ||||
-rw-r--r-- | test/libapt/makefile | 6 | ||||
-rw-r--r-- | test/libapt/parsedepends_test.cc | 128 |
9 files changed, 163 insertions, 17 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 16e6ee332..25a1df3f9 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -395,7 +395,8 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op) bit by bit. */ const char *debListParser::ParseDepends(const char *Start,const char *Stop, string &Package,string &Ver, - unsigned int &Op, bool ParseArchFlags) + unsigned int &Op, bool const &ParseArchFlags, + bool const &StripMultiArch) { // Strip off leading space for (;Start != Stop && isspace(*Start) != 0; Start++); @@ -414,7 +415,14 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, // Stash the package name Package.assign(Start,I - Start); - + + // We don't want to confuse library users which can't handle MultiArch + if (StripMultiArch == true) { + size_t const found = Package.rfind(':'); + if (found != string::npos) + Package = Package.substr(0,found); + } + // Skip white space to the '(' for (;I != Stop && isspace(*I) != 0 ; I++); diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 34bb29c72..1c709229f 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -64,7 +64,8 @@ class debListParser : public pkgCacheGenerator::ListParser static const char *ParseDepends(const char *Start,const char *Stop, string &Package,string &Ver,unsigned int &Op, - bool ParseArchFlags = false); + bool const &ParseArchFlags = false, + bool const &StripMultiArch = false); static const char *ConvertRelation(const char *I,unsigned int &Op); debListParser(FileFd *File); diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index bde10aa6d..21336e1af 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -54,7 +54,8 @@ const char **debSrcRecordParser::Binaries() package/version records representing the build dependency. The returned array need not be freed and will be reused by the next call to this function */ -bool debSrcRecordParser::BuildDepends(vector<pkgSrcRecords::Parser::BuildDepRec> &BuildDeps, bool ArchOnly) +bool debSrcRecordParser::BuildDepends(vector<pkgSrcRecords::Parser::BuildDepRec> &BuildDeps, + bool const &ArchOnly, bool const &StripMultiArch) { unsigned int I; const char *Start, *Stop; @@ -77,7 +78,7 @@ bool debSrcRecordParser::BuildDepends(vector<pkgSrcRecords::Parser::BuildDepRec> while (1) { Start = debListParser::ParseDepends(Start, Stop, - rec.Package,rec.Version,rec.Op,true); + rec.Package,rec.Version,rec.Op,true, StripMultiArch); if (Start == 0) return _error->Error("Problem parsing dependency: %s", fields[I]); diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h index a3b5a8286..c39d78bae 100644 --- a/apt-pkg/deb/debsrcrecords.h +++ b/apt-pkg/deb/debsrcrecords.h @@ -30,14 +30,14 @@ class debSrcRecordParser : public pkgSrcRecords::Parser virtual bool Restart() {return Tags.Jump(Sect,0);}; virtual bool Step() {iOffset = Tags.Offset(); return Tags.Step(Sect);}; - virtual bool Jump(unsigned long Off) {iOffset = Off; return Tags.Jump(Sect,Off);}; + virtual bool Jump(unsigned long const &Off) {iOffset = Off; return Tags.Jump(Sect,Off);}; virtual string Package() const {return Sect.FindS("Package");}; virtual string Version() const {return Sect.FindS("Version");}; virtual string Maintainer() const {return Sect.FindS("Maintainer");}; virtual string Section() const {return Sect.FindS("Section");}; virtual const char **Binaries(); - virtual bool BuildDepends(vector<BuildDepRec> &BuildDeps, bool ArchOnly); + virtual bool BuildDepends(vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true); virtual unsigned long Offset() {return iOffset;}; virtual string AsStr() { @@ -47,7 +47,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser }; virtual bool Files(vector<pkgSrcRecords::File> &F); - debSrcRecordParser(string File,pkgIndexFile const *Index) + debSrcRecordParser(string const &File,pkgIndexFile const *Index) : Parser(Index), Fd(File,FileFd::ReadOnly), Tags(&Fd,102400), Buffer(0), BufSize(0) {} ~debSrcRecordParser(); diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 5e40ae624..46a02b55c 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -77,7 +77,7 @@ bool pkgSrcRecords::Restart() /* This searches on both source package names and output binary names and returns the first found. A 'cursor' like system is used to allow this function to be called multiple times to get successive entries */ -pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool SrcOnly) +pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool const &SrcOnly) { if (Current == Files.end()) return 0; @@ -116,7 +116,7 @@ pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool SrcOnly) // Parser::BuildDepType - Convert a build dep to a string /*{{{*/ // --------------------------------------------------------------------- /* */ -const char *pkgSrcRecords::Parser::BuildDepType(unsigned char Type) +const char *pkgSrcRecords::Parser::BuildDepType(unsigned char const &Type) { const char *fields[] = {"Build-Depends", "Build-Depends-Indep", diff --git a/apt-pkg/srcrecords.h b/apt-pkg/srcrecords.h index 99cbc6060..a49533864 100644 --- a/apt-pkg/srcrecords.h +++ b/apt-pkg/srcrecords.h @@ -59,7 +59,7 @@ class pkgSrcRecords virtual bool Restart() = 0; virtual bool Step() = 0; - virtual bool Jump(unsigned long Off) = 0; + virtual bool Jump(unsigned long const &Off) = 0; virtual unsigned long Offset() = 0; virtual string AsStr() = 0; @@ -69,8 +69,8 @@ class pkgSrcRecords virtual string Section() const = 0; virtual const char **Binaries() = 0; // Ownership does not transfer - virtual bool BuildDepends(vector<BuildDepRec> &BuildDeps, bool ArchOnly) = 0; - static const char *BuildDepType(unsigned char Type); + virtual bool BuildDepends(vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0; + static const char *BuildDepType(unsigned char const &Type); virtual bool Files(vector<pkgSrcRecords::File> &F) = 0; @@ -90,7 +90,7 @@ class pkgSrcRecords bool Restart(); // Locate a package by name - Parser *Find(const char *Package,bool SrcOnly = false); + Parser *Find(const char *Package,bool const &SrcOnly = false); pkgSrcRecords(pkgSourceList &List); ~pkgSrcRecords(); diff --git a/debian/changelog b/debian/changelog index 03411832c..056e5c1f7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,9 +19,11 @@ apt (0.7.25) UNRELEASED; urgency=low Closes: #555797 [ David Kalnischkies ] - * [BREAK] add possibility to download and use multiply - Translation files, configurable with Acquire::Translation - (Closes: #444222, #448216, #550564) + * [BREAK] add possibility to download and use multiply + Translation files, configurable with Acquire::Translation + (Closes: #444222, #448216, #550564) + * Ignore :qualifiers after package name in build dependencies + for now as long we don't understand them (Closes: #558103) * apt-pkg/packagemanager.cc: - better debug output for ImmediateAdd with depth and why - improve the message shown for failing immediate configuration diff --git a/test/libapt/makefile b/test/libapt/makefile index f61a95f3d..5712c025a 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -11,3 +11,9 @@ PROGRAM = getLanguages${BASENAME} SLIBS = -lapt-pkg SOURCE = getlanguages_test.cc include $(PROGRAM_H) + +# Program for testing ParseDepends +PROGRAM = ParseDepends${BASENAME} +SLIBS = -lapt-pkg +SOURCE = parsedepends_test.cc +include $(PROGRAM_H) diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc new file mode 100644 index 000000000..b7befa561 --- /dev/null +++ b/test/libapt/parsedepends_test.cc @@ -0,0 +1,128 @@ +#include <apt-pkg/deblistparser.h> +#include <apt-pkg/configuration.h> + +#include "assert.h" + +int main(int argc,char *argv[]) { + string Package; + string Version; + unsigned int Op = 5; + unsigned int Null = 0; + bool StripMultiArch = true; + bool ParseArchFlags = false; + _config->Set("APT::Architecture","dsk"); + + const char* Depends = + "debhelper:any (>= 5.0), " + "libdb-dev:any, " + "gettext:native (<= 0.12), " + "libcurl4-gnutls-dev:native | libcurl3-gnutls-dev (>> 7.15.5), " + "debiandoc-sgml, " + "apt (>= 0.7.25), " + "not-for-me [ !dsk ], " + "only-for-me [ dsk ], " + "overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), " + ; + + unsigned short runner = 0; +test: +// std::clog << (StripMultiArch ? "NO-Multi" : "Multi") << " " << (ParseArchFlags ? "Flags" : "NO-Flags") << std::endl; + + // Stripping MultiArch is currently the default setting to not confuse + // non-MultiArch capable users of the library with "strange" extensions. + const char* Start = Depends; + const char* End = Depends + strlen(Depends); + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + if (StripMultiArch == true) + equals("debhelper", Package); + else + equals("debhelper:any", Package); + equals("5.0", Version); + equals(Null | pkgCache::Dep::GreaterEq, Op); + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + if (StripMultiArch == true) + equals("libdb-dev", Package); + else + equals("libdb-dev:any", Package); + equals("", Version); + equals(Null | pkgCache::Dep::NoOp, Op); + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + if (StripMultiArch == true) + equals("gettext", Package); + else + equals("gettext:native", Package); + equals("0.12", Version); + equals(Null | pkgCache::Dep::LessEq, Op); + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + if (StripMultiArch == true) + equals("libcurl4-gnutls-dev", Package); + else + equals("libcurl4-gnutls-dev:native", Package); + equals("", Version); + equals(Null | pkgCache::Dep::Or, Op); + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + equals("libcurl3-gnutls-dev", Package); + equals("7.15.5", Version); + equals(Null | pkgCache::Dep::Greater, Op); + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + equals("debiandoc-sgml", Package); + equals("", Version); + equals(Null | pkgCache::Dep::NoOp, Op); + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + equals("apt", Package); + equals("0.7.25", Version); + equals(Null | pkgCache::Dep::GreaterEq, Op); + + if (ParseArchFlags == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + equals("", Package); // not-for-me + } else { + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + Start = strstr(Start, ","); + Start++; + } + + if (ParseArchFlags == true) { + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + equals("only-for-me", Package); + equals("", Version); + equals(Null | pkgCache::Dep::NoOp, Op); + } else { + equals(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch)); + Start = strstr(Start, ","); + Start++; + } + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + if (StripMultiArch == true) + equals("overlord-dev", Package); + else + equals("overlord-dev:any", Package); + equals("7.15.3~", Version); + equals(Null | pkgCache::Dep::Equals | pkgCache::Dep::Or, Op); + + Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch); + if (StripMultiArch == true) + equals("overlord-dev", Package); + else + equals("overlord-dev:native", Package); + equals("7.15.5", Version); + equals(Null | pkgCache::Dep::Greater, Op); + + if (StripMultiArch == false) + ParseArchFlags = true; + StripMultiArch = !StripMultiArch; + + runner++; + if (runner < 4) + goto test; // this is the prove: tests are really evil ;) + + return 0; +} |