4444import spack .relocate as relocate
4545
4646
47+ _relocation_blacklist = (".spack" , "man" )
48+
49+
4750class NoOverwriteException (Exception ):
4851 pass
4952
@@ -95,18 +98,14 @@ def read_buildinfo_file(prefix):
9598 return buildinfo
9699
97100
98- def write_buildinfo_file (prefix , rel = False ):
99- """
100- Create a cache file containing information
101- required for the relocation
102- """
101+ def _find_relocations (prefix ):
103102 text_to_relocate = []
104103 binary_to_relocate = []
105- blacklist = (".spack" , "man" )
106104 # Do this at during tarball creation to save time when tarball unpacked.
107105 # Used by make_package_relative to determine binaries to change.
108106 for root , dirs , files in os .walk (prefix , topdown = True ):
109- dirs [:] = [d for d in dirs if d not in blacklist ]
107+ dirs [:] = [d for d in dirs if d not in _relocation_blacklist ]
108+
110109 for filename in files :
111110 path_name = os .path .join (root , filename )
112111 filetype = relocate .get_filetype (path_name )
@@ -117,6 +116,16 @@ def write_buildinfo_file(prefix, rel=False):
117116 rel_path_name = os .path .relpath (path_name , prefix )
118117 text_to_relocate .append (rel_path_name )
119118
119+ return text_to_relocate , binary_to_relocate
120+
121+
122+ def write_buildinfo_file (prefix , rel = False ):
123+ """
124+ Create a cache file containing information
125+ required for the relocation
126+ """
127+ text_to_relocate , binary_to_relocate = _find_relocations (prefix )
128+
120129 # Create buildinfo data and write it to disk
121130 buildinfo = {}
122131 buildinfo ['relative_rpaths' ] = rel
@@ -354,18 +363,28 @@ def relocate_package(prefix):
354363 if new_path == old_path and not rel :
355364 return
356365
366+ text_relocs = buildinfo ['relocate_textfiles' ]
367+ binary_relocs = buildinfo ['relocate_binaries' ]
368+
369+ # if there are no relocations, search for them instead
370+ # TODO: revisit this in a 0.11 point release
371+ if not text_relocs or not binary_relocs :
372+ text_relocs , binary_relocs = _find_relocations (prefix )
373+ rel = False
374+
357375 tty .msg ("Relocating package from" ,
358376 "%s to %s." % (old_path , new_path ))
359377 path_names = set ()
360- for filename in buildinfo [ 'relocate_textfiles' ] :
378+ for filename in text_relocs :
361379 path_name = os .path .join (prefix , filename )
362380 path_names .add (path_name )
363381 relocate .relocate_text (path_names , old_path , new_path )
382+
364383 # If the binary files in the package were not edited to use
365384 # relative RPATHs, then the RPATHs need to be relocated
366385 if not rel :
367386 path_names = set ()
368- for filename in buildinfo [ 'relocate_binaries' ] :
387+ for filename in binary_relocs :
369388 path_name = os .path .join (prefix , filename )
370389 path_names .add (path_name )
371390 relocate .relocate_binary (path_names , old_path , new_path )
0 commit comments