Skip to content

Commit ae95916

Browse files
committed
Add make target to sign with ad-hoc signature with correct entitlements
By default, building MacVim locally will sign with an ad-hoc signature with no entitlements. Release builds are then signed with the `macvim-signed` target which signs MacVim with a valid signature and embed the entitlments. This new target allows us to sign MacVim to have similar entitlements and behaviors as a release build without needing an Apple Developer signature. There are currently two possible use cases for this: 1. Package managers like Homebrew can use this to build MacVim to get the correct hardened runtime entitlements. 2. Reproducible builds (#1506) can use this to generate a reproducible artifact. Proper release builds are not reproducible since there's no way for a proper digital signature to be reproduced, but we can strip and re-sign with an ad-hoc signature reproducibly using this target for a decent compromise. Related: #1585
1 parent 5e0c333 commit ae95916

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

src/MacVim/scripts/sign-developer-id

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,55 @@
22

33
# Utility script to sign MacVim with a valid Developer ID with hardened runtime
44
# along with a provided entitlments file. This script requires a Developer ID
5-
# cert already installed on the computer.
5+
# cert already installed on the computer, unless only making adhoc signatures.
66

77
# Use the following to verify:
88
# codesign -d --verbose=4 --entitlements - <MacVim_app>
99

1010
if [[ $# == 0 || $# == 1 ]]; then
11-
echo "Usage: sign-developer-id <MacVim_app> <entitlements_file>"
11+
echo "Usage: sign-developer-id [--adhoc] <MacVim_app> <entitlements_file>"
1212
exit -1
1313
fi
1414

1515
set -e
1616

17+
signature_identity="Developer ID Application"
18+
19+
if [[ "$1" == "--adhoc" ]]; then
20+
# Create an adhoc signature. This is useful for local testing, but cannot
21+
# generate a valid signed app that you could distribute to other people.
22+
signature_identity="-"
23+
shift
24+
fi
25+
1726
macvim_path=$1
1827
entitlements=$2
1928

2029
if [[ "$macvim_path" =~ dmg ]]; then
2130
set -x
22-
codesign -f -s "Developer ID Application" -o runtime --timestamp "$macvim_path"
31+
codesign -f -s "$signature_identity" -o runtime --timestamp "$macvim_path"
2332
else
2433
# Sign bottom-up to make sure everything is signed in order.
2534
# Note: Not using --deep because it's been deprecated since macOS 13, and
2635
# also it doesn't catch all the binaries anyway so it's better to just be
2736
# explicit and sign everything in order to be clear what we are doing.
2837
if [ -d "$macvim_path/Contents/Frameworks/Sparkle.framework/Versions/A" ]; then
2938
(set -x
30-
codesign -f -s "Developer ID Application" -o runtime --timestamp "$macvim_path/Contents/Frameworks/Sparkle.framework/Versions/A/Resources/Autoupdate.app/Contents/MacOS/fileop"
31-
codesign -f -s "Developer ID Application" -o runtime --timestamp "$macvim_path/Contents/Frameworks/Sparkle.framework/Versions/A/Resources/Autoupdate.app")
39+
codesign -f -s "$signature_identity" -o runtime --timestamp "$macvim_path/Contents/Frameworks/Sparkle.framework/Versions/A/Resources/Autoupdate.app/Contents/MacOS/fileop"
40+
codesign -f -s "$signature_identity" -o runtime --timestamp "$macvim_path/Contents/Frameworks/Sparkle.framework/Versions/A/Resources/Autoupdate.app")
3241
fi
3342
if [ -d $macvim_path/Contents/Frameworks/Sparkle.framework/Versions/B ]; then
3443
(set -x
35-
codesign -f -s "Developer ID Application" -o runtime --timestamp "$macvim_path/Contents/Frameworks/Sparkle.framework/Versions/B/Autoupdate"
36-
codesign -f -s "Developer ID Application" -o runtime --timestamp "$macvim_path/Contents/Frameworks/Sparkle.framework/Versions/B/Updater.app")
44+
codesign -f -s "$signature_identity" -o runtime --timestamp "$macvim_path/Contents/Frameworks/Sparkle.framework/Versions/B/Autoupdate"
45+
codesign -f -s "$signature_identity" -o runtime --timestamp "$macvim_path/Contents/Frameworks/Sparkle.framework/Versions/B/Updater.app")
3746
fi
3847
if [ -d $macvim_path/Contents/Frameworks/Sparkle.framework ]; then
3948
(set -x
40-
codesign -f -s "Developer ID Application" -o runtime --timestamp "$macvim_path/Contents/Frameworks/Sparkle.framework")
49+
codesign -f -s "$signature_identity" -o runtime --timestamp "$macvim_path/Contents/Frameworks/Sparkle.framework")
4150
fi
4251
set -x
43-
codesign -f -s "Developer ID Application" -o runtime --timestamp "$macvim_path/Contents/Library/QuickLook/QLStephen.qlgenerator/Contents/MacOS/QLStephen"
44-
codesign -f -s "Developer ID Application" -o runtime --timestamp --entitlements $entitlements "$macvim_path/Contents/bin/xxd"
45-
codesign -f -s "Developer ID Application" -o runtime --timestamp --entitlements $entitlements "$macvim_path/Contents/MacOS/Vim"
46-
codesign -f -s "Developer ID Application" -o runtime --timestamp --entitlements $entitlements "$macvim_path"
52+
codesign -f -s "$signature_identity" -o runtime --timestamp "$macvim_path/Contents/Library/QuickLook/QLStephen.qlgenerator/Contents/MacOS/QLStephen"
53+
codesign -f -s "$signature_identity" -o runtime --timestamp "$macvim_path/Contents/bin/xxd"
54+
codesign -f -s "$signature_identity" -o runtime --timestamp --entitlements $entitlements "$macvim_path/Contents/MacOS/Vim"
55+
codesign -f -s "$signature_identity" -o runtime --timestamp --entitlements $entitlements "$macvim_path"
4756
fi

src/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3773,7 +3773,7 @@ Makefile:
37733773

37743774
##############################################################################
37753775
### MacVim GUI
3776-
.PHONY: macvim macvim-dmg macvim-dmg-legacy macvimclean macvim-signed macvim-dmg-release macvim-dmg-release-legacy macvim-install-runtime macvim-xcodeproj-compat
3776+
.PHONY: macvim macvim-dmg macvim-dmg-legacy macvimclean macvim-signed macvim-signed-adhoc macvim-dmg-release macvim-dmg-release-legacy macvim-install-runtime macvim-xcodeproj-compat
37773777

37783778
RUNTIME_FOLDER_LIST = MacVim/auto/runtime_folder_list.xcfilelist
37793779

@@ -3803,6 +3803,9 @@ macvim-tests:
38033803
macvim-signed:
38043804
MacVim/scripts/sign-developer-id $(RELEASEDIR)/MacVim.app $(ENTITLEMENTS)
38053805

3806+
macvim-signed-adhoc:
3807+
MacVim/scripts/sign-developer-id --adhoc $(RELEASEDIR)/MacVim.app $(ENTITLEMENTS)
3808+
38063809
macvim-dmg-legacy: DMGFILESYSTEM = HFS+
38073810
macvim-dmg-legacy: DMGFORMAT = UDZO
38083811
macvim-dmg-legacy: macvim-dmg

0 commit comments

Comments
 (0)