Skip to content

Commit 73e2757

Browse files
committed
[recursive-lipo] Make sure we don't get relative paths in directories
1 parent f8e3819 commit 73e2757

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

utils/recursive-lipo

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,16 @@ def overlapping_lipo_architectures(file_paths, lipo_executable):
4242
return False
4343

4444

45-
# Copy the file
46-
def copy_file(file, src_root_dirs, dest_root_dir):
45+
# Determine the path to the first file and where it should be installed.
46+
def get_first_file_and_dest_path(file, src_root_dirs, dest_root_dir):
4747
for dir in src_root_dirs:
4848
orig_file = os.path.join(dir, file)
4949
if os.path.exists(orig_file):
50-
dest_file = os.path.join(
50+
dest_path = os.path.join(
5151
dest_root_dir, os.path.relpath(orig_file, dir))
52-
print("-- Copying file %s" % dest_file)
53-
shutil.copy2(orig_file, dest_file)
54-
return
52+
return (orig_file, dest_path)
5553

56-
print("-- Warning: unable to copy file %s" % file)
54+
return None
5755

5856

5957
def merge_lipo_files(src_root_dirs, file_list, dest_root_dir, verbose=False,
@@ -79,8 +77,10 @@ def merge_lipo_files(src_root_dirs, file_list, dest_root_dir, verbose=False,
7977
print("-- Warning: Can't locate source file %s" % file)
8078
continue
8179

82-
dest_path = os.path.join(
83-
dest_root_dir, os.path.relpath(file_paths[0], src_root_dirs[0]))
80+
first_file_and_dest = get_first_file_and_dest_path(
81+
file, src_root_dirs, dest_root_dir)
82+
orig_file = first_file_and_dest[0]
83+
dest_path = first_file_and_dest[1]
8484

8585
if all([os.path.islink(item) for item in file_paths]):
8686
# It's a symlink in all found instances, copy the link.
@@ -100,12 +100,14 @@ def merge_lipo_files(src_root_dirs, file_list, dest_root_dir, verbose=False,
100100
# identical.
101101
if all([filecmp.cmp(item, file_paths[0]) for item in file_paths]):
102102
# All instances are identical, just copy the unique file.
103-
copy_file(file, src_root_dirs, dest_root_dir)
103+
print("-- Copying file %s" % dest_path)
104+
shutil.copy2(orig_file, dest_path)
104105
elif all([os.access(item, os.X_OK) for item in file_paths]):
105106
if overlapping_lipo_architectures(file_paths, lipo_executable):
106107
# lipo will fail due to overlapping architectures, so
107108
# copy the file directly.
108-
copy_file(file, src_root_dirs, dest_root_dir)
109+
print("-- Copying file verbatim %s" % dest_path)
110+
shutil.copy2(orig_file, dest_path)
109111
else:
110112
# Multiple instances are different and executable, try lipo.
111113
if verbose:

0 commit comments

Comments
 (0)