summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorJohannes Schauer <j.schauer@email.de>2014-02-25 00:12:20 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-03-13 13:57:34 +0100
commit565ded7b65240b25ad8551789ac388c8ce72b1f4 (patch)
tree81025637a5e03dcd4f06018a83551161adfb03b1 /apt-pkg/deb
parenta5414e56403537678d5be87acf59c37a05f55719 (diff)
implement BuildProfileSpec support as dpkg has in 1.17.2
Build-dependencies are now able to include a <profile.foo …> specification limiting usage similar to already supported [arch …]. More details: https://wiki.debian.org/BuildProfileSpec Closes: 661537
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/deblistparser.cc91
-rw-r--r--apt-pkg/deb/deblistparser.h17
-rw-r--r--apt-pkg/deb/debsrcrecords.cc2
3 files changed, 101 insertions, 9 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index acdcc4554..a4795f15d 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -475,17 +475,30 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
/* This parses the dependency elements out of a standard string in place,
bit by bit. */
const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op)
+ { return ParseDepends(Start, Stop, Package, Ver, Op, false, true, false); }
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags)
+ { return ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags, true, false); }
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags, bool const &StripMultiArch)
+ { return ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags, StripMultiArch, false); }
+const char *debListParser::ParseDepends(const char *Start,const char *Stop,
string &Package,string &Ver,
unsigned int &Op, bool const &ParseArchFlags,
- bool const &StripMultiArch)
+ bool const &StripMultiArch,
+ bool const &ParseRestrictionsList)
{
// Strip off leading space
- for (;Start != Stop && isspace(*Start) != 0; Start++);
+ for (;Start != Stop && isspace(*Start) != 0; ++Start);
// Parse off the package name
const char *I = Start;
for (;I != Stop && isspace(*I) == 0 && *I != '(' && *I != ')' &&
- *I != ',' && *I != '|' && *I != '[' && *I != ']'; I++);
+ *I != ',' && *I != '|' && *I != '[' && *I != ']' &&
+ *I != '<' && *I != '>'; ++I);
// Malformed, no '('
if (I != Stop && *I == ')')
@@ -602,6 +615,76 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
for (;I != Stop && isspace(*I) != 0; I++);
}
+ if (ParseRestrictionsList == true)
+ {
+ // Parse a restrictions list
+ if (I != Stop && *I == '<')
+ {
+ ++I;
+ // malformed
+ if (unlikely(I == Stop))
+ return 0;
+
+ std::vector<string> const profiles = _config->FindVector("APT::Build-Profiles");
+
+ const char *End = I;
+ bool Found = false;
+ bool NegRestriction = false;
+ while (I != Stop)
+ {
+ // look for whitespace or ending '>'
+ for (;End != Stop && !isspace(*End) && *End != '>'; ++End);
+
+ if (unlikely(End == Stop))
+ return 0;
+
+ if (*I == '!')
+ {
+ NegRestriction = true;
+ ++I;
+ }
+
+ std::string restriction(I, End);
+
+ std::string prefix = "profile.";
+ // only support for "profile" prefix, ignore others
+ if (restriction.size() > prefix.size() &&
+ restriction.substr(0, prefix.size()) == prefix)
+ {
+ // get the name of the profile
+ restriction = restriction.substr(prefix.size());
+
+ if (restriction.empty() == false && profiles.empty() == false &&
+ std::find(profiles.begin(), profiles.end(), restriction) != profiles.end())
+ {
+ Found = true;
+ if (I[-1] != '!')
+ NegRestriction = false;
+ // we found a match, so fast-forward to the end of the wildcards
+ for (; End != Stop && *End != '>'; ++End);
+ }
+ }
+
+ if (*End++ == '>') {
+ I = End;
+ break;
+ }
+
+ I = End;
+ for (;I != Stop && isspace(*I) != 0; I++);
+ }
+
+ if (NegRestriction == true)
+ Found = !Found;
+
+ if (Found == false)
+ Package = ""; /* not for this restriction */
+ }
+
+ // Skip whitespace
+ for (;I != Stop && isspace(*I) != 0; I++);
+ }
+
if (I != Stop && *I == '|')
Op |= pkgCache::Dep::Or;
@@ -635,7 +718,7 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
string Version;
unsigned int Op;
- Start = ParseDepends(Start, Stop, Package, Version, Op, false, false);
+ Start = ParseDepends(Start, Stop, Package, Version, Op, false, false, false);
if (Start == 0)
return _error->Error("Problem parsing dependency %s",Tag);
size_t const found = Package.rfind(':');
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 386d291a2..0531b20f3 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -72,11 +72,20 @@ class debListParser : public pkgCacheGenerator::ListParser
bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File,
std::string section);
-
+
+ static const char *ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op);
static const char *ParseDepends(const char *Start,const char *Stop,
- std::string &Package,std::string &Ver,unsigned int &Op,
- bool const &ParseArchFlags = false,
- bool const &StripMultiArch = true);
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags);
+ static const char *ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags, bool const &StripMultiArch);
+ static const char *ParseDepends(const char *Start,const char *Stop,
+ std::string &Package,std::string &Ver,unsigned int &Op,
+ bool const &ParseArchFlags, bool const &StripMultiArch,
+ bool const &ParseRestrictionsList);
+
static const char *ConvertRelation(const char *I,unsigned int &Op);
debListParser(FileFd *File, std::string const &Arch = "");
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index ce55ccd1f..90182b4a4 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -90,7 +90,7 @@ bool debSrcRecordParser::BuildDepends(std::vector<pkgSrcRecords::Parser::BuildDe
while (1)
{
Start = debListParser::ParseDepends(Start, Stop,
- rec.Package,rec.Version,rec.Op,true, StripMultiArch);
+ rec.Package,rec.Version,rec.Op,true,StripMultiArch,true);
if (Start == 0)
return _error->Error("Problem parsing dependency: %s", fields[I]);