CI: Add Uninstall PKG

This commit is contained in:
Mykola Grymalyuk
2024-05-21 19:36:33 -06:00
parent af44dcef8e
commit 0ef817566e
7 changed files with 140 additions and 13 deletions

View File

@@ -17,9 +17,9 @@ class GeneratePackage:
}
def _generate_welcome(self) -> str:
def _generate_installer_welcome(self) -> str:
"""
Generate Welcome message for PKG
Generate Welcome message for installer PKG
"""
_welcome = ""
@@ -39,10 +39,38 @@ class GeneratePackage:
return _welcome
def _generate_uninstaller_welcome(self) -> str:
"""
Generate Welcome message for uninstaller PKG
"""
_welcome = ""
_welcome = "# Application Uninstaller\n"
_welcome += "This package will uninstall the OpenCore Legacy Patcher application and its Privileged Helper Tool from your system."
_welcome += "\n\n"
_welcome += "This will not remove any root patches or OpenCore configurations that you may have installed using OpenCore Legacy Patcher."
_welcome += "\n\n"
_welcome += f"For more information on OpenCore Legacy Patcher, see our [documentation]({constants.Constants().guide_link}) and [GitHub repository]({constants.Constants().repo_link})."
return _welcome
def generate(self) -> None:
"""
Generate OpenCore-Patcher.pkg
"""
print("Generating OpenCore-Patcher-Uninstaller.pkg")
assert macos_pkg_builder.Packages(
pkg_output="./dist/OpenCore-Patcher-Uninstaller.pkg",
pkg_bundle_id="com.dortania.opencore-legacy-patcher-uninstaller",
pkg_version=constants.Constants().patcher_version,
pkg_background="./ci_tooling/installation_pkg/PkgBackgroundUninstaller.png",
pkg_preinstall_script="./ci_tooling/installation_pkg/uninstall.sh",
pkg_as_distribution=True,
pkg_title="OpenCore Legacy Patcher Uninstaller",
pkg_welcome=self._generate_uninstaller_welcome(),
).build() is True
print("Generating OpenCore-Patcher.pkg")
assert macos_pkg_builder.Packages(
pkg_output="./dist/OpenCore-Patcher.pkg",
@@ -55,5 +83,5 @@ class GeneratePackage:
pkg_postinstall_script="./ci_tooling/installation_pkg/postinstall.sh",
pkg_file_structure=self._files,
pkg_title="OpenCore Legacy Patcher",
pkg_welcome=self._generate_welcome(),
pkg_welcome=self._generate_installer_welcome(),
).build() is True

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View File

@@ -20,7 +20,7 @@ shimAppPath="/Applications/OpenCore-Patcher.app"
function _setSUIDBit() {
local binaryPath=$1
echo " Setting SUID bit on: $binaryPath"
echo "Setting SUID bit on: $binaryPath"
# Check if path is a directory
if [[ -d $binaryPath ]]; then
@@ -38,16 +38,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"
echo "Removing old symbolic link: $aliasPath"
/bin/rm -f $aliasPath
else
echo " Removing old file: $aliasPath"
echo "Removing old file: $aliasPath"
/bin/rm -rf $aliasPath
fi
fi
# Create symbolic link
echo " Creating symbolic link: $aliasPath"
echo "Creating symbolic link: $aliasPath"
/bin/ln -s $mainPath $aliasPath
}

View File

@@ -26,13 +26,13 @@ function _removeFile() {
if [[ ! -e $file ]]; then
# Check if file is a symbolic link
if [[ -L $file ]]; then
echo " Removing symbolic link: $file"
echo "Removing symbolic link: $file"
/bin/rm -f $file
fi
return
fi
echo " Removing file: $file"
echo "Removing file: $file"
# Check if file is a directory
if [[ -d $file ]]; then
@@ -49,7 +49,7 @@ function _createParentDirectory() {
# Check if parent directory exists
if [[ ! -d $parentDirectory ]]; then
echo " Creating parent directory: $parentDirectory"
echo "Creating parent directory: $parentDirectory"
/bin/mkdir -p $parentDirectory
fi
}

View File

@@ -0,0 +1,75 @@
#!/bin/zsh --no-rcs
# ------------------------------------------------------
# OpenCore Legacy Patcher PKG Uninstall Script
# ------------------------------------------------------
# MARK: Variables
# ---------------------------
filesToRemove=(
"/Applications/OpenCore-Patcher.app"
"/Library/Application Support/Dortania/Update.plist"
"/Library/Application Support/Dortania/OpenCore-Patcher.app"
"/Library/PrivilegedHelperTools/com.dortania.opencore-legacy-patcher.privileged-helper"
)
# MARK: Functions
# ---------------------------
function _removeFile() {
local file=$1
if [[ ! -e $file ]]; then
# Check if file is a symbolic link
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 $file ]]; then
/bin/rm -rf $file
else
/bin/rm -f $file
fi
}
function _cleanLaunchService() {
local domain="com.dortania.opencore-legacy-patcher"
# Iterate over launch agents and daemons
for launchServiceVariant in "/Library/LaunchAgents" "/Library/LaunchDaemons"; do
# Check if directory exists
if [[ ! -d $launchServiceVariant ]]; then
continue
fi
# Iterate over launch service files
for launchServiceFile in $(/bin/ls -1 $launchServiceVariant | /usr/bin/grep $domain); do
local launchServicePath="$launchServiceVariant/$launchServiceFile"
# Remove launch service file
_removeFile $launchServicePath
done
done
}
function _main() {
_cleanLaunchService
for file in $filesToRemove; do
_removeFile $file
done
}
# MARK: Main
# ---------------------------
echo "Starting uninstall script..."
_main