inst-builder: Refactor to bulk adding dependency clauses

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 7 years ago
parent bc1d3afa38
commit ab6b2ef953

@ -63,6 +63,7 @@ def build_installability_tester(suite_info, archs):
if rels: if rels:
relations.add_breaks(rels) relations.add_breaks(rels)
dep_relations = []
for block in depends: for block in depends:
sat = set() sat = set()
@ -71,7 +72,7 @@ def build_installability_tester(suite_info, archs):
sat.update(s.pkg_id for s in 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))
if len(block) != 1: if len(block) != 1:
relations.add_dependency_clause(sat) dep_relations.append(sat)
else: else:
# This dependency might be a part # This dependency might be a part
# of a version-range a la: # of a version-range a la:
@ -98,8 +99,10 @@ def build_installability_tester(suite_info, archs):
else: else:
possible_dep_ranges[key] = sat possible_dep_ranges[key] = sat
for clause in possible_dep_ranges.values(): if possible_dep_ranges:
relations.add_dependency_clause(clause) dep_relations.extend(possible_dep_ranges.values())
relations.add_dependency_clauses(dep_relations)
return builder.build() return builder.build()
@ -114,12 +117,11 @@ class _RelationBuilder(object):
self._new_deps = set(binary_data[0]) self._new_deps = set(binary_data[0])
self._new_breaks = set(binary_data[1]) self._new_breaks = set(binary_data[1])
def add_dependency_clauses(self, or_clauses):
"""Add a dependency clauses
def add_dependency_clause(self, or_clause): Each clause must be a sequence BinaryPackageIDs. The clause
"""Add a dependency clause is an OR clause, i.e. any BinaryPackageID in the
The clause must be a sequence of (name, version, architecture)
tuples. The clause is an OR clause, i.e. any tuple in the
sequence can satisfy the relation. It is irrelevant if the sequence can satisfy the relation. It is irrelevant if the
dependency is from the "Depends" or the "Pre-Depends" field. dependency is from the "Depends" or the "Pre-Depends" field.
@ -132,16 +134,18 @@ class _RelationBuilder(object):
called. called.
""" """
itbuilder = self._itbuilder itbuilder = self._itbuilder
clause = itbuilder._intern_set(or_clause)
binary = self._binary binary = self._binary
okay = False interned_or_clauses = [itbuilder._intern_set(c) for c in or_clauses]
for dep_tuple in clause: okay = True
okay = True for or_clause in interned_or_clauses:
rdeps, _, rdep_relations = itbuilder._reverse_relations(dep_tuple) if not or_clause:
rdeps.add(binary) okay = False
rdep_relations.add(clause) for dep_tuple in or_clause:
rdeps, _, rdep_relations = itbuilder._reverse_relations(dep_tuple)
self._new_deps.add(clause) rdeps.add(binary)
rdep_relations.add(or_clause)
self._new_deps.update(interned_or_clauses)
if not okay: if not okay:
itbuilder._broken.add(binary) itbuilder._broken.add(binary)

@ -132,8 +132,7 @@ class UniverseBuilder(object):
in_testing=pkg_builder._in_testing, in_testing=pkg_builder._in_testing,
) )
with builder.relation_builder(pkg_id) as rel: with builder.relation_builder(pkg_id) as rel:
for or_clause in pkg_builder._dependencies: rel.add_dependency_clauses(pkg_builder._dependencies)
rel.add_dependency_clause(or_clause)
rel.add_breaks(pkg_builder._conflicts) rel.add_breaks(pkg_builder._conflicts)
return builder.build() return builder.build()

Loading…
Cancel
Save