spec: implemented direct satisfy semantic

Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
Massimiliano Culpo 2024-10-22 18:17:24 +02:00
parent e6729320f7
commit 575483d041
No known key found for this signature in database
GPG Key ID: 3E52BB992233066C

View File

@ -3506,6 +3506,19 @@ def satisfies(self, other: Union[str, "Spec"], deps: bool = True) -> bool:
if rhs_edge.spec.virtual:
rhs_edge.update_virtuals(virtuals=(rhs_edge.spec.name,))
if rhs_edge.direct:
# Note: this relies on abstract specs from string not being deeper than 2 levels
# e.g. in foo %fee ^bar %baz we cannot go deeper than "baz" and e.g. specify its
# dependencies too.
current_node = self if rhs_edge.parent.name is None else self[rhs_edge.parent.name]
candidates = current_node.dependencies(
name=rhs_edge.spec.name,
deptype=rhs_edge.depflag,
virtuals=rhs_edge.virtuals or None,
)
if not candidates or not any(x.satisfies(rhs_edge.spec) for x in candidates):
return False
if not rhs_edge.virtuals:
continue