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:
@@ -6,15 +6,25 @@
|
||||
# ------------------------------------------------------
|
||||
|
||||
|
||||
# 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
|
||||
# ---------------------------
|
||||
|
||||
filesToRemove=(
|
||||
"/Applications/OpenCore-Patcher.app"
|
||||
"/Library/Application Support/Dortania/Update.plist"
|
||||
"/Library/Application Support/Dortania/OpenCore-Patcher.app"
|
||||
"/Library/LaunchAgents/com.dortania.opencore-legacy-patcher.auto-patch.plist"
|
||||
"/Library/PrivilegedHelperTools/com.dortania.opencore-legacy-patcher.privileged-helper"
|
||||
"Applications/OpenCore-Patcher.app"
|
||||
"Library/Application Support/Dortania/Update.plist"
|
||||
"Library/Application Support/Dortania/OpenCore-Patcher.app"
|
||||
"Library/LaunchAgents/com.dortania.opencore-legacy-patcher.auto-patch.plist"
|
||||
"Library/PrivilegedHelperTools/com.dortania.opencore-legacy-patcher.privileged-helper"
|
||||
)
|
||||
|
||||
|
||||
@@ -22,39 +32,43 @@ filesToRemove=(
|
||||
# ---------------------------
|
||||
|
||||
function _removeFile() {
|
||||
local currentFile=$1
|
||||
local file=$1
|
||||
|
||||
if [[ ! -e $currentFile ]]; then
|
||||
if [[ ! -e $file ]]; then
|
||||
# Check if file is a symbolic link
|
||||
if [[ -L $currentFile ]]; then
|
||||
/bin/rm -f $currentFile
|
||||
if [[ -L $file ]]; then
|
||||
echo "Removing symbolic link: $file"
|
||||
/bin/rm -f $file
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Removing file: $file"
|
||||
|
||||
# Check if file is a directory
|
||||
if [[ -d $currentFile ]]; then
|
||||
/bin/rm -rf $currentFile
|
||||
if [[ -d $file ]]; then
|
||||
/bin/rm -rf $file
|
||||
else
|
||||
/bin/rm -f $currentFile
|
||||
/bin/rm -f $file
|
||||
fi
|
||||
}
|
||||
|
||||
function _createParentDirectory() {
|
||||
local currentFile=$1
|
||||
local file=$1
|
||||
|
||||
local parentDirectory="$(/usr/bin/dirname $currentFile)"
|
||||
local parentDirectory="$(/usr/bin/dirname $file)"
|
||||
|
||||
# Check if parent directory exists
|
||||
if [[ ! -d $parentDirectory ]]; then
|
||||
echo "Creating parent directory: $parentDirectory"
|
||||
/bin/mkdir -p $parentDirectory
|
||||
fi
|
||||
}
|
||||
|
||||
function _main() {
|
||||
for file in $filesToRemove; do
|
||||
_removeFile $file
|
||||
_createParentDirectory $file
|
||||
_removeFile $pathToTargetVolume/$file
|
||||
_createParentDirectory $pathToTargetVolume/$file
|
||||
done
|
||||
}
|
||||
|
||||
@@ -62,4 +76,5 @@ function _main() {
|
||||
# MARK: Main
|
||||
# ---------------------------
|
||||
|
||||
echo "Starting preinstall script..."
|
||||
_main
|
||||
Reference in New Issue
Block a user