-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
we get random errors due to hdiutil resource busy problems (not our fault)
- Loading branch information
Showing
1 changed file
with
59 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,72 @@ | ||
# We retry a few times, due to a macos/github action runner (macos-13) limitation | ||
# see https://github.com/actions/runner-images/issues/7522 | ||
# This function can eventually be retired, it's a bandaid until all runners are updated | ||
function(create_dmg_with_retry) | ||
cmake_parse_arguments(ARG "" "CODESIGN" "" ${ARGN}) | ||
|
||
set(DMG_CMD create-dmg | ||
--volname "@QGIS_APP_NAME@ Installer" | ||
--hide-extension @QGIS_APP_NAME@.app | ||
--volicon "@CMAKE_SOURCE_DIR@/images/icons/mac/qgis.icns" | ||
--background "@CMAKE_SOURCE_DIR@/platform/macos/installer_background.png" | ||
--window-pos 200 120 | ||
--window-size 512 320 | ||
--icon-size 100 | ||
--icon "@QGIS_APP_NAME@.app" 130 160 | ||
--app-drop-link 400 155) | ||
|
||
if(ARG_CODESIGN) | ||
list(APPEND DMG_CMD --codesign ${ARG_CODESIGN}) | ||
endif() | ||
|
||
list(APPEND DMG_CMD | ||
@CMAKE_BINARY_DIR@/@QGIS_APP_NAME@-Installer.dmg | ||
${CPACK_TEMPORARY_DIRECTORY}/@QGIS_APP_NAME@.app) | ||
|
||
set(MAX_RETRIES 10) | ||
set(RETRY_COUNT 0) | ||
set(SUCCESS FALSE) | ||
|
||
while(NOT SUCCESS AND RETRY_COUNT LESS ${MAX_RETRIES}) | ||
execute_process( | ||
COMMAND ${DMG_CMD} | ||
RESULT_VARIABLE CREATE_DMG_FAILURE | ||
) | ||
|
||
if(CREATE_DMG_FAILURE) | ||
math(EXPR RETRY_COUNT "${RETRY_COUNT} + 1") | ||
if(RETRY_COUNT LESS ${MAX_RETRIES}) | ||
message(STATUS "Creating dmg failed (attempt ${RETRY_COUNT} of ${MAX_RETRIES}). Retrying...") | ||
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 2) | ||
endif() | ||
else() | ||
set(SUCCESS TRUE) | ||
endif() | ||
endwhile() | ||
|
||
if(NOT SUCCESS) | ||
message(FATAL_ERROR "Failed to create DMG after ${MAX_RETRIES} attempts") | ||
endif() | ||
endfunction() | ||
|
||
# Fixup rpath of QGIS app to let it find libraries | ||
execute_process(COMMAND install_name_tool -add_rpath @loader_path/../Frameworks ${CPACK_TEMPORARY_DIRECTORY}/@QGIS_APP_NAME@.app/Contents/MacOS/QGIS | ||
WORKING_DIRECTORY @CMAKE_BINARY_DIR@ | ||
COMMAND_ERROR_IS_FATAL ANY | ||
) | ||
WORKING_DIRECTORY @CMAKE_BINARY_DIR@ | ||
COMMAND_ERROR_IS_FATAL ANY | ||
) | ||
|
||
if(NOT "$ENV{MACOS_CODE_SIGN_IDENTITY}" STREQUAL "") | ||
# -appstore-compliant will strip away odbc, psql and webengine plugins | ||
execute_process(COMMAND "@MACDEPLOYQT_EXECUTABLE@" @QGIS_APP_NAME@.app -codesign=${MACOS_CODE_SIGN_IDENTITY} -sign-for-notarization=${MACOS_CODE_SIGN_IDENTITY} | ||
WORKING_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY} | ||
COMMAND_ERROR_IS_FATAL ANY | ||
) | ||
|
||
execute_process(COMMAND create-dmg --volname "@QGIS_APP_NAME@ Installer" --hide-extension @QGIS_APP_NAME@.app --volicon "@CMAKE_SOURCE_DIR@/images/icons/mac/qgis.icns" --background "@CMAKE_SOURCE_DIR@/platform/macos/installer_background.png" --window-pos 200 120 --window-size 512 320 --icon-size 100 --icon "@QGIS_APP_NAME@.app" 130 160 --app-drop-link 400 155 --codesign "${MACOS_CODE_SIGN_IDENTITY}" @CMAKE_BINARY_DIR@/@QGIS_APP_NAME@-Installer.dmg ${CPACK_TEMPORARY_DIRECTORY}/@QGIS_APP_NAME@.app | ||
RESULT_VARIABLE CREATE_DMG_FAILURE) | ||
|
||
if(CREATE_DMG_FAILURE) | ||
message(STATUS "Creating dmg failed. Retrying ...") | ||
execute_process(COMMAND create-dmg --volname "@QGIS_APP_NAME@ Installer" --hide-extension @QGIS_APP_NAME@.app --volicon "@CMAKE_SOURCE_DIR@/images/icons/mac/qgis.icns" --background "@CMAKE_SOURCE_DIR@/platform/macos/installer_background.png" --window-pos 200 120 --window-size 512 320 --icon-size 100 --icon "@QGIS_APP_NAME@.app" 130 160 --app-drop-link 400 155 --codesign "${MACOS_CODE_SIGN_IDENTITY}" @CMAKE_BINARY_DIR@/@QGIS_APP_NAME@-Installer.dmg ${CPACK_TEMPORARY_DIRECTORY}/@QGIS_APP_NAME@.app | ||
COMMAND_ERROR_IS_FATAL ANY) | ||
endif() | ||
|
||
create_dmg_with_retry(CODESIGN "${MACOS_CODE_SIGN_IDENTITY}") | ||
else() | ||
# -appstore-compliant will strip away odbc, psql and webengine plugins | ||
execute_process(COMMAND "@MACDEPLOYQT_EXECUTABLE@" "@QGIS_APP_NAME@.app" | ||
WORKING_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY} | ||
COMMAND_ERROR_IS_FATAL ANY | ||
) | ||
|
||
execute_process(COMMAND create-dmg --volname "@QGIS_APP_NAME@ Installer" --hide-extension @QGIS_APP_NAME@.app --volicon "@CMAKE_SOURCE_DIR@/images/icons/mac/qgis.icns" --background "@CMAKE_SOURCE_DIR@/platform/macos/installer_background.png" --window-pos 200 120 --window-size 512 320 --icon-size 100 --icon "@QGIS_APP_NAME@.app" 130 160 --app-drop-link 400 155 @CMAKE_BINARY_DIR@/@QGIS_APP_NAME@-Installer.dmg ${CPACK_TEMPORARY_DIRECTORY}/@QGIS_APP_NAME@.app | ||
RESULT_VARIABLE CREATE_DMG_FAILURE) | ||
|
||
if(CREATE_DMG_FAILURE) | ||
message(STATUS "Creating dmg failed.") | ||
endif() | ||
|
||
create_dmg_with_retry() | ||
endif() |