mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-19 05:50:43 +01:00
Retry macOS stapling and validation (#36)
This commit is contained in:
1 parent
e01dac2c35
commit
bf03e6ad2f
2 files changed
+31
-5
No files matched your search
@@ -97,6 +97,20 @@ notarize() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Apple's CloudKit ticket lookup can drop its connection after notarization succeeded.
|
||||
# Stapling and validation are idempotent; a missing or bad ticket still fails every attempt.
|
||||
stapler_retry() {
|
||||
local action="$1" target="$2" try
|
||||
for try in 1 2 3 4; do
|
||||
xcrun stapler "$action" "$target" && return 0
|
||||
[ "$try" = 4 ] && break
|
||||
echo "stapler $action failed (try $try of 4); retrying in $((try * 20)) s" >&2
|
||||
sleep $((try * 20))
|
||||
done
|
||||
echo "error: stapler $action $(basename "$target") failed 4 times" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
# ---- TextureCraft.app ----------------------------------------------------------------------------
|
||||
echo "==> assembling $APP"
|
||||
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
|
||||
@@ -120,8 +134,8 @@ codesign --verify --strict --deep --verbose=2 "$APP"
|
||||
if [ "$NOTARIZE" = 1 ]; then
|
||||
ditto -c -k --keepParent "$APP" "$WORK/TextureCraft-notarize.zip"
|
||||
notarize "$WORK/TextureCraft-notarize.zip"
|
||||
xcrun stapler staple "$APP"
|
||||
xcrun stapler validate "$APP"
|
||||
stapler_retry staple "$APP"
|
||||
stapler_retry validate "$APP"
|
||||
spctl --assess --type execute -vvv "$APP"
|
||||
fi
|
||||
|
||||
@@ -141,8 +155,8 @@ sign "$DMG"
|
||||
codesign --verify --strict --verbose=2 "$DMG"
|
||||
if [ "$NOTARIZE" = 1 ]; then
|
||||
notarize "$DMG"
|
||||
xcrun stapler staple "$DMG"
|
||||
xcrun stapler validate "$DMG"
|
||||
stapler_retry staple "$DMG"
|
||||
stapler_retry validate "$DMG"
|
||||
spctl --assess --type open --context context:primary-signature -vvv "$DMG"
|
||||
fi
|
||||
|
||||
|
||||
@@ -70,6 +70,18 @@ assess() {
|
||||
return 1
|
||||
}
|
||||
|
||||
# Validation fetches the ticket from Apple's CloudKit and can fail on a dropped connection.
|
||||
stapler_validate() {
|
||||
local target="$1" try
|
||||
for try in 1 2 3 4; do
|
||||
xcrun stapler validate "$target" && return 0
|
||||
[ "$try" = 4 ] && break
|
||||
echo "stapler validate failed (try $try of 4); retrying in $((try * 20)) s" >&2
|
||||
sleep $((try * 20))
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
for f in "$DMG" "$CLI_ZIP"; do
|
||||
if [ ! -f "$f" ]; then
|
||||
echo "error: missing $f" >&2
|
||||
@@ -126,7 +138,7 @@ fi
|
||||
echo "==> $(basename "$DMG")"
|
||||
codesign --verify --strict --verbose=2 "$DMG"
|
||||
if [ "$STRICT" = 1 ]; then
|
||||
xcrun stapler validate "$DMG" || fail "no notarization ticket stapled to the DMG"
|
||||
stapler_validate "$DMG" || fail "no notarization ticket stapled to the DMG"
|
||||
assess --assess --type open --context context:primary-signature -vv "$DMG" \
|
||||
|| fail "Gatekeeper rejects the DMG"
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user