def add_files_to_view(self, view, merge_map): bin_dir = self.spec.prefix.bin for src, dst in merge_map.items(): if not path_contains_subdirectory(src, bin_dir): view.link(src, dst) elif not os.path.islink(src): copy(src, dst) if 'script' in get_filetype(src): filter_file( self.spec.prefix, os.path.abspath( view.get_projection_for_spec(self.spec) ), dst, backup=False ) else: # orig_link_target = os.path.realpath(src) is insufficient when # the spack install tree is located at a symlink or a # descendent of a symlink. What we need here is the real # relative path from the python prefix to src # TODO: generalize this logic in the link_tree object # add a method to resolve a link relative to the link_tree # object root. realpath_src = os.path.realpath(src) realpath_prefix = os.path.realpath(self.spec.prefix) realpath_rel = os.path.relpath(realpath_src, realpath_prefix) orig_link_target = os.path.join(self.spec.prefix, realpath_rel) new_link_target = os.path.abspath(merge_map[orig_link_target]) view.link(new_link_target, dst)
def add_files_to_view(self, view, merge_map): bin_dir = self.spec.prefix.bin for src, dst in merge_map.items(): if not path_contains_subdirectory(src, bin_dir): view.link(src, dst) elif not os.path.islink(src): shutil.copy2(src, dst) if 'script' in get_filetype(src): filter_file(self.spec.prefix, os.path.abspath(view.root), dst) else: orig_link_target = os.path.realpath(src) new_link_target = os.path.abspath(merge_map[orig_link_target]) view.link(new_link_target, dst)
def add_files_to_view(self, view, merge_map): bin_dir = self.spec.prefix.bin for src, dst in merge_map.items(): if not path_contains_subdirectory(src, bin_dir): view.link(src, dst) elif not os.path.islink(src): copy(src, dst) if 'script' in get_filetype(src): filter_file( self.spec.prefix, os.path.abspath(view.root), dst) else: orig_link_target = os.path.realpath(src) new_link_target = os.path.abspath(merge_map[orig_link_target]) view.link(new_link_target, dst)
def add_files_to_view(self, view, merge_map): bin_dir = self.spec.prefix.bin python_prefix = self.extendee_spec.prefix global_view = same_path(python_prefix, view.root) for src, dst in merge_map.items(): if os.path.exists(dst): continue elif global_view or not path_contains_subdirectory(src, bin_dir): view.link(src, dst) elif not os.path.islink(src): shutil.copy2(src, dst) if 'script' in get_filetype(src): filter_file(python_prefix, os.path.abspath(view.root), dst) else: orig_link_target = os.path.realpath(src) new_link_target = os.path.abspath(merge_map[orig_link_target]) view.link(new_link_target, dst)
def add_files_to_view(self, view, merge_map): bin_dir = self.spec.prefix.bin python_prefix = self.extendee_spec.prefix global_view = same_path(python_prefix, view.root) for src, dst in merge_map.items(): if os.path.exists(dst): continue elif global_view or not path_contains_subdirectory(src, bin_dir): view.link(src, dst) elif not os.path.islink(src): shutil.copy2(src, dst) if 'script' in get_filetype(src): filter_file( python_prefix, os.path.abspath(view.root), dst) else: orig_link_target = os.path.realpath(src) new_link_target = os.path.abspath(merge_map[orig_link_target]) view.link(new_link_target, dst)
def write_buildinfo_file(prefix, workdir, rel=False): """ Create a cache file containing information required for the relocation """ text_to_relocate = [] binary_to_relocate = [] blacklist = (".spack", "man") os_id = platform.system() # 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] for filename in files: path_name = os.path.join(root, filename) # Check if the file contains a string with the installroot. # This cuts down on the number of files added to the list # of files potentially needing relocation if relocate.strings_contains_installroot(path_name, spack.store.layout.root): filetype = get_filetype(path_name) if relocate.needs_binary_relocation(filetype, os_id): rel_path_name = os.path.relpath(path_name, prefix) binary_to_relocate.append(rel_path_name) elif relocate.needs_text_relocation(filetype): rel_path_name = os.path.relpath(path_name, prefix) text_to_relocate.append(rel_path_name) # Create buildinfo data and write it to disk buildinfo = {} buildinfo['relative_rpaths'] = rel buildinfo['buildpath'] = spack.store.layout.root buildinfo['relative_prefix'] = os.path.relpath(prefix, spack.store.layout.root) buildinfo['relocate_textfiles'] = text_to_relocate buildinfo['relocate_binaries'] = binary_to_relocate filename = buildinfo_file_name(workdir) with open(filename, 'w') as outfile: outfile.write(yaml.dump(buildinfo, default_flow_style=True))
def write_buildinfo_file(prefix, workdir, rel=False): """ Create a cache file containing information required for the relocation """ text_to_relocate = [] binary_to_relocate = [] blacklist = (".spack", "man") os_id = platform.system() # 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] for filename in files: path_name = os.path.join(root, filename) # Check if the file contains a string with the installroot. # This cuts down on the number of files added to the list # of files potentially needing relocation if relocate.strings_contains_installroot( path_name, spack.store.layout.root): filetype = get_filetype(path_name) if relocate.needs_binary_relocation(filetype, os_id): rel_path_name = os.path.relpath(path_name, prefix) binary_to_relocate.append(rel_path_name) elif relocate.needs_text_relocation(filetype): rel_path_name = os.path.relpath(path_name, prefix) text_to_relocate.append(rel_path_name) # Create buildinfo data and write it to disk buildinfo = {} buildinfo['relative_rpaths'] = rel buildinfo['buildpath'] = spack.store.layout.root buildinfo['relative_prefix'] = os.path.relpath( prefix, spack.store.layout.root) buildinfo['relocate_textfiles'] = text_to_relocate buildinfo['relocate_binaries'] = binary_to_relocate filename = buildinfo_file_name(workdir) with open(filename, 'w') as outfile: outfile.write(yaml.dump(buildinfo, default_flow_style=True))