From e0e6f295846414f6923c9f4d8243790a2caccc4a Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Wed, 5 Feb 2025 20:33:44 +0100 Subject: [PATCH] relocate.py: don't warn about symlinks (#48904) `relocate_links` warns when the target is absolute and not matched by any prefix from the prefix to prefix map. This can lead to false positives, cause the prefix to prefix map does not contain trivial/identity entries whenever a package is installed to its original location. Since relocate_links is the odd one out there (we don't warn about similar issues with rpaths, etc), just remove the warning. --- lib/spack/spack/relocate.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py index e58c558b3a3..f2d0089eba0 100644 --- a/lib/spack/spack/relocate.py +++ b/lib/spack/spack/relocate.py @@ -236,22 +236,15 @@ def relocate_elf_binaries(binaries: Iterable[str], prefix_to_prefix: Dict[str, s _set_elf_rpaths_and_interpreter(path, rpaths=rpaths, interpreter=interpreter) -def _warn_if_link_cant_be_relocated(link: str, target: str): - if not os.path.isabs(target): - return - tty.warn(f'Symbolic link at "{link}" to "{target}" cannot be relocated') - - def relocate_links(links: Iterable[str], prefix_to_prefix: Dict[str, str]) -> None: """Relocate links to a new install prefix.""" regex = re.compile("|".join(re.escape(p) for p in prefix_to_prefix.keys())) for link in links: old_target = readlink(link) + if not os.path.isabs(old_target): + continue match = regex.match(old_target) - - # No match. if match is None: - _warn_if_link_cant_be_relocated(link, old_target) continue new_target = prefix_to_prefix[match.group()] + old_target[match.end() :]