Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Sign the disk image by the certificate that signed the app

Țugui Dragoșd958fbf04fd2
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index 2f328dfa..c3eb597f 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -568,8 +568,9 @@ its place (`SettingsView`), whose zap takes Peel's whole folder, `Terminal/` inc
`Scripts/release.sh` builds a Release copy, signs it with a Developer ID, has Apple notarize it, staples the ticket,
checks the result with Gatekeeper, and prints the path and SHA-256 of `Peel-<version>.dmg`, for people, and of
-`Peel-<version>.zip`, for Homebrew, and the path of its update feed. The disk image is signed, notarized, and
-stapled too. It opens on a window of the album's paper with an arc from Peel to Applications, which
+`Peel-<version>.zip`, for Homebrew, and the path of its update feed. The disk image is signed by the certificate
+that signed the app, named by its SHA-1 so a renewed certificate of the same name can't make the name ambiguous,
+then notarized and stapled too. It opens on a window of the album's paper with an arc from Peel to Applications, which
`Scripts/make_dmg.sh` lays out with dmgbuild, run by uv, so nothing drives Finder; the background carries no words,
since Finder writes the names in each Mac's language. It starts only from a committed tree whose package tests pass
with warnings as errors, builds Sparkle from its source, and refuses a build:
diff --git a/Scripts/release.sh b/Scripts/release.sh
index ab9ab0bb..75d3ceb6 100755
--- a/Scripts/release.sh
+++ b/Scripts/release.sh
@@ -216,10 +216,15 @@ rm -f "$final"
ditto -c -k --keepParent "$app" "$final"
echo "== Disk image"
-# Signed with the identity that signed the app, then notarized and stapled itself, so it opens without a warning.
-identity="$(codesign -d --verbose=2 "$app" 2>&1 \
- | sed -n 's/^Authority=\(Developer ID Application: .*\)$/\1/p' | head -1)"
-[ -n "$identity" ] || { echo "REFUSED: the app's Developer ID identity could not be read"; exit 1; }
+# Signed by the very certificate that signed the app, named by its SHA-1: `codesign` refuses a name that two
+# certificates in the keychain share (`man codesign`), as an old Developer ID and its renewal do. Then notarized and
+# stapled itself, so it opens without a warning.
+certificates="$(mktemp -d)"
+codesign -d --extract-certificates="$certificates/leaf" "$app" 2> /dev/null || true
+identity="$(shasum -a 1 "$certificates/leaf0" 2> /dev/null | cut -d ' ' -f 1)" || true
+rm -rf "$certificates"
+[[ "$identity" =~ '^[0-9a-f]{40}$' ]] \
+ || { echo "REFUSED: the certificate that signed the app could not be read"; exit 1; }
image="$build/Peel-$version.dmg"
zsh Scripts/make_dmg.sh "$app" "$image"
codesign --sign "$identity" --timestamp "$image"