Skip to content

Commit

Permalink
Quick fix for relocation issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
tgamblin committed Nov 13, 2017
1 parent fffcd77 commit 57608a6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
37 changes: 28 additions & 9 deletions lib/spack/spack/binary_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
import spack.relocate as relocate


_relocation_blacklist = (".spack", "man")


class NoOverwriteException(Exception):
pass

Expand Down Expand Up @@ -95,18 +98,14 @@ def read_buildinfo_file(prefix):
return buildinfo


def write_buildinfo_file(prefix, rel=False):
"""
Create a cache file containing information
required for the relocation
"""
def _find_relocations(prefix):
text_to_relocate = []
binary_to_relocate = []
blacklist = (".spack", "man")
# Do this at during tarball creation to save time when tarball unpacked.
# Used by make_package_relative to determine binaries to change.
for root, dirs, files in os.walk(prefix, topdown=True):
dirs[:] = [d for d in dirs if d not in blacklist]
dirs[:] = [d for d in dirs if d not in _relocation_blacklist]

for filename in files:
path_name = os.path.join(root, filename)
filetype = relocate.get_filetype(path_name)
Expand All @@ -117,6 +116,16 @@ def write_buildinfo_file(prefix, rel=False):
rel_path_name = os.path.relpath(path_name, prefix)
text_to_relocate.append(rel_path_name)

return text_to_relocate, binary_to_relocate


def write_buildinfo_file(prefix, rel=False):
"""
Create a cache file containing information
required for the relocation
"""
text_to_relocate, binary_to_relocate = _find_relocations(prefix)

# Create buildinfo data and write it to disk
buildinfo = {}
buildinfo['relative_rpaths'] = rel
Expand Down Expand Up @@ -354,18 +363,28 @@ def relocate_package(prefix):
if new_path == old_path and not rel:
return

text_relocs = buildinfo['relocate_textfiles']
binary_relocs = buildinfo['relocate_binaries']

# if there are no relocations, search for them instead
# TODO: revisit this in a 0.11 point release
if not text_relocs or not binary_relocs:
text_relocs, binary_relocs = _find_relocations(prefix)
rel = False

tty.msg("Relocating package from",
"%s to %s." % (old_path, new_path))
path_names = set()
for filename in buildinfo['relocate_textfiles']:
for filename in text_relocs:
path_name = os.path.join(prefix, filename)
path_names.add(path_name)
relocate.relocate_text(path_names, old_path, new_path)

# If the binary files in the package were not edited to use
# relative RPATHs, then the RPATHs need to be relocated
if not rel:
path_names = set()
for filename in buildinfo['relocate_binaries']:
for filename in binary_relocs:
path_name = os.path.join(prefix, filename)
path_names.add(path_name)
relocate.relocate_binary(path_names, old_path, new_path)
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/relocate.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def needs_binary_relocation(filetype):
retval = False
if "relocatable" in filetype:
return False
if "link" in filetype:
if "symbolic link" in filetype:
return False
if platform.system() == 'Darwin':
return ('Mach-O' in filetype)
Expand Down

0 comments on commit 57608a6

Please sign in to comment.