Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/bin/fix-machos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ def codesign!(filename)
entitlements_xml, _, _ = Open3.capture3("codesign", "-d", "--entitlements", ":-", filename)
has_entitlements = !entitlements_xml.strip.empty?

# Some entitlements (notably `com.apple.security.virtualization` and
# `com.apple.security.hypervisor`) require either adhoc signing or a
# Developer ID with a matching provisioning profile. When pantry CI
# has imported a Developer ID via `apple-actions/import-codesign-certs`,
# `signing_id` is that Developer ID — but it generally has no matching
# provisioning, so macOS Virtualization.framework / hypervisor.framework
# refuse the entitlement at runtime (the binary launches but vz / hv
# calls fail). Homebrew sidesteps this by always adhoc-signing these
# binaries. Mirror that: force adhoc when these entitlements are present.
# See pkgxdev/pantry#7853.
privileged_entitlements = %w[
com.apple.security.virtualization
com.apple.security.hypervisor
]
if has_entitlements and privileged_entitlements.any? { |k| entitlements_xml.include?(k) }
resign_with_entitlements!(filename, "-", entitlements_xml)
return
end

# `--preserve-metadata=flags` does NOT preserve the adhoc flag (0x2)
# when re-signing — codesign treats the adhoc bit as identity-derived
# rather than a preservable flag. The result is a signed-but-not-adhoc
Expand Down
Loading