Compare commits

...

10 Commits

18
fix-rpaths.py Normal file → Executable file
View File

@@ -1,13 +1,22 @@
#! /usr/bin/env python
#! /usr/bin/env python3
import subprocess
import sys
from os.path import join, basename
import os
from pathlib import Path
app_bundle = sys.argv[1]
dry_run = '--dry' in sys.argv
# Accept the inner binary path as valid input:
if '/Contents/MacOS/' in app_bundle:
app_bundle = app_bundle[0:app_bundle.find('/Contents/MacOS/')]
# Allow a / after .app:
if app_bundle.endswith('/'):
app_bundle = app_bundle[0:-1]
app_binary = join(app_bundle, 'Contents/MacOS', basename(app_bundle).split(".")[0])
app_frameworks = join(app_bundle, 'Contents/Frameworks')
@@ -16,7 +25,9 @@ binaries = []
# Extend .framework paths to the actual binary
for binary in binaries_unfiltered:
if binary.endswith('.framework'):
binaries.append(join(binary, 'Versions/A/' + basename(binary).split(".")[0]))
current_symlink = join(binary, 'Versions/Current/' + basename(binary).split(".")[0])
current_realpath = str(Path(current_symlink).resolve())
binaries.append(current_realpath)
else:
binaries.append(binary)
@@ -37,8 +48,7 @@ for binary, dependencies in dependency_map.items():
existing_rpath = line.strip()[len('path '):line.strip().find('(') - 1]
if existing_rpath == new_rpath:
has_rpath = True
else:
break
break
if not has_rpath:
print('\tAdding rpath: ' + new_rpath)
if not dry_run: