Browse Source

Ignore :qualifiers after package name in build dependencies

for now as long we don't understand them (Closes: #558103)
tags/debian/0.8.0
David Kalnischkies 12 years ago
parent
commit
41c81fd85d
9 changed files with 163 additions and 17 deletions
  1. +10
    -2
      apt-pkg/deb/deblistparser.cc
  2. +2
    -1
      apt-pkg/deb/deblistparser.h
  3. +3
    -2
      apt-pkg/deb/debsrcrecords.cc
  4. +3
    -3
      apt-pkg/deb/debsrcrecords.h
  5. +2
    -2
      apt-pkg/srcrecords.cc
  6. +4
    -4
      apt-pkg/srcrecords.h
  7. +5
    -3
      debian/changelog
  8. +6
    -0
      test/libapt/makefile
  9. +128
    -0
      test/libapt/parsedepends_test.cc

+ 10
- 2
apt-pkg/deb/deblistparser.cc View File

@@ -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++);


+ 2
- 1
apt-pkg/deb/deblistparser.h View File

@@ -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);


+ 3
- 2
apt-pkg/deb/debsrcrecords.cc View File

@@ -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]);


+ 3
- 3
apt-pkg/deb/debsrcrecords.h View File

@@ -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();


+ 2
- 2
apt-pkg/srcrecords.cc View File

@@ -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",


+ 4
- 4
apt-pkg/srcrecords.h View File

@@ -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();


+ 5
- 3
debian/changelog View File

@@ -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


+ 6
- 0
test/libapt/makefile View File

@@ -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)

+ 128
- 0
test/libapt/parsedepends_test.cc View File

@@ -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;
}

Loading…
Cancel
Save