Skip to content

Commit

Permalink
fix osx package
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Oct 24, 2023
1 parent 10a898e commit 81438e4
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 15 deletions.
9 changes: 2 additions & 7 deletions .github/scripts/.package.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,13 @@ ${_usage_host:-}"
if (( _loglevel > 1 || ${+CI} )) _tarflags="v${_tarflags}"
if (( package )) {
if [[ ! -f ${project_root}/build_macos/installer-macos.generated.pkgproj ]] {
log_error 'Packages project file not found. Run the build script or the CMake build and install procedures first.'
if [[ ! -f ${project_root}/release/${config}/${product_name}.pkg ]] {
log_error 'Installer Package not found. Run the build script or the CMake build and install procedures first.'
return 2
}
check_packages
log_group "Packaging ${product_name}..."
pushd ${project_root}
packagesbuild \
--build-folder ${project_root}/release/${config} \
${project_root}/build_macos/installer-macos.generated.pkgproj
if (( codesign )) {
read_codesign_installer
Expand Down
3 changes: 2 additions & 1 deletion cmake/macos/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ function(set_target_properties_plugin target)
CONFIGURATIONS Release
DESTINATION .
OPTIONAL)
configure_file(cmake/macos/resources/create-package.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake")
configure_file(cmake/macos/resources/distribution.in "${CMAKE_CURRENT_BINARY_DIR}/distribution" @ONLY)
configure_file(cmake/macos/resources/create-package.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake" @ONLY)
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake")
endfunction()

Expand Down
42 changes: 35 additions & 7 deletions cmake/macos/resources/create-package.cmake.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
set(CMAKE_PROJECT_NAME ${CMAKE_PROJECT_NAME})
set(CMAKE_PROJECT_VERSION ${CMAKE_PROJECT_VERSION})
set(MACOS_BUNDLEID ${MACOS_BUNDLEID})
set(UUID_PACKAGE ${UUID_PACKAGE})
set(UUID_INSTALLER ${UUID_INSTALLER})
configure_file(cmake/macos/resources/installer-macos.pkgproj.in
"${CMAKE_CURRENT_BINARY_DIR}/installer-macos.generated.pkgproj")
make_directory("$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins")

if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@[email protected]" AND NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@[email protected]")
file(INSTALL DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins"
TYPE DIRECTORY FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@[email protected]" USE_SOURCE_PERMISSIONS)

if(CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$" OR CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$")
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@[email protected]" AND NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@[email protected]")
file(INSTALL DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins" TYPE DIRECTORY FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@[email protected]" USE_SOURCE_PERMISSIONS)
endif()
endif()
endif()

make_directory("$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp")

execute_process(
COMMAND /usr/bin/pkgbuild
--identifier '@MACOS_BUNDLEID@'
--version '@CMAKE_PROJECT_VERSION@'
--root "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package"
"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp/@[email protected]"
COMMAND_ERROR_IS_FATAL ANY
)

execute_process(
COMMAND /usr/bin/productbuild
--distribution "@CMAKE_CURRENT_BINARY_DIR@/distribution"
--package-path "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp"
"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@[email protected]"
COMMAND_ERROR_IS_FATAL ANY)

if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@[email protected]")
file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp")
file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package")
endif()
33 changes: 33 additions & 0 deletions cmake/macos/resources/distribution.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="1.0">
<options
rootVolumeOnly="true"
hostArchitectures="arm64,x86_64"
customize="never"
allow-external-scripts="no" />
<domains enable_currentUserHome="true" enable_anywhere="false" enable_localSystem="false" />
<title>@CMAKE_PROJECT_NAME@</title>
<choices-outline>
<line choice="obs-plugin" />
</choices-outline>
<choice id="obs-plugin" title="@CMAKE_PROJECT_NAME@" description="">
<pkg-ref id="@MACOS_BUNDLEID@" />
</choice>
<pkg-ref id="@MACOS_BUNDLEID@" version="@CMAKE_PROJECT_VERSION@">#@[email protected]</pkg-ref>
<installation-check script="installCheck();" />
<script>
function installCheck() {
var macOSVersion = system.version.ProductVersion

if (system.compareVersions(macOSVersion, '@CMAKE_OSX_DEPLOYMENT_TARGET@') == -1) {
my.result.title = system.localizedStandardStringWithFormat(
'InstallationCheckError',
system.localizedString('DISTRIBUTION_TITLE')
);
my.result.message = ' ';
my.result.type = 'Fatal';
return false;
}
}
</script>
</installer-gui-script>

0 comments on commit 81438e4

Please sign in to comment.