mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-05-25 01:11:30 +00:00
britney.py: Handle version-ranged dependencies a bit smarter
Avoid creating two dependency clauses for dependencies emulating a "version range" a la: Depends: pkg-a (>= 2), pkg-a (<< 3~) Previously this would create two clauses a la: - (pkg-a, 2, arch), (pkg-a, 3, arch) - (pkg-a, 1, arch), (pkg-a, 2, arch) However, it is plain to see that only (pkg-a, 2, arch) is a valid solution and the other options are just noise. This patch makes Britney merge these two claues into a single clause containing exactly (pkg-a, 2, arch). Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
4009d1b244
commit
c25e7f9cd7
34
britney.py
34
britney.py
@ -431,10 +431,12 @@ class Britney(object):
|
|||||||
|
|
||||||
depends = []
|
depends = []
|
||||||
conflicts = []
|
conflicts = []
|
||||||
|
possible_dep_ranges = {}
|
||||||
|
|
||||||
# We do not differ between depends and pre-depends
|
# We do not differ between depends and pre-depends
|
||||||
if pkgdata[DEPENDS]:
|
if pkgdata[DEPENDS]:
|
||||||
depends.extend(apt_pkg.parse_depends(pkgdata[DEPENDS], False))
|
depends.extend(apt_pkg.parse_depends(pkgdata[DEPENDS], False))
|
||||||
|
|
||||||
if pkgdata[CONFLICTS]:
|
if pkgdata[CONFLICTS]:
|
||||||
conflicts = apt_pkg.parse_depends(pkgdata[CONFLICTS], False)
|
conflicts = apt_pkg.parse_depends(pkgdata[CONFLICTS], False)
|
||||||
|
|
||||||
@ -442,8 +444,10 @@ class Britney(object):
|
|||||||
|
|
||||||
for (al, dep) in [(depends, True), \
|
for (al, dep) in [(depends, True), \
|
||||||
(conflicts, False)]:
|
(conflicts, False)]:
|
||||||
|
|
||||||
for block in al:
|
for block in al:
|
||||||
sat = set()
|
sat = set()
|
||||||
|
|
||||||
for dep_dist in binaries:
|
for dep_dist in binaries:
|
||||||
(_, pkgs) = solvers(block, arch, dep_dist)
|
(_, pkgs) = solvers(block, arch, dep_dist)
|
||||||
for p in pkgs:
|
for p in pkgs:
|
||||||
@ -460,7 +464,37 @@ class Britney(object):
|
|||||||
# is using §7.6.2
|
# is using §7.6.2
|
||||||
relations.add_breaks(pt)
|
relations.add_breaks(pt)
|
||||||
if dep:
|
if dep:
|
||||||
|
if len(block) != 1:
|
||||||
relations.add_dependency_clause(sat)
|
relations.add_dependency_clause(sat)
|
||||||
|
else:
|
||||||
|
# This dependency might be a part
|
||||||
|
# of a version-range a la:
|
||||||
|
#
|
||||||
|
# Depends: pkg-a (>= 1),
|
||||||
|
# pkg-a (<< 2~)
|
||||||
|
#
|
||||||
|
# In such a case we want to reduce
|
||||||
|
# that to a single clause for
|
||||||
|
# efficiency.
|
||||||
|
#
|
||||||
|
# In theory, it could also happen
|
||||||
|
# with "non-minimal" dependencies
|
||||||
|
# a la:
|
||||||
|
#
|
||||||
|
# Depends: pkg-a, pkg-a (>= 1)
|
||||||
|
#
|
||||||
|
# But dpkg is known to fix that up
|
||||||
|
# at build time, so we will
|
||||||
|
# probably only see "ranges" here.
|
||||||
|
key = block[0][0]
|
||||||
|
if key in possible_dep_ranges:
|
||||||
|
possible_dep_ranges[key] &= sat
|
||||||
|
else:
|
||||||
|
possible_dep_ranges[key] = sat
|
||||||
|
|
||||||
|
if dep:
|
||||||
|
for clause in possible_dep_ranges.itervalues():
|
||||||
|
relations.add_dependency_clause(clause)
|
||||||
|
|
||||||
self._inst_tester = builder.build()
|
self._inst_tester = builder.build()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user