1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
# CMake script to sign macOS build
# Arguments:
# APP_IDENTIFIER - app identifier
# APP_LOCATION - the path to Audacity.app
# DMG_LOCATION - the path to Audacity dmg package
# APPLE_NOTARIZATION_USER_NAME - notarization user name
# APPLE_NOTARIZATION_PASSWORD - notarization password
# https://cmake.org/cmake/help/latest/policy/CMP0054.html
cmake_policy( SET CMP0054 NEW )
# https://cmake.org/cmake/help/latest/policy/CMP0011.html
cmake_policy( SET CMP0011 NEW )
function( get_plist_value output path key )
execute_process(
COMMAND /usr/libexec/PlistBuddy -c "Print ${key}" "${path}"
OUTPUT_VARIABLE result
)
string( STRIP ${result} result )
set( ${output} ${result} PARENT_SCOPE )
endfunction()
if( APP_LOCATION )
get_filename_component( temp_dir "${APP_LOCATION}/.." ABSOLUTE )
else()
get_filename_component( temp_dir "${DMG_LOCATION}" DIRECTORY )
endif()
set( temp_plist "${temp_dir}/NotarizationResult.plist" )
function( notarize path )
message( STATUS "Notarizing ${path}" )
execute_process(
COMMAND
xcrun altool
--notarize-app
--primary-bundle-id "${APP_IDENTIFIER}"
--file "${path}"
--username "${APPLE_NOTARIZATION_USER_NAME}"
--password "${APPLE_NOTARIZATION_PASSWORD}"
--output-format xml
OUTPUT_VARIABLE
result
)
file( WRITE ${temp_plist} ${result} )
get_plist_value( req_id ${temp_plist} "notarization-upload:RequestUUID" )
message( STATUS "\t Request ID: '${req_id}'" )
set( success Off )
while( NOT success )
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 15)
execute_process(
COMMAND
xcrun altool
--notarization-info ${req_id}
--username ${APPLE_NOTARIZATION_USER_NAME}
--password ${APPLE_NOTARIZATION_PASSWORD}
--output-format xml
OUTPUT_VARIABLE
result
)
file( WRITE ${temp_plist} ${result} )
get_plist_value( notarization_result ${temp_plist} "notarization-info:Status" )
message( STATUS "\t Status: ${notarization_result}" )
if( NOT "${notarization_result}" STREQUAL "in progress" )
if ( NOT "${notarization_result}" STREQUAL "success" )
message(FATAL_ERROR "Notarization failed:\n${result}\n")
else()
message(STATUS "Notarization successful")
endif()
break()
endif()
endwhile()
endfunction()
if( DEFINED APP_LOCATION )
get_filename_component( archive "${APP_LOCATION}/../notarization.zip" ABSOLUTE )
execute_process(
COMMAND
xcrun ditto
-c -k --keepParent
${APP_LOCATION}
${archive}
)
notarize( ${archive} )
execute_process( COMMAND stapler staple "${APP_LOCATION}" )
file( REMOVE "${APP_LOCATION}/../notarization.zip" )
endif()
if( DEFINED DMG_LOCATION )
notarize( ${DMG_LOCATION} )
execute_process( COMMAND stapler staple "${DMG_LOCATION}" )
endif()
file( REMOVE ${temp_plist} )
|