scripts/codesign_example: Add check for sha256sum program

This commit is contained in:
Wilken Rivera 2020-02-12 16:54:04 -05:00
parent 746b7cbf0f
commit c121aa9104
1 changed files with 13 additions and 2 deletions

View File

@ -8,6 +8,17 @@ if ! command -v jq > /dev/null 2>&1; then
exit 1 exit 1
fi fi
if ! command -v sha256sum > /dev/null 2>&1; then
if !command -v gsha256sum > /dev/null 2>&1; then
echo "This script requires sha256sum (linux) or gsha256sum (osx) to work properly."
exit 1
else
SHASUM_PROG=gsha256sum
fi
else
SHASUM_PROG=sha256sum
fi
PRODUCT_NAME="${PRODUCT_NAME:-""}" PRODUCT_NAME="${PRODUCT_NAME:-""}"
if [ -z "$PRODUCT_NAME" ]; then if [ -z "$PRODUCT_NAME" ]; then
echo "Missing required product name: ${PRODUCT_NAME}" echo "Missing required product name: ${PRODUCT_NAME}"
@ -145,6 +156,6 @@ signed_checksum=$(
| grep -i "x-checksum-sha256" | awk 'gsub("[\r\n]", "", $2) {print $2;}' | grep -i "x-checksum-sha256" | awk 'gsub("[\r\n]", "", $2) {print $2;}'
) )
echo "${signed_checksum} signed_${SN_ID}.zip" | gsha256sum -c echo "${signed_checksum} signed_${SN_ID}.zip" | SHASUM_PROG -c
mv "signed_${SN_ID}.zip" "$TARGET_ZIP" mv "signed_${SN_ID}.zip" "$TARGET_ZIP"