1 # Work around for some odd behaviour where we can't codesign a file
2 # in-place if it has been called before. This happens for example if
3 # you try to fix-up a binary using strip/install_name_tool, after it
4 # had been used previous. The solution is to copy the binary (with
5 # the corrupted signature from strip/install_name_tool) to some
6 # location, sign it there and move it back into place.
8 # This does not appear to happen with the codesign tool that ships
9 # with recent macOS BigSur installs on M1 arm64 machines. However it
10 # had also been happening with the tools that shipped with the DTKs.
18 CODESIGN_ALLOCATE
=@codesignAllocate@ \
19 @sigtool@
/bin
/codesign
-f -s - "$tmpdir/$(basename "$1")"
20 mv "$tmpdir/$(basename "$1")" "$1"
24 checkRequiresSignature
() {
28 @sigtool@
/bin
/sigtool
--file "$file" check-requires-signature || rc
=$?
30 if [ "$rc" -eq 0 ] ||
[ "$rc" -eq 1 ]; then
34 echo "Unexpected exit status from sigtool: $rc"
40 if checkRequiresSignature
"$file"; then