diff options
-rw-r--r-- | apt-pkg/versionmatch.cc | 15 | ||||
-rwxr-xr-x | test/integration/test-bug-758153-versioned-provides-support | 26 |
2 files changed, 34 insertions, 7 deletions
diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index 340f5a64c..82590edfe 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -159,15 +159,16 @@ bool pkgVersionMatch::MatchVer(const char *A,string B,bool Prefix) /* */ pkgCache::VerIterator pkgVersionMatch::Find(pkgCache::PkgIterator Pkg) { - pkgCache::VerIterator Ver = Pkg.VersionList(); - for (; Ver.end() == false; ++Ver) - { + for (auto Ver = Pkg.VersionList(); not Ver.end(); ++Ver) if (VersionMatches(Ver)) return Ver; - } - - // This will be Ended by now. - return Ver; + // check if the package provides itself in a matching version + for (auto Prov = Pkg.ProvidesList(); not Prov.end(); ++Prov) + if (Prov->ProvideVersion != 0 && Prov.OwnerPkg() == Prov.ParentPkg()) + if (MatchVer(Prov.ProvideVersion(), VerStr, VerPrefixMatch) || + ExpressionMatches(VerStr, Prov.ProvideVersion())) + return Prov.OwnerVer(); + return pkgCache::VerIterator{}; } /*}}}*/ diff --git a/test/integration/test-bug-758153-versioned-provides-support b/test/integration/test-bug-758153-versioned-provides-support index fb8ed39e8..7bf9d76bd 100755 --- a/test/integration/test-bug-758153-versioned-provides-support +++ b/test/integration/test-bug-758153-versioned-provides-support @@ -337,6 +337,32 @@ E: Unable to correct problems, you have held broken packages." aptget install ne fi testsuccessequal "$HEADER +The following NEW packages will be installed: + selfprov +0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded. +Inst selfprov (2 unstable [amd64]) +Conf selfprov (2 unstable [amd64])" apt install selfprov -s --solver $solver + if [ "$solver" = 'apt' ]; then + HEADER_POST_NL=" +$HEADER_POST" + else + HEADER_POST_NL='' + fi + testsuccessequal "$HEADER_PRE +Selected version '2' (unstable [amd64]) for 'selfprov'$HEADER_POST_NL +The following NEW packages will be installed: + selfprov +0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded. +Inst selfprov (2 unstable [amd64]) +Conf selfprov (2 unstable [amd64])" apt install selfprov=1 -s --solver $solver + testsuccessequal "$HEADER +The following NEW packages will be installed: + selfprov +0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded. +Inst selfprov (2 unstable [amd64]) +Conf selfprov (2 unstable [amd64])" apt install selfprov=2 -s --solver $solver + + testsuccessequal "$HEADER The following additional packages will be installed: selfprov The following NEW packages will be installed: |