mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-24 20:10:14 +10:00
Packaging: Resolve AutoPkg not setting S-bit
This commit is contained in:
@@ -5,18 +5,41 @@
|
||||
# Create alias for app, start patching and reboot.
|
||||
# ------------------------------------------------------
|
||||
|
||||
# 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
|
||||
# ---------------------------
|
||||
|
||||
mainAppPath="/Library/Application Support/Dortania/OpenCore-Patcher.app"
|
||||
shimAppPath="/Applications/OpenCore-Patcher.app"
|
||||
helperPath="Library/PrivilegedHelperTools/com.dortania.opencore-legacy-patcher.privileged-helper"
|
||||
mainAppPath="Library/Application Support/Dortania/OpenCore-Patcher.app"
|
||||
shimAppPath="Applications/OpenCore-Patcher.app"
|
||||
executablePath="$mainAppPath/Contents/MacOS/OpenCore-Patcher"
|
||||
|
||||
|
||||
# MARK: Functions
|
||||
# ---------------------------
|
||||
|
||||
function _setSUIDBit() {
|
||||
local binaryPath=$1
|
||||
|
||||
echo "Setting SUID bit on: $binaryPath"
|
||||
|
||||
# Check if path is a directory
|
||||
if [[ -d $binaryPath ]]; then
|
||||
/bin/chmod -R +s $binaryPath
|
||||
else
|
||||
/bin/chmod +s $binaryPath
|
||||
fi
|
||||
}
|
||||
|
||||
function _createAlias() {
|
||||
local mainPath=$1
|
||||
local aliasPath=$2
|
||||
@@ -25,13 +48,16 @@ function _createAlias() {
|
||||
if [[ -e $aliasPath ]]; then
|
||||
# Check if alias path is a symbolic link
|
||||
if [[ -L $aliasPath ]]; then
|
||||
echo "Removing old symbolic link: $aliasPath"
|
||||
/bin/rm -f $aliasPath
|
||||
else
|
||||
echo "Removing old file: $aliasPath"
|
||||
/bin/rm -rf $aliasPath
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create symbolic link
|
||||
echo "Creating symbolic link: $aliasPath"
|
||||
/bin/ln -s $mainPath $aliasPath
|
||||
}
|
||||
|
||||
@@ -52,8 +78,9 @@ function _reboot() {
|
||||
}
|
||||
|
||||
function _main() {
|
||||
_createAlias "$mainAppPath" "$shimAppPath"
|
||||
_startPatching "$executablePath"
|
||||
_setSUIDBit "$pathToTargetVolume/$helperPath"
|
||||
_createAlias "$pathToTargetVolume/$mainAppPath" "$pathToTargetVolume/$shimAppPath"
|
||||
_startPatching "$pathToTargetVolume/$executablePath"
|
||||
_reboot
|
||||
}
|
||||
|
||||
@@ -61,4 +88,5 @@ function _main() {
|
||||
# MARK: Main
|
||||
# ---------------------------
|
||||
|
||||
echo "Starting postinstall script..."
|
||||
_main
|
||||
Reference in New Issue
Block a user