diff --git a/scripts/notarize_wait.sh b/scripts/notarize_wait.sh index e0a03d77d8..1120362a22 100755 --- a/scripts/notarize_wait.sh +++ b/scripts/notarize_wait.sh @@ -50,22 +50,34 @@ if [ "$STATUS" != "Accepted" ]; then exit 1 fi +echo "=== Verifying code signature before stapling ===" +if ! codesign --verify --deep --strict "$APP_PATH" 2>&1; then + echo "ERROR: Code signature verification failed - app may have been damaged during transfer" + echo "Attempting to show signature details:" + codesign -dvvv "$APP_PATH" 2>&1 || true + exit 1 +fi +echo "Code signature verified successfully" + echo "=== Stapling notarization ticket to app ===" -# Retry stapling - Apple's CloudKit can have a brief delay after notarization completes -MAX_STAPLE_ATTEMPTS=5 +# Retry stapling - Apple's CloudKit can take several minutes to propagate the ticket +MAX_STAPLE_ATTEMPTS=10 +STAPLE_WAIT_SECONDS=30 STAPLE_ATTEMPT=1 while [ $STAPLE_ATTEMPT -le $MAX_STAPLE_ATTEMPTS ]; do echo "Stapling attempt $STAPLE_ATTEMPT/$MAX_STAPLE_ATTEMPTS..." - if xcrun stapler staple "$APP_PATH"; then + if STAPLE_OUTPUT=$(xcrun stapler staple "$APP_PATH" 2>&1); then + echo "$STAPLE_OUTPUT" echo "Stapling successful" break fi + echo "Stapler output: $STAPLE_OUTPUT" if [ $STAPLE_ATTEMPT -eq $MAX_STAPLE_ATTEMPTS ]; then - echo "ERROR: Stapling failed after $MAX_STAPLE_ATTEMPTS attempts" + echo "ERROR: Stapling failed after $MAX_STAPLE_ATTEMPTS attempts (total wait: $((MAX_STAPLE_ATTEMPTS * STAPLE_WAIT_SECONDS)) seconds)" exit 1 fi - echo "Stapling failed, waiting 10 seconds before retry..." - sleep 10 + echo "Stapling failed, waiting $STAPLE_WAIT_SECONDS seconds before retry..." + sleep $STAPLE_WAIT_SECONDS STAPLE_ATTEMPT=$((STAPLE_ATTEMPT + 1)) done