diff --git a/apt/private/apt_dep_resolver.bzl b/apt/private/apt_dep_resolver.bzl index 802a706..553f022 100644 --- a/apt/private/apt_dep_resolver.bzl +++ b/apt/private/apt_dep_resolver.bzl @@ -6,6 +6,7 @@ load(":version_constraint.bzl", "version_constraint") def _resolve_package(state, name, version, arch): # First check if the constraint is satisfied by a virtual package virtual_packages = state.repository.virtual_packages(name = name, arch = arch) + virtual_packages.extend(state.repository.virtual_packages(name = name, arch = "all")) candidates = [ package @@ -34,6 +35,15 @@ def _resolve_package(state, name, version, arch): if "Priority" in package and package["Priority"] == "required": return package + # Sometimes they are provided by multiple versions of the same library + if len({c["Package"]: None for c in candidates}.keys()) == 1: + versions = [c["Version"] for c in candidates] + selected_version = 0 + for i in range(1, len(versions)): + if version_constraint.relop(versions[i], versions[selected_version], ">>"): + selected_version = i + return candidates[selected_version] + # Otherwise, we can't disambiguate the virtual package providers so # choose none and warn. # buildifier: disable=print diff --git a/apt/private/version_constraint.bzl b/apt/private/version_constraint.bzl index b290f8b..091e3b9 100644 --- a/apt/private/version_constraint.bzl +++ b/apt/private/version_constraint.bzl @@ -74,7 +74,7 @@ def _is_satisfied_by(va, vb): if vb[0] != "=": fail("Per https://www.debian.org/doc/debian-policy/ch-relationships.html only = is allowed for Provides field.") - return _version_relop(va[1], vb[1], va[0]) + return _version_relop(vb[1], va[1], va[0]) version_constraint = struct( relop = _version_relop,