#!/bin/bash # Function to retrieve a value from a plist function plist { /usr/libexec/PlistBuddy -c "Print ${2}" "${1}" } function realpath { python -c "import os; import sys; print(os.path.realpath(sys.argv[1]))" "${1}" } # Function to notarize a file (APP or DMG) function notarize { # Bail if not signing if [ -z "${SIGNING}" ] then return fi # Create temporary output file OUTPUT=$(mktemp /tmp/notarization-XXXX) trap "cat '${OUTPUT}' ; rm '${OUTPUT}'" EXIT # Send the app off for notarization xcrun altool --notarize-app \ --primary-bundle-id "${IDENT}" \ --file "${1}" \ --username "${NOTARIZE_USERNAME}" \ --password "${NOTARIZE_PASSWORD}" \ --output-format xml \ >"${OUTPUT}" # Bail if notarization failed if [ ${?} -ne 0 ] then exit 1 fi # Extract the request UUID from the output plist REQ=$(plist "${OUTPUT}" "notarization-upload:RequestUUID") # Poll until the request is complete for ((;;)) do # Sleep a bit sleep 15s # Ask for request status xcrun altool --notarization-info "${REQ}" \ --username "${NOTARIZE_USERNAME}" \ --password "${NOTARIZE_PASSWORD}" \ --output-format xml \ >"${OUTPUT}" if [ ${?} -ne 0 ] then exit 1 fi # Extract the current status and stop polling if it's no longer in progress STATUS=$(plist "${OUTPUT}" "notarization-info:Status") echo "Notarization status: ${STATUS}" if [ "${STATUS}" != "in progress" ] then break fi done # Bail if the notarization wasn't successful if [ "${STATUS}" != "success" ] then exit 1 fi # Cleanup trap EXIT rm "${OUTPUT}" } if [ -z "${SRCROOT}" -o -z "${DSTROOT}" ] then if [ "${#}" -ne 2 ] then echo "You must specify the source and destination roots" echo echo "Usage: ${0} srcroot dstroot" echo echo " srcroot path to the 'mac' subdirectory of your source tree" echo " dstroot path to where Tenacity was built:" echo " legacy build = /tmp/Tenacity.dst" echo " cmake build =