From e48d24ee4591bd94e8fc3c9091d740440cbb9abd Mon Sep 17 00:00:00 2001 From: Patrick Gartung Date: Mon, 16 Mar 2020 18:43:11 -0500 Subject: Warn only if link target is not relative and outside of the install prefix (#15512) --- lib/spack/spack/relocate.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py index e7c85fa4d9..88b5a36c56 100644 --- a/lib/spack/spack/relocate.py +++ b/lib/spack/spack/relocate.py @@ -682,19 +682,18 @@ def relocate_links(linknames, old_layout_root, new_layout_root, link_names = [os.path.join(new_install_prefix, linkname) for linkname in linknames] for link_name in link_names: - old_link_target = os.readlink(link_name) - old_link_target = re.sub(placeholder, old_layout_root, old_link_target) - if old_link_target.startswith(old_install_prefix): + link_target = os.readlink(link_name) + link_target = re.sub(placeholder, old_layout_root, link_target) + if link_target.startswith(old_install_prefix): new_link_target = re.sub( - old_install_prefix, new_install_prefix, old_link_target) + old_install_prefix, new_install_prefix, link_target) os.unlink(link_name) os.symlink(new_link_target, link_name) - else: - msg = 'Old link target %s' % old_link_target + if (os.path.isabs(link_target) and + not link_target.startswith(new_install_prefix)): + msg = 'Link target %s' % link_target msg += ' for symbolic link %s is outside' % link_name - msg += ' of the old install prefix %s.\n' % old_install_prefix - msg += 'This symbolic link will not be relocated' - msg += ' and might break relocation.' + msg += ' of the newinstall prefix %s.\n' % new_install_prefix tty.warn(msg) -- cgit v1.2.3-70-g09d2