diff --git a/.gitignore b/.gitignore index 7a139b8d..036ec406 100644 --- a/.gitignore +++ b/.gitignore @@ -116,7 +116,8 @@ internationalization/.vscode/launch.json internationalization/pofiles/new_zh_CN.mo internationalization/.vscode/settings.json internationalization/~$zh_CN.xlsx - -GeoDamake.opt internationalization/credentials.json internationalization/token.json + +GeoDamake.opt +build/ diff --git a/BuildTools/macosx/code_sign.py b/BuildTools/macosx/code_sign.py index 388325ff..5d47ba6b 100755 --- a/BuildTools/macosx/code_sign.py +++ b/BuildTools/macosx/code_sign.py @@ -1,10 +1,14 @@ import subprocess -import os, sys, re +import os +import sys +import re from shutil import copyfile +from pathlib import Path processed_items = {} -def ProcessDependency(dylib_path, cid): + +def ProcessDependency(dylib_path, cid, current_item=None): if dylib_path in processed_items: return else: @@ -49,10 +53,14 @@ def ProcessDependency(dylib_path, cid): dylib_path = '/usr/local/opt/openexr/lib/libOpenEXR-3_1.30.dylib' if dylib_path == '@rpath/libOpenEXRCore-3_1.30.dylib': dylib_path = '/usr/local/opt/openexr/lib/libOpenEXRCore-3_1.30.dylib' - + m = re.search('@rpath/(libabsl.*)', dylib_path) if m: dylib_path = '/usr/local/opt/abseil/lib/' + m.group(1) + elif dylib_path.startswith('@rpath'): + item_filename = os.path.basename(dylib_path) + copy_dir = str(Path(current_item).parent) + dylib_path = f'{copy_dir}/{item_filename}' m = re.search('@rpath/(libaws.*)', dylib_path) if m: @@ -62,21 +70,35 @@ def ProcessDependency(dylib_path, cid): if m: dylib_path = '/usr/local/' + m.group(1) - + if dylib_path.startswith('@loader_path'): + item_filename = os.path.basename(dylib_path) + upper_levels = dylib_path.count('../') + copy_dir = str(Path(current_item).parent) + if upper_levels - 1 >= 0: + current_dir = Path(current_item).parents[upper_levels - 1] + copy_dir = str(current_dir) + item_filename = dylib_path[dylib_path.rindex('../') + 3:] + dylib_path = f'{copy_dir}/{item_filename}' + elif upper_levels == 0: + dylib_path = f'{copy_dir}/{item_filename}' + print("Process:", dylib_path) - #cmd = "codesign -f -s - " + # cmd = "codesign -f -s - " cmd = '/usr/bin/codesign --force --sign "{}" '.format(cid) os.system(cmd + dylib_path) - dep_libs = subprocess.check_output(['otool', '-L', dylib_path]).decode('utf-8') + dep_libs = subprocess.check_output( + ['otool', '-L', dylib_path]).decode('utf-8') items = dep_libs.split('\n')[2:-1] for item in items: item = item.strip().split(" ")[0] if item.startswith('/usr/lib') == False and item.startswith('/System') == False: # process item - ProcessDependency(item, cid) + ProcessDependency(item, cid, dylib_path) + # e.g. # python3 code_sign.py /opt/homebrew/opt/gdal/lib/libgdal.29.dylib "Apple Development: xunli@uchicago.edu (AN5USPSZF6)" # python3 code_sign.py /opt/homebrew/opt/gdal/lib/libgdal.32.dylib "Apple Development: xunli@uchicago.edu (AN5USPSZF6)" -ProcessDependency(sys.argv[1], sys.argv[2]) +#ProcessDependency(sys.argv[1], sys.argv[2]) +#ProcessDependency('/opt/homebrew/Cellar/gdal/3.7.2/lib/libgdal.33.3.7.2.dylib', "Apple Development: xunli@uchicago.edu (AN5USPSZF6)")