From 751e5c8490e556e6c2db55018b048eb0e2f04eea Mon Sep 17 00:00:00 2001 From: Andrew Leonard <31470007+andrew-m-leonard@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:52:48 +0100 Subject: [PATCH] Add Windows sign.sh retry and check curl rc (#3490) * Add Windows sign.sh retry and check curl rc Signed-off-by: Andrew Leonard * Add Windows sign.sh retry and check curl rc Signed-off-by: Andrew Leonard --------- Signed-off-by: Andrew Leonard --- sign.sh | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/sign.sh b/sign.sh index 26b991327..bd381c2c5 100755 --- a/sign.sh +++ b/sign.sh @@ -83,7 +83,32 @@ signRelease() dir=$(dirname "$f") file=$(basename "$f") mv "$f" "${dir}/unsigned_${file}" - curl --fail --silent --show-error -o "$f" -F file="@${dir}/unsigned_${file}" https://cbi.eclipse.org/authenticode/sign + if ! curl --fail --silent --show-error -o "$f" -F file="@${dir}/unsigned_${file}" https://cbi.eclipse.org/authenticode/sign; then + echo "curl command failed, sign of $f failed" + + # Retry up to 20 times + max_iterations=20 + iteration=1 + success=false + echo "Code Not Signed For File $f" + while [ $iteration -le $max_iterations ] && [ $success = false ]; do + echo $iteration Of $max_iterations + sleep 1 + if ! curl --fail --silent --show-error -o "$f" -F file="@${dir}/unsigned_${file}" https://cbi.eclipse.org/authenticode/sign; then + echo "curl command failed, $f Failed Signing On Attempt $iteration" + success=false + iteration=$((iteration+1)) + if [ $iteration -gt $max_iterations ] + then + echo "Errors Encountered During Signing" + exit 1 + fi + else + echo "$f Signed OK On Attempt $iteration" + success=true + fi + done + fi chmod --reference="${dir}/unsigned_${file}" "$f" rm -rf "${dir}/unsigned_${file}" else @@ -132,9 +157,13 @@ signRelease() dir=$(dirname "$f") file=$(basename "$f") mv "$f" "${dir}/unsigned_${file}" - curl --fail --silent --show-error -o "$f" -F file="@${dir}/unsigned_${file}" -F entitlements="@$ENTITLEMENTS" https://cbi.eclipse.org/macos/codesign/sign - echo File = "$f" - TESTMACSIGN=$(grep -ic "$MACSIGNSTRING" "$f") + if ! curl --fail --silent --show-error -o "$f" -F file="@${dir}/unsigned_${file}" -F entitlements="@$ENTITLEMENTS" https://cbi.eclipse.org/macos/codesign/sign; then + echo "curl command failed, sign of $f failed" + TESTMACSIGN=0 + else + echo File = "$f" + TESTMACSIGN=$(grep -ic "$MACSIGNSTRING" "$f") + fi echo Sign Result = "$TESTMACSIGN" if [ "$TESTMACSIGN" -gt 0 ] then @@ -149,9 +178,13 @@ signRelease() while [ $iteration -le $max_iterations ] && [ $success = false ]; do echo $iteration Of $max_iterations sleep 1 - curl --fail -o "$f" -F file="@${dir}/unsigned_${file}" -F entitlements="@$ENTITLEMENTS" https://cbi.eclipse.org/macos/codesign/sign - TESTMACSIGN2=$(grep -ic "$MACSIGNSTRING" "$f") - echo TESTMACSIGN2 = "$TESTMACSIGN2" + if ! curl --fail -o "$f" -F file="@${dir}/unsigned_${file}" -F entitlements="@$ENTITLEMENTS" https://cbi.eclipse.org/macos/codesign/sign; then + echo "curl command failed, sign of $f failed" + TESTMACSIGN2=0 + else + TESTMACSIGN2=$(grep -ic "$MACSIGNSTRING" "$f") + echo TESTMACSIGN2 = "$TESTMACSIGN2" + fi if [ "$TESTMACSIGN2" -gt 0 ] then echo "$f Signed OK On Attempt $iteration"