示例#1
0
def make_package_relative(workdir, spec, allow_root):
    """
    Change paths in binaries to relative paths. Change absolute symlinks
    to relative symlinks.
    """
    prefix = spec.prefix
    buildinfo = read_buildinfo_file(workdir)
    old_layout_root = buildinfo['buildpath']
    orig_path_names = list()
    cur_path_names = list()
    for filename in buildinfo['relocate_binaries']:
        orig_path_names.append(os.path.join(prefix, filename))
        cur_path_names.append(os.path.join(workdir, filename))
    if (spec.architecture.platform == 'darwin'
            or spec.architecture.platform == 'test'
            and platform.system().lower() == 'darwin'):
        relocate.make_macho_binaries_relative(cur_path_names, orig_path_names,
                                              old_layout_root)
    if (spec.architecture.platform == 'linux'
            or spec.architecture.platform == 'test'
            and platform.system().lower() == 'linux'):
        relocate.make_elf_binaries_relative(cur_path_names, orig_path_names,
                                            old_layout_root)
    relocate.raise_if_not_relocatable(cur_path_names, allow_root)
    orig_path_names = list()
    cur_path_names = list()
    for linkname in buildinfo.get('relocate_links', []):
        orig_path_names.append(os.path.join(prefix, linkname))
        cur_path_names.append(os.path.join(workdir, linkname))
    relocate.make_link_relative(cur_path_names, orig_path_names)
示例#2
0
def make_package_relative(workdir, spec, allow_root):
    """
    Change paths in binaries to relative paths. Change absolute symlinks
    to relative symlinks.
    """
    prefix = spec.prefix
    buildinfo = read_buildinfo_file(workdir)
    old_path = buildinfo['buildpath']
    orig_path_names = list()
    cur_path_names = list()
    for filename in buildinfo['relocate_binaries']:
        orig_path_names.append(os.path.join(prefix, filename))
        cur_path_names.append(os.path.join(workdir, filename))
    if spec.architecture.platform == 'darwin':
        relocate.make_macho_binaries_relative(cur_path_names, orig_path_names,
                                              old_path, allow_root)
    else:
        relocate.make_elf_binaries_relative(cur_path_names, orig_path_names,
                                            old_path, allow_root)
    orig_path_names = list()
    cur_path_names = list()
    for filename in buildinfo.get('relocate_links', []):
        orig_path_names.append(os.path.join(prefix, filename))
        cur_path_names.append(os.path.join(workdir, filename))
    relocate.make_link_relative(cur_path_names, orig_path_names)
示例#3
0
def make_package_relative(workdir, spec, allow_root):
    """
    Change paths in binaries to relative paths. Change absolute symlinks
    to relative symlinks.
    """
    prefix = spec.prefix
    buildinfo = read_buildinfo_file(workdir)
    old_layout_root = buildinfo['buildpath']
    orig_path_names = list()
    cur_path_names = list()
    for filename in buildinfo['relocate_binaries']:
        orig_path_names.append(os.path.join(prefix, filename))
        cur_path_names.append(os.path.join(workdir, filename))

    platform = spack.architecture.get_platform(spec.platform)
    if 'macho' in platform.binary_formats:
        relocate.make_macho_binaries_relative(cur_path_names, orig_path_names,
                                              old_layout_root)

    if 'elf' in platform.binary_formats:
        relocate.make_elf_binaries_relative(cur_path_names, orig_path_names,
                                            old_layout_root)

    relocate.raise_if_not_relocatable(cur_path_names, allow_root)
    orig_path_names = list()
    cur_path_names = list()
    for linkname in buildinfo.get('relocate_links', []):
        orig_path_names.append(os.path.join(prefix, linkname))
        cur_path_names.append(os.path.join(workdir, linkname))
    relocate.make_link_relative(cur_path_names, orig_path_names)