diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2024-02-12 21:56:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-12 21:56:06 +0100 |
commit | cb3c014a434443241cd9e417a8edf42eb23fd633 (patch) | |
tree | 310605c54d0ac33409311e7623487d08de769dea /lib | |
parent | 2a01e9679af2b62f8a72c5552c8b3eed0061086d (diff) | |
download | spack-cb3c014a434443241cd9e417a8edf42eb23fd633.tar.gz spack-cb3c014a434443241cd9e417a8edf42eb23fd633.tar.bz2 spack-cb3c014a434443241cd9e417a8edf42eb23fd633.tar.xz spack-cb3c014a434443241cd9e417a8edf42eb23fd633.zip |
audit: detect self-referential depends_on (#42456)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/audit.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/spack/spack/audit.py b/lib/spack/spack/audit.py index 070062c6bb..bbf2ed19db 100644 --- a/lib/spack/spack/audit.py +++ b/lib/spack/spack/audit.py @@ -796,10 +796,30 @@ def _issues_in_depends_on_directive(pkgs, error_cls): except spack.repo.UnknownPackageError: # This dependency is completely missing, so report # and continue the analysis + summary = f"{pkg_name}: unknown package '{dep_name}' in 'depends_on' directive" + details = [f" in {filename}"] + errors.append(error_cls(summary=summary, details=details)) + continue + + # Check for self-referential specs similar to: + # + # depends_on("foo@X.Y", when="^foo+bar") + # + # That would allow clingo to choose whether to have foo@X.Y+bar in the graph. + problematic_edges = [ + x for x in when.edges_to_dependencies(dep_name) if not x.virtuals + ] + if problematic_edges and not dep.patches: summary = ( - f"{pkg_name}: unknown package '{dep_name}' in " "'depends_on' directive" + f"{pkg_name}: dependency on '{dep.spec}' when '{when}' is self-referential" ) - details = [f" in {filename}"] + details = [ + ( + f" please specify better using '^[virtuals=...] {dep_name}', or " + f"substitute with an equivalent condition on '{pkg_name}'" + ), + f" in {filename}", + ] errors.append(error_cls(summary=summary, details=details)) continue |