macOS: Remove duplicate RPATHs (#21244)

* Package: fix formatting.

* Package: correct printing of directory being processed.

* Package: remove duplicate RPATHs for macOS builds.

* Package: note the additional issue affecting RPATHs in the bundle script.
This commit is contained in:
Jackson Oursland
2025-05-12 09:21:14 -07:00
committed by GitHub
parent da239c6c69
commit a997c1ef16
2 changed files with 12 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
#!/bin/bash
set -e
set -x
set -x
conda_env="FreeCAD.app/Contents/Resources"
@@ -41,6 +41,7 @@ find . -name "*.pyc" -type f -delete
# fix problematic rpaths and reexport_dylibs for signing
# see https://github.com/FreeCAD/FreeCAD/issues/10144#issuecomment-1836686775
# and https://github.com/FreeCAD/FreeCAD-Bundle/pull/203
# and https://github.com/FreeCAD/FreeCAD-Bundle/issues/375
python ../scripts/fix_macos_lib_paths.py ${conda_env}/lib
# build and install the launcher

View File

@@ -5,7 +5,7 @@ import sys
if len(sys.argv) < 1 or "-h" in sys.argv:
print("""Usage: python fix_macos_paths.py <scan_path> [-r] [-s]
Options:
-r scan the directory recursively
-s scan only without fixing absolute paths in LC_RPATH or LC_REEXPORT_DYLIB
@@ -52,10 +52,10 @@ def change_reexport_dylib(file_path, reexport_dylib):
def scan_directory(directory, recursive=False):
if recursive:
print(f"Recursively scanning dir: {scan_path}")
print(f"Recursively scanning dir: {directory}")
else:
print(f"Scanning dir: {scan_path}")
print(f"Scanning dir: {directory}")
for filename in os.listdir(directory):
full_path = os.path.join(directory, filename)
if recursive and os.path.isdir(full_path):
@@ -71,16 +71,21 @@ def scan_directory(directory, recursive=False):
continue
file_dir = os.path.dirname(full_path)
rpaths_processed = set()
for rpath in rpaths:
if os.path.isabs(rpath) and os.path.samefile(file_dir, rpath):
if scanmode:
print(f'\nFound absolute path in LC_RPATH: {rpath}\nIn: {full_path}')
else:
remove_rpath(full_path, rpath)
if rpath in rpaths_processed:
print(f'\nFound duplicate RPATH: {rpath}\nIn: {full_path}')
remove_rpath(full_path, rpath)
rpaths_processed.add(rpath)
for reexport_dylib in reexport_dylibs:
if os.path.isabs(reexport_dylib):
if scanmode:
print(f'\nFound absolute path inLC_REEXPORT_DYLIB: {reexport_dylib}\nIn: {full_path}')
print(f'\nFound absolute path in LC_REEXPORT_DYLIB: {reexport_dylib}\nIn: {full_path}')
else:
change_reexport_dylib(full_path, reexport_dylib)