summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Gartung <gartung@fnal.gov>2020-03-16 18:43:11 -0500
committerGitHub <noreply@github.com>2020-03-16 18:43:11 -0500
commite48d24ee4591bd94e8fc3c9091d740440cbb9abd (patch)
tree011ab0d55cd5a059a141146fc4aa99336bedb663 /lib
parentc9a715b190c7ac077ca29143b57ec0b7445bc9c1 (diff)
downloadspack-e48d24ee4591bd94e8fc3c9091d740440cbb9abd.tar.gz
spack-e48d24ee4591bd94e8fc3c9091d740440cbb9abd.tar.bz2
spack-e48d24ee4591bd94e8fc3c9091d740440cbb9abd.tar.xz
spack-e48d24ee4591bd94e8fc3c9091d740440cbb9abd.zip
Warn only if link target is not relative and outside of the install prefix (#15512)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/relocate.py17
1 files 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)