Skip to content

Commit

Permalink
Apply the same fallback to codesign_allocate
Browse files Browse the repository at this point in the history
  • Loading branch information
avdv committed Jul 2, 2024
1 parent 162908a commit ac40163
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion haskell/private/cc_wrapper.py.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -934,13 +934,15 @@ def darwin_rewrite_load_commands(rewrites, output):
# Fall back to /usr/bin/codesign if the `CODESIGN` executable is not available
# (this might happen when using a default cc toolchain from a nix shell on Darwin instead
# of using a nixpkgs_cc_configure'd toolchain).
# Do the same for codesign_allocate.
codesign = CODESIGN if os.access(CODESIGN, os.X_OK) else "/usr/bin/codesign"
codesign_allocate = CODESIGN_ALLOCATE if os.access(CODESIGN_ALLOCATE, os.X_OK) else "/usr/bin/codesign_allocate"
# This is necessary on MacOS Monterey on M1.
# The moving back and forth is necessary because the OS caches the signature.
# See this note from nixpkgs for reference:
# https://github.com/NixOS/nixpkgs/blob/5855ff74f511423e3e2646248598b3ffff229223/pkgs/os-specific/darwin/signing-utils/utils.sh#L1-L6
os.rename(output, f"{output}.resign")
subprocess.check_call([codesign] + ["-f", "-s", "-"] + [f"{output}.resign"], env = {'CODESIGN_ALLOCATE': CODESIGN_ALLOCATE})
subprocess.check_call([codesign] + ["-f", "-s", "-"] + [f"{output}.resign"], env = {'CODESIGN_ALLOCATE': codesign_allocate})
os.rename(f"{output}.resign", output)


Expand Down

0 comments on commit ac40163

Please sign in to comment.