GeezerVison is showing github.com — tools: retry Gatekeeper check and stapling after notarization · nodejs/node@9dc4bb5
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: tools/osx-notarize.sh +21-2Lines changed: 21 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
48 | 48 | exit 1 |
49 | 49 | fi |
50 | 50 |
|
51 | | -if ! xcrun spctl --assess --type install --context context:primary-signature --ignore-cache --verbose=2 "node-$pkgid.pkg"; then |
| 51 | +# The notarization ticket can take a while to become available from Apple's |
| 52 | +# servers after notarytool reports "Accepted", so retry with backoff. |
| 53 | +retry() { |
| 54 | + delay=15 |
| 55 | + attempt=1 |
| 56 | + while ! "$@"; do |
| 57 | + if [ "$attempt" -ge 6 ]; then |
| 58 | + return 1 |
| 59 | + fi |
| 60 | + echo "Attempt $attempt failed, retrying in ${delay}s..." |
| 61 | + sleep "$delay" |
| 62 | + attempt=$((attempt + 1)) |
| 63 | + delay=$((delay * 2)) |
| 64 | + done |
| 65 | +} |
| 66 | + |
| 67 | +if ! retry xcrun spctl --assess --type install --context context:primary-signature --ignore-cache --verbose=2 "node-$pkgid.pkg"; then |
52 | 68 | echo "error: Signature will not be accepted by Gatekeeper!" 1>&2 |
53 | 69 | exit 1 |
54 | 70 | else |
55 | 71 | echo "Verification was successful." |
56 | 72 | fi |
57 | 73 |
|
58 | | -xcrun stapler staple "node-$pkgid.pkg" |
| 74 | +if ! retry xcrun stapler staple "node-$pkgid.pkg"; then |
| 75 | + echo "error: Stapling node-$pkgid.pkg failed." 1>&2 |
| 76 | + exit 1 |
| 77 | +fi |
59 | 78 | echo "Stapler was successful." |