summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2019-11-13 17:51:57 -0800
committerGreg Becker <becker33@llnl.gov>2019-11-13 17:51:57 -0800
commit3f861e18b008f6705708e4dc5168915119d7e24e (patch)
tree41f550bdc8be96e3116091b49e4bb9ca73433af0 /lib
parent045e9c905f9abfee06d2d1a6ca42e5d636f848b8 (diff)
downloadspack-3f861e18b008f6705708e4dc5168915119d7e24e.tar.gz
spack-3f861e18b008f6705708e4dc5168915119d7e24e.tar.bz2
spack-3f861e18b008f6705708e4dc5168915119d7e24e.tar.xz
spack-3f861e18b008f6705708e4dc5168915119d7e24e.zip
symlink relativization: determine target relative to the link directory (#13710)
when making a package relative, relocate links relative to link directory rather than the full link path (which includes the file name) because `os.path.relpath` expects a directory.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/relocate.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py
index 711c7d2341..4cbe6d64c6 100644
--- a/lib/spack/spack/relocate.py
+++ b/lib/spack/spack/relocate.py
@@ -502,11 +502,11 @@ def make_link_relative(cur_path_names, orig_path_names):
Change absolute links to be relative.
"""
for cur_path, orig_path in zip(cur_path_names, orig_path_names):
- old_src = os.readlink(orig_path)
- new_src = os.path.relpath(old_src, orig_path)
+ target = os.readlink(orig_path)
+ relative_target = os.path.relpath(target, os.path.dirname(orig_path))
os.unlink(cur_path)
- os.symlink(new_src, cur_path)
+ os.symlink(relative_target, cur_path)
def make_macho_binaries_relative(cur_path_names, orig_path_names, old_dir,