diff options
author | Julian Andres Klode <jak@debian.org> | 2017-01-17 00:08:16 +0100 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2017-01-17 01:43:50 +0100 |
commit | 6ede8952f55a1bc356b42b1adc7b9bd504af943c (patch) | |
tree | 4cc3971fe0ad8ca7fc789f21033e4a1f89585d77 /test | |
parent | c5b8afab0f409b06a63599ff1c5acb433f3957d4 (diff) |
Read dpkg tables to handle architecture wildcards
Our implementation of wildcards was rudimentary. It worked for some
common ones, but it was also broken: For example, armel matched any-armel,
but should match any-arm.
With this commit, we load the correct tables from dpkg. Supported are
both triplets and quadruplet tables (the latter introduced in dpkg 1.18.11).
There are some odd things we have to deal with in the cache filter for
historical and API reasons:
* The character "*" must be accepted as an alternative to any - in fact
it may appear anywhere in the wildcard as we also allow fnmatch() style
wildcard matching on the commandline.
* The code might get passed an arch with a minus at the end, for example
the cmdline "install apt:any-arm-" will first try to check if any-arm-
is a valid architecture. We deal with this by rejecting any wildcard
ending in a minus.
* Triplets are actually implemented by extending them to faux quadruplets
- by prepending a "base" component for the architecture tuple, and "any"
if there is a wildcard component.
Once we have constructed a wildcard, it is transformed into an fnmatch()
expression for historical reasons. In the future, we should really get a
tuple class and implement matching in a better, more explicit way.
This does for now though - it passes all the test cases and accepts all
things it should accept.
Closes: #748936
Thanks: James Clarke <jrtc27@jrtc27.com> for the initial patch
Diffstat (limited to 'test')
-rwxr-xr-x | test/integration/test-bug-632221-cross-dependency-satisfaction | 2 | ||||
-rw-r--r-- | test/libapt/cachefilter_test.cc | 97 |
2 files changed, 76 insertions, 23 deletions
diff --git a/test/integration/test-bug-632221-cross-dependency-satisfaction b/test/integration/test-bug-632221-cross-dependency-satisfaction index 066e29d99..d52652cad 100755 --- a/test/integration/test-bug-632221-cross-dependency-satisfaction +++ b/test/integration/test-bug-632221-cross-dependency-satisfaction @@ -21,7 +21,7 @@ insertpackage 'unstable' 'foreigner' 'amd64,armel' '1.0' 'Multi-Arch: foreign' insertpackage 'unstable' 'arm-stuff' 'armel' '1.0' insertpackage 'unstable' 'linux-stuff' 'amd64,armel' '1.0' -insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner, libfwibble-dev, arm-stuff [any-armel] | linux-stuff [ linux-any]' +insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner, libfwibble-dev, arm-stuff [eabi-any-any-arm gnueabi-any-arm] | linux-stuff [ linux-any]' insertsource 'unstable' 'forbidden-no' 'any' '1' 'Build-Depends: amdboot:any' insertsource 'unstable' 'forbidden-same' 'any' '1' 'Build-Depends: libc6:any' diff --git a/test/libapt/cachefilter_test.cc b/test/libapt/cachefilter_test.cc index 28924b758..08812e0dc 100644 --- a/test/libapt/cachefilter_test.cc +++ b/test/libapt/cachefilter_test.cc @@ -1,6 +1,7 @@ #include <config.h> #include <apt-pkg/cachefilter.h> +#include <apt-pkg/fileutl.h> #include <string> @@ -9,17 +10,22 @@ TEST(CacheFilterTest, ArchitectureSpecification) { { - SCOPED_TRACE("Pattern is any-armhf"); - APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-armhf"); - EXPECT_TRUE(ams("armhf")); - EXPECT_FALSE(ams("armel")); - EXPECT_TRUE(ams("linux-armhf")); - EXPECT_FALSE(ams("linux-armel")); - EXPECT_TRUE(ams("kfreebsd-armhf")); - EXPECT_TRUE(ams("gnu-linux-armhf")); - EXPECT_FALSE(ams("gnu-linux-armel")); - EXPECT_TRUE(ams("gnu-kfreebsd-armhf")); - EXPECT_TRUE(ams("musl-linux-armhf")); + SCOPED_TRACE("Pattern is *"); + // * should be treated like any + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("*"); + EXPECT_TRUE(ams("sparc")); + EXPECT_TRUE(ams("amd64")); + EXPECT_TRUE(ams("kfreebsd-amd64")); + } + { + SCOPED_TRACE("Pattern is any-i386"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-i386"); + EXPECT_TRUE(ams("i386")); + EXPECT_FALSE(ams("amd64")); + EXPECT_TRUE(ams("linux-i386")); + EXPECT_FALSE(ams("linux-amd64")); + EXPECT_TRUE(ams("kfreebsd-i386")); + EXPECT_TRUE(ams("musl-linux-i386")); } { SCOPED_TRACE("Pattern is linux-any"); @@ -29,11 +35,9 @@ TEST(CacheFilterTest, ArchitectureSpecification) EXPECT_TRUE(ams("linux-armhf")); EXPECT_TRUE(ams("linux-armel")); EXPECT_FALSE(ams("kfreebsd-armhf")); - EXPECT_TRUE(ams("gnu-linux-armhf")); - EXPECT_TRUE(ams("gnu-linux-armel")); - EXPECT_FALSE(ams("gnu-kfreebsd-armhf")); EXPECT_TRUE(ams("musl-linux-armhf")); } + if (FileExists(DPKG_DATADIR "/tupletable")) { SCOPED_TRACE("Pattern is gnu-any-any"); APT::CacheFilter::PackageArchitectureMatchesSpecification ams("gnu-any-any"); //really? @@ -42,11 +46,32 @@ TEST(CacheFilterTest, ArchitectureSpecification) EXPECT_TRUE(ams("linux-armhf")); EXPECT_TRUE(ams("linux-armel")); EXPECT_TRUE(ams("kfreebsd-armhf")); - EXPECT_TRUE(ams("gnu-linux-armhf")); - EXPECT_TRUE(ams("gnu-linux-armel")); - EXPECT_TRUE(ams("gnu-kfreebsd-armhf")); EXPECT_FALSE(ams("musl-linux-armhf")); } + if (FileExists(DPKG_DATADIR "/triplettable")) + { + SCOPED_TRACE("Pattern is gnueabi-any-any"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("gnueabi-any-any"); //really? + EXPECT_TRUE(ams("linux-armel")); + EXPECT_TRUE(ams("armel")); + EXPECT_FALSE(ams("armhf")); + EXPECT_FALSE(ams("linux-armhf")); + EXPECT_FALSE(ams("musleabihf-linux-armhf")); + } + if (FileExists(DPKG_DATADIR "/triplettable")) + { + SCOPED_TRACE("Pattern is gnueabihf-any-any"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("gnueabihf-any-any"); //really? + EXPECT_FALSE(ams("linux-armel")); + EXPECT_FALSE(ams("armel")); + EXPECT_TRUE(ams("armhf")); + EXPECT_TRUE(ams("linux-armhf")); + EXPECT_FALSE(ams("musleabihf-linux-armhf")); + } + + // Weird ones - armhf's tuple is actually eabihf-gnu-linux-arm + // armel's tuple is actually eabi-gnu-linux-arm + // x32's tuple is actually x32-gnu-linux-amd64 { SCOPED_TRACE("Architecture is armhf"); APT::CacheFilter::PackageArchitectureMatchesSpecification ams("armhf", false); @@ -54,13 +79,41 @@ TEST(CacheFilterTest, ArchitectureSpecification) EXPECT_FALSE(ams("armel")); EXPECT_TRUE(ams("linux-any")); EXPECT_FALSE(ams("kfreebsd-any")); - EXPECT_TRUE(ams("any-armhf")); - EXPECT_FALSE(ams("any-armel")); + EXPECT_TRUE(ams("any-arm")); EXPECT_TRUE(ams("linux-armhf")); EXPECT_FALSE(ams("kfreebsd-armhf")); - EXPECT_TRUE(ams("gnu-linux-armhf")); - EXPECT_FALSE(ams("gnu-linux-armel")); - EXPECT_FALSE(ams("gnu-kfreebsd-armhf")); EXPECT_FALSE(ams("musl-linux-armhf")); } + { + SCOPED_TRACE("Pattern is any-arm"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-arm"); + EXPECT_TRUE(ams("armhf")); + EXPECT_TRUE(ams("armel")); + EXPECT_TRUE(ams("linux-armhf")); + EXPECT_TRUE(ams("linux-armel")); + EXPECT_TRUE(ams("musl-linux-armhf")); + EXPECT_TRUE(ams("uclibc-linux-armel")); + + EXPECT_FALSE(ams("arm64")); + EXPECT_FALSE(ams("linux-arm64")); + EXPECT_FALSE(ams("kfreebsd-arm64")); + EXPECT_FALSE(ams("musl-linux-arm64")); + } + { + SCOPED_TRACE("Pattern is any-amd64"); + APT::CacheFilter::PackageArchitectureMatchesSpecification ams("any-amd64"); + EXPECT_TRUE(ams("amd64")); + EXPECT_TRUE(ams("x32")); + EXPECT_TRUE(ams("linux-amd64")); + EXPECT_TRUE(ams("linux-x32")); + EXPECT_TRUE(ams("kfreebsd-amd64")); + EXPECT_TRUE(ams("musl-linux-amd64")); + EXPECT_TRUE(ams("uclibc-linux-amd64")); + + EXPECT_FALSE(ams("i386")); + EXPECT_FALSE(ams("linux-i386")); + EXPECT_FALSE(ams("kfreebsd-i386")); + EXPECT_FALSE(ams("musl-linux-i386")); + EXPECT_FALSE(ams("uclibc-linux-i386")); + } } |