inst-builder: Split relation loop and optimize conflicts

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 7 years ago
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.
for block in al: if conflicts:
sat = set() for dep_suite in suite_info:
dep_binaries_s_a, dep_provides_s_a = dep_suite.binaries[arch]
for dep_suite in suite_info: for block in (relation for relation in conflicts):
dep_binaries_s_a, dep_provides_s_a = dep_suite.binaries[arch] # if a package satisfies its own conflicts relation, then it is using §7.6.2
pkgs = solvers(block, dep_binaries_s_a, dep_provides_s_a) rels = (s.pkg_id for s in solvers(block, dep_binaries_s_a, dep_provides_s_a)
for pdata in pkgs: if s.pkg_id != pkg_id)
dep_pkg_id = pdata.pkg_id for r in rels:
if dep: relations.add_breaks(r)
sat.add(dep_pkg_id)
elif pkg_id != dep_pkg_id: for block in depends:
# if t satisfies its own sat = set()
# conflicts relation, then it
# is using §7.6.2 for dep_suite in suite_info:
relations.add_breaks(dep_pkg_id) dep_binaries_s_a, dep_provides_s_a = dep_suite.binaries[arch]
if dep: sat.update(s.pkg_id for s in solvers(block, dep_binaries_s_a, dep_provides_s_a))
if len(block) != 1:
relations.add_dependency_clause(sat) if len(block) != 1:
else: relations.add_dependency_clause(sat)
# This dependency might be a part else:
# of a version-range a la: # This dependency might be a part
# # of a version-range a la:
# Depends: pkg-a (>= 1), #
# pkg-a (<< 2~) # Depends: pkg-a (>= 1),
# # pkg-a (<< 2~)
# In such a case we want to reduce #
# that to a single clause for # In such a case we want to reduce
# efficiency. # that to a single clause for
# # efficiency.
# In theory, it could also happen #
# with "non-minimal" dependencies # In theory, it could also happen
# a la: # with "non-minimal" dependencies
# # a la:
# Depends: pkg-a, pkg-a (>= 1) #
# # Depends: pkg-a, pkg-a (>= 1)
# But dpkg is known to fix that up #
# at build time, so we will # But dpkg is known to fix that up
# probably only see "ranges" here. # at build time, so we will
key = block[0][0] # probably only see "ranges" here.
if key in possible_dep_ranges: key = block[0][0]
possible_dep_ranges[key] &= sat if key in possible_dep_ranges:
else: possible_dep_ranges[key] &= sat
possible_dep_ranges[key] = sat else:
possible_dep_ranges[key] = sat
if dep:
for clause in possible_dep_ranges.values(): for clause in possible_dep_ranges.values():
relations.add_dependency_clause(clause) relations.add_dependency_clause(clause)
return builder.build() return builder.build()

Loading…
Cancel
Save