浏览代码

CI: Remove dependency on packagesbuild and use native Xcode tools

PatTheMav 1 年之前
父节点
当前提交
cff11c6edc

+ 2 - 7
.github/scripts/.package.zsh

@@ -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

+ 0 - 62
.github/scripts/utils.zsh/check_packages

@@ -1,62 +0,0 @@
-if (( ! ${+commands[packagesbuild]} )) {
-  autoload -Uz log_group log_info log_status mkcd
-
-  if (( ! ${+commands[curl]} )) {
-    log_error 'curl not found. Please install curl.'
-    return 2
-  }
-
-  if (( ! ${+project_root} )) {
-    log_error "'project_root' not set. Please set before running ${0}."
-    return 2
-  }
-
-  local -a curl_opts=()
-  if (( ${+CI} )) {
-    curl_opts+=(--show-error --silent)
-  } else {
-    curl_opts+=(--progress-bar)
-  }
-  curl_opts+=(--location -O)
-
-  log_group 'Installing Packages.app...'
-
-  local version
-  local base_url
-  local hash
-  IFS=';' read -r version base_url hash <<< \
-    "$(jq -r '.tools.packages | {version, baseUrl, hash} | join(";")' buildspec.json)"
-
-  mkdir -p ${project_root}/.deps && pushd ${project_root}/.deps
-  curl ${curl_opts} "${base_url}/Packages.dmg"
-
-  local checksum="$(sha256sum Packages.dmg | cut -d " " -f 1)"
-
-  if [[ ${hash} != ${checksum} ]] {
-    log_error "Checksum mismatch of Packages.dmg download.
-Expected : ${hash}
-Actual   : ${checksum}"
-    return 2
-  }
-
-  hdiutil attach -readonly -noverify -noautoopen -plist Packages.dmg > .result.plist
-  local -i num_entities=$(( $(plutil -extract system-entities raw -- .result.plist) - 1 ))
-  local keys
-  local mount_point
-  for i ({0..${num_entities}}) {
-    keys=($(plutil -extract system-entities.${i} raw -- .result.plist))
-    if [[ ${keys} == *mount-point* ]] {
-      mount_point=$(plutil -extract system-entities.${i}.mount-point raw -- .result.plist)
-      break
-    }
-  }
-  rm .result.plist
-
-  log_status 'Installing Packages.app requires elevated privileges!'
-
-  sudo installer -pkg ${mount_point}/packages/Packages.pkg -target / && rehash
-  hdiutil detach ${mount_point} &> /dev/null && log_status 'Packages.dmg image unmounted.'
-  popd
-
-  log_group
-}

+ 0 - 10
buildspec.json

@@ -31,14 +31,6 @@
             }
         }
     },
-    "tools": {
-        "packages": {
-            "version": "1.2.10",
-            "baseUrl": "http://s.sudre.free.fr/Software/files",
-            "label": "Packages.app",
-            "hash": "6afdd25386295974dad8f078b8f1e41cabebd08e72d970bf92f707c7e48b16c9"
-        }
-    },
     "platformConfig": {
         "macos": {
             "bundleId": "com.example.obs-plugintemplate"
@@ -50,8 +42,6 @@
     "website": "https://example.com",
     "email": "me@example.com",
     "uuids": {
-        "macosPackage": "00000000-0000-0000-0000-000000000000",
-        "macosInstaller": "00000000-0000-0000-0000-000000000000",
         "windowsApp": "00000000-0000-0000-0000-000000000000"
     }
 }

+ 0 - 2
cmake/common/bootstrap.cmake

@@ -49,8 +49,6 @@ string(JSON _author GET ${buildspec} author)
 string(JSON _email GET ${buildspec} email)
 string(JSON _version GET ${buildspec} version)
 string(JSON _bundleId GET ${buildspec} platformConfig macos bundleId)
-string(JSON _macosPackageUUID GET ${buildspec} uuids macosPackage)
-string(JSON _macosInstallerUUID GET ${buildspec} uuids macosInstaller)
 string(JSON _windowsAppUUID GET ${buildspec} uuids windowsApp)
 # cmake-format: on
 

+ 3 - 17
cmake/macos/helpers.cmake

@@ -57,29 +57,15 @@ function(set_target_properties_plugin target)
     PREFIX "UI Files"
     FILES ${target_ui_files})
 
-  set(valid_uuid FALSE)
-  check_uuid(${_macosPackageUUID} valid_uuid)
-  if(NOT valid_uuid)
-    message(FATAL_ERROR "Specified macOS package UUID is not a valid UUID value: ${_macosPackageUUID}")
-  else()
-    set(UUID_PACKAGE ${_macosPackageUUID})
-  endif()
-
-  set(valid_uuid FALSE)
-  check_uuid(${_macosInstallerUUID} valid_uuid)
-  if(NOT valid_uuid)
-    message(FATAL_ERROR "Specified macOS package UUID is not a valid UUID value: ${_macosInstallerUUID}")
-  else()
-    set(UUID_INSTALLER ${_macosInstallerUUID})
-  endif()
-
   install(TARGETS ${target} LIBRARY DESTINATION .)
   install(
     FILES "$<TARGET_BUNDLE_DIR:${target}>.dsym"
     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()
 

+ 35 - 7
cmake/macos/resources/create-package.cmake.in

@@ -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}/@CMAKE_PROJECT_NAME@.plugin" AND NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin")
+  file(INSTALL DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins"
+    TYPE DIRECTORY FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin" 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}/@CMAKE_PROJECT_NAME@.plugin.dSYM" AND NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM")
+      file(INSTALL DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins" TYPE DIRECTORY FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM" 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/@CMAKE_PROJECT_NAME@.pkg"
+    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}/@CMAKE_PROJECT_NAME@.pkg"
+    COMMAND_ERROR_IS_FATAL ANY)
+
+if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.pkg")
+  file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp")
+  file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package")
+endif()

+ 33 - 0
cmake/macos/resources/distribution.in

@@ -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@">#@CMAKE_PROJECT_NAME@.pkg</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>