summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/binary_distribution.py13
-rw-r--r--lib/spack/spack/relocate.py8
2 files changed, 17 insertions, 4 deletions
diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py
index 8658f7aa51..0beac413e1 100644
--- a/lib/spack/spack/binary_distribution.py
+++ b/lib/spack/spack/binary_distribution.py
@@ -602,7 +602,7 @@ def relocate_package(spec, allow_root):
if not is_backup_file(text_name):
text_names.append(text_name)
-# If we are installing back to the same location don't replace anything
+# If we are not installing back to the same install tree do the relocation
if old_layout_root != new_layout_root:
files_to_relocate = [os.path.join(workdir, filename)
for filename in buildinfo.get('relocate_binaries')
@@ -656,6 +656,17 @@ def relocate_package(spec, allow_root):
new_spack_prefix,
prefix_to_prefix)
+# If we are installing back to the same location
+# relocate the sbang location if the spack directory changed
+ else:
+ if old_spack_prefix != new_spack_prefix:
+ relocate.relocate_text(text_names,
+ old_layout_root, new_layout_root,
+ old_prefix, new_prefix,
+ old_spack_prefix,
+ new_spack_prefix,
+ prefix_to_prefix)
+
def extract_tarball(spec, filename, allow_root=False, unsigned=False,
force=False):
diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py
index 56e7c6632c..e299f1c5c1 100644
--- a/lib/spack/spack/relocate.py
+++ b/lib/spack/spack/relocate.py
@@ -804,15 +804,17 @@ def relocate_text(
where they should be relocated
"""
# TODO: reduce the number of arguments (8 seems too much)
- sbang_regex = r'#!/bin/bash {0}/bin/sbang'.format(orig_spack)
- new_sbang = r'#!/bin/bash {0}/bin/sbang'.format(new_spack)
+ orig_sbang = '#!/bin/bash {0}/bin/sbang'.format(orig_spack)
+ new_sbang = '#!/bin/bash {0}/bin/sbang'.format(new_spack)
for file in files:
_replace_prefix_text(file, orig_install_prefix, new_install_prefix)
for orig_dep_prefix, new_dep_prefix in new_prefixes.items():
_replace_prefix_text(file, orig_dep_prefix, new_dep_prefix)
_replace_prefix_text(file, orig_layout_root, new_layout_root)
- _replace_prefix_text(file, sbang_regex, new_sbang)
+ # relocate the sbang location only if the spack directory changed
+ if orig_spack != new_spack:
+ _replace_prefix_text(file, orig_sbang, new_sbang)
def relocate_text_bin(