support versioned provides as implemented by dpkg
authorDavid Kalnischkies <david@kalnischkies.de>
Sat, 16 Aug 2014 14:33:46 +0000 (16:33 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Tue, 26 Aug 2014 18:49:48 +0000 (20:49 +0200)
APT supported versioned provides for a long while in an attempt to get
it working with rpm. While this support is old, we can be relatively
sure that it works as versioned provides are used internally to make
Multi-Arch:foreign work.

Previous versions of apt will print a warning indicating that the
versioned provides is ignored, so that something which "Provides: foo (=
2)" doesn't provide anything.

Note that dpkg does allow only a equals-relation in the provides line
as anything else is deemed too complex. apt doesn't support anything
else either and such a support would require potentially big changes.

Closes: 758153

apt-pkg/deb/deblistparser.cc
test/integration/test-bug-758153-versioned-provides-support [new file with mode: 0755]

index 28c8985..7d4fd52 100644 (file)
@@ -803,8 +803,8 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
         Start = ParseDepends(Start,Stop,Package,Version,Op);
         if (Start == 0)
            return _error->Error("Problem parsing Provides line");
-        if (Op != pkgCache::Dep::NoOp) {
-           _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str());
+        if (Op != pkgCache::Dep::NoOp && Op != pkgCache::Dep::Equals) {
+           _error->Warning("Ignoring Provides line with non-equal DepCompareOp for package %s", Package.c_str());
         } else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign) {
            if (NewProvidesAllArch(Ver, Package, Version) == false)
               return false;
diff --git a/test/integration/test-bug-758153-versioned-provides-support b/test/integration/test-bug-758153-versioned-provides-support
new file mode 100755 (executable)
index 0000000..2904ae5
--- /dev/null
@@ -0,0 +1,137 @@
+#!/bin/sh
+set -e
+
+# dpkg implements versioned provides in commit 5bb02fe80e9f40dcad9703a72f67cf615ff217b5
+# but previous versions seem to allow parsing, working and ignoring it.
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+insertinstalledpackage 'webapp' 'all' '1' 'Depends: httpd'
+insertinstalledpackage 'webserver' 'all' '1' 'Provides: httpd'
+
+insertpackage 'unstable' 'webapp' 'all' '2' 'Depends: httpd (>= 2)'
+insertpackage 'unstable' 'webserver' 'amd64' '2' 'Provides: httpd (= 2)'
+insertpackage 'unstable' 'foreign-webserver' 'i386' '2' 'Multi-Arch: foreign
+Provides: httpd (= 2)'
+
+insertpackage 'experimental' 'webapp' 'all' '3' 'Depends: httpd (>= 1.5)'
+insertpackage 'experimental' 'webserver' 'amd64' '3' 'Provides: httpd (= 3)'
+
+insertpackage 'experimental' 'foreign-webserver' 'i386' '4' 'Multi-Arch: foreign
+Provides: httpd (= 4)'
+insertpackage 'experimental' 'cool-webapp' 'all' '4' 'Depends: httpd (>= 4)'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be upgraded:
+  webapp webserver
+2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+Inst webserver [1] (2 unstable [amd64])
+Inst webapp [1] (2 unstable [all])
+Conf webserver (2 unstable [amd64])
+Conf webapp (2 unstable [all])' aptget dist-upgrade -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be upgraded:
+  webapp webserver
+2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+Inst webserver [1] (2 unstable [amd64])
+Inst webapp [1] (2 unstable [all])
+Conf webserver (2 unstable [amd64])
+Conf webapp (2 unstable [all])' aptget install webapp webserver -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be upgraded:
+  webapp webserver
+2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+Inst webserver [1] (2 unstable [amd64])
+Inst webapp [1] (3 experimental [all])
+Conf webserver (2 unstable [amd64])
+Conf webapp (3 experimental [all])' aptget install webapp=3 webserver -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be upgraded:
+  webapp webserver
+2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+Inst webserver [1] (3 experimental [amd64])
+Inst webapp [1] (2 unstable [all])
+Conf webserver (3 experimental [amd64])
+Conf webapp (2 unstable [all])' aptget install webapp webserver=3 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+  foreign-webserver:i386
+The following packages will be upgraded:
+  webapp
+1 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
+Inst foreign-webserver:i386 (2 unstable [i386])
+Inst webapp [1] (2 unstable [all])
+Conf foreign-webserver:i386 (2 unstable [i386])
+Conf webapp (2 unstable [all])' aptget install webapp foreign-webserver:i386 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+  foreign-webserver:i386
+The following packages will be upgraded:
+  webapp
+1 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
+Inst foreign-webserver:i386 (2 unstable [i386])
+Inst webapp [1] (3 experimental [all])
+Conf foreign-webserver:i386 (2 unstable [i386])
+Conf webapp (3 experimental [all])' aptget install webapp=3 foreign-webserver:i386 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+  foreign-webserver:i386
+The following packages will be upgraded:
+  webapp
+1 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
+Inst foreign-webserver:i386 (4 experimental [i386])
+Inst webapp [1] (2 unstable [all])
+Conf foreign-webserver:i386 (4 experimental [i386])
+Conf webapp (2 unstable [all])' aptget install webapp foreign-webserver:i386=4 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+Some packages could not be installed. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ cool-webapp : Depends: httpd (>= 4)
+E: Unable to correct problems, you have held broken packages.' aptget install cool-webapp -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+Some packages could not be installed. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ cool-webapp : Depends: httpd (>= 4)
+E: Unable to correct problems, you have held broken packages.' aptget install cool-webapp foreign-webserver:i386 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+  cool-webapp foreign-webserver:i386
+0 upgraded, 2 newly installed, 0 to remove and 2 not upgraded.
+Inst foreign-webserver:i386 (4 experimental [i386])
+Inst cool-webapp (4 experimental [all])
+Conf foreign-webserver:i386 (4 experimental [i386])
+Conf cool-webapp (4 experimental [all])' aptget install cool-webapp foreign-webserver:i386=4 -s