Skip to content

Commit 003ab75

Browse files
author
Ayla Khan
committed
Add script to fix Mac OS X packages.
1 parent 4cd8b0c commit 003ab75

File tree

3 files changed

+43
-25
lines changed

3 files changed

+43
-25
lines changed

src/CMake/Modules/CPack.Description.plist.in

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
scirunbuild_dir=@CMAKE_BINARY_DIR@
4+
productroot_dir=@PKG_ROOT_DIR@
5+
6+
if [[ ! -e $productroot_dir ]]; then
7+
echo "$productroot_dir does not exist"
8+
exit 1
9+
fi
10+
11+
@PKGBUILD_EXE@ --analyze --root $productroot_dir $scirunbuild_dir/@[email protected]
12+
@PKGBUILD_EXE@ --identifier edu.utah.sci.@CPACK_PACKAGE_NAME@ --root $productroot_dir \
13+
--component-plist $scirunbuild_dir/@[email protected] \
14+
--install-location /Applications $scirunbuild_dir/@[email protected]
15+
@PRODUCTBUILD_EXE@ --distribution $scirunbuild_dir/CPack.Distribution.dist \
16+
--package-path $productroot_dir $productroot_dir/tmp.pkg
17+
# Tip: pkgutil --expand can be used to debug package building
18+
@PKGUTIL_EXE@ --expand $productroot_dir/tmp.pkg $productroot_dir/tmp
19+
@PKGUTIL_EXE@ --flatten $productroot_dir/tmp $scirunbuild_dir/@[email protected]
20+
rm -f $scirunbuild_dir/@[email protected] $scirunbuild_dir/@[email protected]

src/CMakeLists.txt

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -948,26 +948,36 @@ SET(CPACK_RESOURCE_FILE_WELCOME ${PACKAGING_WELCOME})
948948
SET(CPACK_PACKAGE_VERSION_MAJOR "${SCIRUN_VERSION_MAJOR}")
949949
SET(CPACK_PACKAGE_VERSION_MINOR "${SCIRUN_VERSION_MINOR}")
950950
SET(CPACK_PACKAGE_VERSION_PATCH "${SCIRUN_VERSION_PATCH}")
951+
SET(CPACK_PACKAGE_VERSION "${SCIRUN_VERSION_MAJOR}.${SCIRUN_VERSION_MINOR}.${SCIRUN_VERSION_PATCH}")
951952

952-
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${APPLICATION_NAME} ${SCIRUN_VERSION_MAJOR}.${SCIRUN_VERSION_MINOR}")
953+
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${APPLICATION_NAME}_${SCIRUN_VERSION_MAJOR}.${SCIRUN_VERSION_MINOR}")
953954

954955

955956
# other platform settings will be built up from here
956957
IF(APPLE)
957-
958-
SET(CPACK_PACKAGE_DEFAULT_LOCATION "/Applications/")
959-
SET(CPACK_TOPLEVEL_TAG "")
960-
961-
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
958+
SET(CPACK_GENERATOR "productbuild;TGZ")
959+
SET(CPACK_TOPLEVEL_TAG "")
960+
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
962961
SET(CPACK_INSTALL_PREFIX "/" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
963962
SET(CMAKE_INSTALL_PREFIX "/" CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
964-
ENDIF()
965-
966-
SET(CPACK_PACKAGING_INSTALL_PREFIX "/")
967-
SET(CPACK_STRIP_FILES TRUE)
968-
SET(CPACK_SOURCE_STRIP_FILES TRUE)
969-
SET(CPACK_PACKAGE_EXECUTABLES "${APPLICATION_NAME}.app" "${APPLICATION_NAME}")
970-
963+
ENDIF()
964+
# productbuild packaging repair hack
965+
# call repair_package.sh after running package target in build
966+
# Tip: can inspect packages using the pkgutil --expand command
967+
IF(CPACK_GENERATOR MATCHES "productbuild")
968+
# make sure there are paths to packaging tools
969+
FIND_PROGRAM(PKGBUILD_EXE pkgbuild)
970+
FIND_PROGRAM(PRODUCTBUILD_EXE productbuild)
971+
FIND_PROGRAM(PKGUTIL_EXE pkgutil)
972+
SET(PKG_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Darwin")
973+
SET(PKG_BUILD_DIR "${CMAKE_BINARY_DIR}/_CPack_Packages/productbuild/${PKG_FILE_NAME}")
974+
SET(PKG_ROOT_DIR "${PKG_BUILD_DIR}/Applications")
975+
976+
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/CMake/Modules/CPack.Distribution.dist.in
977+
${CMAKE_BINARY_DIR}/CPack.Distribution.dist)
978+
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/CMake/scripts/repair_package.sh.in
979+
${CMAKE_BINARY_DIR}/repair_package.sh)
980+
ENDIF()
971981
ELSEIF(WIN32 AND NOT UNIX)
972982

973983
# There is a bug in NSIS that does not handle full unix paths properly. Make

0 commit comments

Comments
 (0)