summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Gartung <gartung@fnal.gov>2020-07-09 22:28:51 -0500
committerGitHub <noreply@github.com>2020-07-09 22:28:51 -0500
commite72e2568dd5233220808c46a96810fdc05ef1b12 (patch)
tree7d43f5680885814ecc82a429d391fe42a4d5f937 /lib
parentd9923a05e03233e8ce25990aa4c23c23d83673df (diff)
downloadspack-e72e2568dd5233220808c46a96810fdc05ef1b12.tar.gz
spack-e72e2568dd5233220808c46a96810fdc05ef1b12.tar.bz2
spack-e72e2568dd5233220808c46a96810fdc05ef1b12.tar.xz
spack-e72e2568dd5233220808c46a96810fdc05ef1b12.zip
Relocation of sbang needs to be done when the spack prefix changes even if the install tree has not changed. (#17455)
Diffstat (limited to 'lib')
-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 63af746584..481c540bd9 100644
--- a/lib/spack/spack/binary_distribution.py
+++ b/lib/spack/spack/binary_distribution.py
@@ -603,7 +603,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')
@@ -657,6 +657,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(