PKG Scripts: Add PackageKit parameters

This commit is contained in:
Mykola Grymalyuk
2024-05-22 20:53:25 -06:00
parent e2dabfcc16
commit b6346137f3
3 changed files with 46 additions and 17 deletions
+14 -5
View File
@@ -5,13 +5,22 @@
# Set SUID bit on helper tool, and create app alias. # Set SUID bit on helper tool, and create app alias.
# ------------------------------------------------------ # ------------------------------------------------------
# MARK: PackageKit Parameters
# ---------------------------
pathToScript=$0 # ex. /tmp/PKInstallSandbox.*/Scripts/*/preinstall
pathToPackage=$1 # ex. ~/Downloads/Installer.pkg
pathToTargetLocation=$2 # ex. '/', '/Applications', etc (depends on pkgbuild's '--install-location' argument)
pathToTargetVolume=$3 # ex. '/', '/Volumes/MyVolume', etc
pathToStartupDisk=$4 # ex. '/'
# MARK: Variables # MARK: Variables
# --------------------------- # ---------------------------
helperPath="/Library/PrivilegedHelperTools/com.dortania.opencore-legacy-patcher.privileged-helper" helperPath="Library/PrivilegedHelperTools/com.dortania.opencore-legacy-patcher.privileged-helper"
mainAppPath="/Library/Application Support/Dortania/OpenCore-Patcher.app" mainAppPath="Library/Application Support/Dortania/OpenCore-Patcher.app"
shimAppPath="/Applications/OpenCore-Patcher.app" shimAppPath="Applications/OpenCore-Patcher.app"
# MARK: Functions # MARK: Functions
@@ -52,8 +61,8 @@ function _createAlias() {
} }
function _main() { function _main() {
_setSUIDBit $helperPath _setSUIDBit "$pathToTargetVolume/$helperPath"
_createAlias $mainAppPath $shimAppPath _createAlias "$pathToTargetVolume/$mainAppPath" "$pathToTargetVolume/$shimAppPath"
} }
+16 -6
View File
@@ -6,14 +6,24 @@
# ------------------------------------------------------ # ------------------------------------------------------
# MARK: PackageKit Parameters
# ---------------------------
pathToScript=$0 # ex. /tmp/PKInstallSandbox.*/Scripts/*/preinstall
pathToPackage=$1 # ex. ~/Downloads/Installer.pkg
pathToTargetLocation=$2 # ex. '/', '/Applications', etc (depends on pkgbuild's '--install-location' argument)
pathToTargetVolume=$3 # ex. '/', '/Volumes/MyVolume', etc
pathToStartupDisk=$4 # ex. '/'
# MARK: Variables # MARK: Variables
# --------------------------- # ---------------------------
filesToRemove=( filesToRemove=(
"/Applications/OpenCore-Patcher.app" "Applications/OpenCore-Patcher.app"
"/Library/Application Support/Dortania/Update.plist" "Library/Application Support/Dortania/Update.plist"
"/Library/Application Support/Dortania/OpenCore-Patcher.app" "Library/Application Support/Dortania/OpenCore-Patcher.app"
"/Library/PrivilegedHelperTools/com.dortania.opencore-legacy-patcher.privileged-helper" "Library/PrivilegedHelperTools/com.dortania.opencore-legacy-patcher.privileged-helper"
) )
@@ -56,8 +66,8 @@ function _createParentDirectory() {
function _main() { function _main() {
for file in $filesToRemove; do for file in $filesToRemove; do
_removeFile $file _removeFile $pathToTargetVolume/$file
_createParentDirectory $file _createParentDirectory $pathToTargetVolume/$file
done done
} }
+16 -6
View File
@@ -4,14 +4,24 @@
# ------------------------------------------------------ # ------------------------------------------------------
# MARK: PackageKit Parameters
# ---------------------------
pathToScript=$0 # ex. /tmp/PKInstallSandbox.*/Scripts/*/preinstall
pathToPackage=$1 # ex. ~/Downloads/Installer.pkg
pathToTargetLocation=$2 # ex. '/', '/Applications', etc (depends on pkgbuild's '--install-location' argument)
pathToTargetVolume=$3 # ex. '/', '/Volumes/MyVolume', etc
pathToStartupDisk=$4 # ex. '/'
# MARK: Variables # MARK: Variables
# --------------------------- # ---------------------------
filesToRemove=( filesToRemove=(
"/Applications/OpenCore-Patcher.app" "Applications/OpenCore-Patcher.app"
"/Library/Application Support/Dortania/Update.plist" "Library/Application Support/Dortania/Update.plist"
"/Library/Application Support/Dortania/OpenCore-Patcher.app" "Library/Application Support/Dortania/OpenCore-Patcher.app"
"/Library/PrivilegedHelperTools/com.dortania.opencore-legacy-patcher.privileged-helper" "Library/PrivilegedHelperTools/com.dortania.opencore-legacy-patcher.privileged-helper"
) )
@@ -44,7 +54,7 @@ function _cleanLaunchService() {
local domain="com.dortania.opencore-legacy-patcher" local domain="com.dortania.opencore-legacy-patcher"
# Iterate over launch agents and daemons # Iterate over launch agents and daemons
for launchServiceVariant in "/Library/LaunchAgents" "/Library/LaunchDaemons"; do for launchServiceVariant in "$pathToTargetVolume/Library/LaunchAgents" "$pathToTargetVolume/Library/LaunchDaemons"; do
# Check if directory exists # Check if directory exists
if [[ ! -d $launchServiceVariant ]]; then if [[ ! -d $launchServiceVariant ]]; then
continue continue
@@ -63,7 +73,7 @@ function _cleanLaunchService() {
function _main() { function _main() {
_cleanLaunchService _cleanLaunchService
for file in $filesToRemove; do for file in $filesToRemove; do
_removeFile $file _removeFile "$pathToTargetVolume/$file"
done done
} }