mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-03-10 10:51:08 +00:00
inst-builder: Split relation loop and optimize conflicts
Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
6a3d100b92
commit
6f97e36477
@ -50,55 +50,55 @@ def build_installability_tester(suite_info, archs):
|
|||||||
|
|
||||||
with builder.relation_builder(pkg_id) as relations:
|
with builder.relation_builder(pkg_id) as relations:
|
||||||
|
|
||||||
for (al, dep) in [(depends, True), (conflicts, False)]:
|
# Breaks/Conflicts are so simple that we do not need to keep align the relation
|
||||||
|
# with the suite. This enables us to do a few optimizations.
|
||||||
|
if conflicts:
|
||||||
|
for dep_suite in suite_info:
|
||||||
|
dep_binaries_s_a, dep_provides_s_a = dep_suite.binaries[arch]
|
||||||
|
for block in (relation for relation in conflicts):
|
||||||
|
# if a package satisfies its own conflicts relation, then it is using §7.6.2
|
||||||
|
rels = (s.pkg_id for s in solvers(block, dep_binaries_s_a, dep_provides_s_a)
|
||||||
|
if s.pkg_id != pkg_id)
|
||||||
|
for r in rels:
|
||||||
|
relations.add_breaks(r)
|
||||||
|
|
||||||
for block in al:
|
for block in depends:
|
||||||
sat = set()
|
sat = set()
|
||||||
|
|
||||||
for dep_suite in suite_info:
|
for dep_suite in suite_info:
|
||||||
dep_binaries_s_a, dep_provides_s_a = dep_suite.binaries[arch]
|
dep_binaries_s_a, dep_provides_s_a = dep_suite.binaries[arch]
|
||||||
pkgs = solvers(block, dep_binaries_s_a, dep_provides_s_a)
|
sat.update(s.pkg_id for s in solvers(block, dep_binaries_s_a, dep_provides_s_a))
|
||||||
for pdata in pkgs:
|
|
||||||
dep_pkg_id = pdata.pkg_id
|
|
||||||
if dep:
|
|
||||||
sat.add(dep_pkg_id)
|
|
||||||
elif pkg_id != dep_pkg_id:
|
|
||||||
# if t satisfies its own
|
|
||||||
# conflicts relation, then it
|
|
||||||
# is using §7.6.2
|
|
||||||
relations.add_breaks(dep_pkg_id)
|
|
||||||
if dep:
|
|
||||||
if len(block) != 1:
|
|
||||||
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:
|
if len(block) != 1:
|
||||||
for clause in possible_dep_ranges.values():
|
relations.add_dependency_clause(sat)
|
||||||
relations.add_dependency_clause(clause)
|
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
|
||||||
|
|
||||||
|
for clause in possible_dep_ranges.values():
|
||||||
|
relations.add_dependency_clause(clause)
|
||||||
|
|
||||||
return builder.build()
|
return builder.build()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user