summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-01-31 22:32:45 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2016-01-31 23:24:59 +0100
commit5025879e3fdd705bb0607ff8f51a680749c5972a (patch)
tree373cff10f4b91ae2d33b23ef0f28461828c6031c /apt-pkg
parentaa3e7b3287a20b464237c869483111abc7e9d815 (diff)
support <libc>-<kernel>-<cpu> in architecture specs
APT has a different understanding than dpkg (#748936) what matches and what doesn't match an architecture specification as it isn't converting back (and forward) to Debian triplets. That has to eventually be solved some way or the other, but until that happens we change the matching in apt so that porters can continue their work on non-gnu libc-ports even if policy doesn't specify that yet (and dpkg just supporting it "by accident" via triplets). The initial patch was reformatted, fixed in terms of patterns containing "any-any", dealing with expanding an arch without libc to gnu while a pattern expands libc to any, the parsedepends test was fixed (the new if's were inserted one step too early) and another test just for the specifications added. Closes: #812212 Thanks: Bálint Réczey for initial patch
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/cachefilter.cc51
-rw-r--r--apt-pkg/cachefilter.h4
2 files changed, 37 insertions, 18 deletions
diff --git a/apt-pkg/cachefilter.cc b/apt-pkg/cachefilter.cc
index 4362f43e3..b1adf5de3 100644
--- a/apt-pkg/cachefilter.cc
+++ b/apt-pkg/cachefilter.cc
@@ -68,28 +68,47 @@ bool PackageNameMatchesFnmatch::operator() (pkgCache::GrpIterator const &Grp) {
return fnmatch(Pattern.c_str(), Grp.Name(), FNM_CASEFOLD) == 0;
}
/*}}}*/
-// Architecture matches <kernel>-<cpu> specification /*{{{*/
+// Architecture matches <libc>-<kernel>-<cpu> specification /*{{{*/
//----------------------------------------------------------------------
-/* The complete architecture, consisting of <kernel>-<cpu>. */
-static std::string CompleteArch(std::string const &arch) {
- if (arch.find('-') != std::string::npos) {
- // ensure that only -any- is replaced and not something like company-
- std::string complete = std::string("-").append(arch).append("-");
- complete = SubstVar(complete, "-any-", "-*-");
- complete = complete.substr(1, complete.size()-2);
- return complete;
- }
- else if (arch == "any") return "*-*";
- else return "linux-" + arch;
-}
-PackageArchitectureMatchesSpecification::PackageArchitectureMatchesSpecification(std::string const &pattern, bool const isPattern) :
- literal(pattern), complete(CompleteArch(pattern)), isPattern(isPattern) {
+/* The complete architecture, consisting of <libc>-<kernel>-<cpu>. */
+static std::string CompleteArch(std::string const &arch, bool const isPattern) {
+ auto const found = arch.find('-');
+ if (found != std::string::npos)
+ {
+ // ensure that only -any- is replaced and not something like company-
+ std::string complete = std::string("-").append(arch).append("-");
+ size_t pos = 0;
+ char const * const search = "-any-";
+ auto const search_len = strlen(search) - 2;
+ while((pos = complete.find(search, pos)) != std::string::npos) {
+ complete.replace(pos + 1, search_len, "*");
+ pos += 2;
+ }
+ complete = complete.substr(1, complete.size()-2);
+ if (arch.find('-', found+1) != std::string::npos)
+ // <libc>-<kernel>-<cpu> format
+ return complete;
+ // <kernel>-<cpu> format
+ else if (isPattern)
+ return "*-" + complete;
+ else
+ return "gnu-" + complete;
+ }
+ else if (arch == "any")
+ return "*-*-*";
+ else if (isPattern)
+ return "*-linux-" + arch;
+ else
+ return "gnu-linux-" + arch;
+}
+PackageArchitectureMatchesSpecification::PackageArchitectureMatchesSpecification(std::string const &pattern, bool const pisPattern) :
+ literal(pattern), complete(CompleteArch(pattern, pisPattern)), isPattern(pisPattern) {
}
bool PackageArchitectureMatchesSpecification::operator() (char const * const &arch) {
if (strcmp(literal.c_str(), arch) == 0 ||
strcmp(complete.c_str(), arch) == 0)
return true;
- std::string const pkgarch = CompleteArch(arch);
+ std::string const pkgarch = CompleteArch(arch, !isPattern);
if (isPattern == true)
return fnmatch(complete.c_str(), pkgarch.c_str(), 0) == 0;
return fnmatch(pkgarch.c_str(), complete.c_str(), 0) == 0;
diff --git a/apt-pkg/cachefilter.h b/apt-pkg/cachefilter.h
index 9970b5b22..30a3368e5 100644
--- a/apt-pkg/cachefilter.h
+++ b/apt-pkg/cachefilter.h
@@ -115,11 +115,11 @@ class PackageArchitectureMatchesSpecification : public PackageMatcher { /*{{{*/
/** \class PackageArchitectureMatchesSpecification
\brief matching against architecture specification strings
- The strings are of the format <kernel>-<cpu> where either component,
+ The strings are of the format <libc>-<kernel>-<cpu> where either component,
or the whole string, can be the wildcard "any" as defined in
debian-policy §11.1 "Architecture specification strings".
- Examples: i386, mipsel, linux-any, any-amd64, any */
+ Examples: i386, mipsel, musl-linux-amd64, linux-any, any-amd64, any */
std::string literal;
std::string complete;
bool isPattern;