File: Notarization.cmake

package info (click to toggle)
ausweisapp2 2.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,060 kB
  • sloc: cpp: 114,067; python: 2,805; xml: 1,426; java: 885; sh: 186; makefile: 7
file content (57 lines) | stat: -rw-r--r-- 1,802 bytes parent folder | download | duplicates (2)
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
cmake_minimum_required(VERSION 3.25)

if(NOT CMAKE_SCRIPT_MODE_FILE)
	message(STATUS "Usage: cmake -P cmake/Notarization.cmake")
endif()

function(FETCH_REGEX _output _regex _data)
	string(REGEX MATCH "${_regex}" _unused "${_data}")

	if(CMAKE_MATCH_1)
		string(STRIP "${CMAKE_MATCH_1}" output)
		set(${_output} ${output} PARENT_SCOPE)
	endif()
endfunction()

find_program(XCRUN xcrun)
if(NOT XCRUN)
	message(FATAL_ERROR "Cannot find 'xcrun'")
endif()

file(GLOB DMG_FILE *.dmg)
list(LENGTH DMG_FILE DMG_FILE_LEN)
if(NOT DMG_FILE_LEN EQUAL 1)
	message(FATAL_ERROR "Cannot determine *.dmg file: ${CMAKE_BINARY_DIR}")
endif()
message(STATUS "Using DMG: ${DMG_FILE}")


set(credentials --apple-id $ENV{APPSTORE_USER} --password $ENV{APPSTORE_PSW} --team-id $ENV{APPSTORE_TEAM})
execute_process(COMMAND ${XCRUN} notarytool submit ${credentials} ${DMG_FILE} OUTPUT_VARIABLE UUID_OUTPUT)

set(regex_uuid "id: ([-|0-9|a-z]+)")
FETCH_REGEX(UUID "${regex_uuid}" "${UUID_OUTPUT}")
if(UUID)
	message(STATUS "Fetched UUID: ${UUID}")
else()
	message(FATAL_ERROR "Cannot fetch UUID: ${UUID_OUTPUT}")
endif()

message(STATUS "Wait...")
execute_process(COMMAND ${XCRUN} notarytool wait ${UUID} ${credentials})

execute_process(COMMAND ${XCRUN} notarytool info ${UUID} ${credentials} OUTPUT_VARIABLE STATUS_OUTPUT)

set(regex_status "status: ([a-zA-Z| ]+)")
FETCH_REGEX(STATUS "${regex_status}" "${STATUS_OUTPUT}")

if(STATUS STREQUAL "Accepted")
	message(STATUS "Notarization succeeded...")
else()
	message(STATUS "Fetched Status: ${STATUS}")
	execute_process(COMMAND ${XCRUN} notarytool log ${UUID} ${credentials})
	message(FATAL_ERROR "Notarization failed:\n${STATUS_OUTPUT}")
endif()

execute_process(COMMAND ${XCRUN} stapler staple -v ${DMG_FILE})
execute_process(COMMAND ${XCRUN} stapler validate -v ${DMG_FILE})