Skip to content

Commit 903c708

Browse files
committed
When fixing signatures broken by making libraries relocatable, instead of removing the signature, replace it with an ad-hoc signature. This allows the code to run on Apple Silicon.
1 parent 6cde6c7 commit 903c708

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

locallibs/fix.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
import sys
2424

2525

26-
UNSIGN_TOOL = "/usr/bin/codesign"
27-
28-
2926
def ensure_current_version_link(framework_path, short_version):
3027
'''Make sure the framework has Versions/Current'''
3128
versions_current_path = os.path.join(framework_path, "Versions/Current")
@@ -128,10 +125,15 @@ def fix_other_things(framework_path, short_version):
128125

129126
def fix_broken_signatures(files_relocatablized):
130127
"""
131-
Unsign the binaries and libraries that were relocatablized to avoid
132-
them having corrupted signatures.
128+
Re-sign the binaries and libraries that were relocatablized with ad-hoc
129+
signatures to avoid them having invalid signatures and to allow them to
130+
run on Apple Silicon
133131
"""
132+
CODESIGN_CMD = ["/usr/bin/codesign",
133+
"-s", "-", "--deep", "--force",
134+
"--preserve-metadata=identifier,entitlements,flags,runtime"]
134135
for pathname in files_relocatablized:
135-
print("Removing signature from %s because it is no longer valid."
136+
print("Re-signing %s with ad-hoc signature..."
136137
% pathname)
137-
subprocess.check_call([UNSIGN_TOOL, "--remove-signature", pathname])
138+
cmd = CODESIGN_CMD + [pathname]
139+
subprocess.check_call(cmd)

0 commit comments

Comments
 (0)