Implement uninstaller for macos

This commit is contained in:
altalk23 2023-08-04 03:03:29 +03:00
parent 1be74ed9d9
commit 072a18c970
2 changed files with 93 additions and 43 deletions

View file

@ -1,33 +1,52 @@
#!/usr/bin/env osascript
set tmpPath to (POSIX path of "/tmp/")
set binPath to (tmpPath & "geode-install/")
on ExitWithMessage(message)
display dialog message
do shell script "sudo rm -rf \"" & binPath & "\""
error number -128
end ExitWithMessage
try
set gdPath to (the POSIX path of (choose file with prompt "Please choose the Geometry Dash application to install Geode to:" of type {"app"}))
on error
set installerChoices to {"Install Geode", "Uninstall Geode"}
set installerAnswer to choose from list installerChoices with title "Geode" with prompt "What do you want to do?" default items "Install Geode"
if installerAnswer is false then
ExitWithMessage ("Prompt cancelled.")
end try
else
set installerAnswer to installerAnswer's item 1
end if
set execPath to (gdPath & "Contents/MacOS/Geometry Dash")
set frameworkPath to POSIX path of (gdPath & "Contents/Frameworks/")
set fmodPath to "libfmod.dylib"
set fmodOriginalPath to "restore_fmod.dylib"
set geodePath to "Geode.dylib"
set bootstrapperPath to "GeodeBootstrapper.dylib"
set resourcesPath to "resources/"
set newGeodePath to "Contents/geode/"
set newResourcesPath to (newGeodePath & "resources/geode.loader/")
set tmpPath to POSIX path of "/tmp/"
set binPath to (tmpPath & "geode-install/")
try
tell application "System Events"
tell application "System Events"
try
set libraryPath to POSIX path of (path to home folder from user domain)
set steamPath to (libraryPath & "/Library/Application Support/Steam/steamapps/common/Geometry Dash/")
if exists folder steamPath then
set gdPath to (the POSIX path of (choose file with prompt "Please choose the Geometry Dash application to install Geode to:" of type {"app"} default location steamPath))
else
set gdPath to (the POSIX path of (choose file with prompt "Please choose the Geometry Dash application to install Geode to:" of type {"app"}))
end if
set gdPath to (gdPath & "/")
on error
ExitWithMessage ("Prompt cancelled.")
end try
set execPath to (gdPath & "Contents/MacOS/Geometry Dash")
set frameworkPath to (gdPath & "Contents/Frameworks/")
set fmodPath to "libfmod.dylib"
set fmodOriginalPath to "restore_fmod.dylib"
set geodePath to "Geode.dylib"
set bootstrapperPath to "GeodeBootstrapper.dylib"
set resourcesPath to "resources/"
set newGeodePath to "Contents/geode/"
set newResourcesPath to (newGeodePath & "resources/geode.loader/")
try
if not exists file execPath then
ExitWithMessage ("Not a valid Geometry Dash installation (executable missing): " & gdPath)
end if
@ -35,33 +54,64 @@ try
if not exists file (frameworkPath & fmodPath) then
ExitWithMessage ("Not a valid Geometry Dash installation (fmod missing): " & gdPath)
end if
end tell
on error
on error
ExitWithMessage ("Not a valid Geometry Dash installation: " & gdPath)
end try
end try
end tell
try
if installerAnswer is "Install Geode" then
try
do shell script "mv -n \"" & (frameworkPath & fmodPath) & "\" \"" & (frameworkPath & fmodOriginalPath) & "\""
on error
ExitWithMessage ("Moving original fmod failed: " & (frameworkPath & fmodPath))
end try
on error
ExitWithMessage ("Saving original fmod failed: " & (frameworkPath & fmodPath))
end try
try
do shell script "sudo mv \"" & (binPath & geodePath) & "\" \"" & (frameworkPath & geodePath) & "\""
do shell script "sudo mv \"" & (binPath & bootstrapperPath) & "\" \"" & (frameworkPath & bootstrapperPath) & "\""
do shell script "sudo mv \"" & (binPath & fmodPath) & "\" \"" & (frameworkPath & fmodPath) & "\""
do shell script "INSTALLER_USER=$(stat -f '%Su' $HOME) && sudo chown -R $INSTALLER_USER \"" & frameworkPath & "\""
on error
try
do shell script "mv \"" & (binPath & geodePath) & "\" \"" & (frameworkPath & geodePath) & "\""
do shell script "mv \"" & (binPath & bootstrapperPath) & "\" \"" & (frameworkPath & bootstrapperPath) & "\""
do shell script "mv \"" & (binPath & fmodPath) & "\" \"" & (frameworkPath & fmodPath) & "\""
do shell script "INSTALLER_USER=$(stat -f '%Su' $HOME) && chown -R $INSTALLER_USER \"" & frameworkPath & "\""
on error
ExitWithMessage ("Moving libraries failed: " & frameworkPath)
end try
end try
try
do shell script "sudo mkdir -p \"" & (gdPath & newResourcesPath) & "\""
do shell script "sudo mv \"" & (binPath & resourcesPath) & "\"* \"" & (gdPath & newResourcesPath) & "\""
do shell script "INSTALLER_USER=$(stat -f '%Su' $HOME) && sudo chown -R $INSTALLER_USER \"" & (gdPath & newGeodePath) & "\""
on error
try
do shell script "mkdir -p \"" & (gdPath & newResourcesPath) & "\""
do shell script "mv \"" & (binPath & resourcesPath) & "\"* \"" & (gdPath & newResourcesPath) & "\""
do shell script "INSTALLER_USER=$(stat -f '%Su' $HOME) && chown -R $INSTALLER_USER \"" & (gdPath & newGeodePath) & "\""
on error
ExitWithMessage ("Moving resources failed: " & (gdPath & newResourcesPath))
end try
end try
else if installerAnswer is "Uninstall Geode" then
try
do shell script "rm \"" & (frameworkPath & geodePath) & "\""
do shell script "rm \"" & (frameworkPath & bootstrapperPath) & "\""
do shell script "rm \"" & (frameworkPath & fmodPath) & "\""
on error
ExitWithMessage ("Removing libraries failed: " & frameworkPath)
end try
try
do shell script "mv \"" & (frameworkPath & fmodOriginalPath) & "\" \"" & (frameworkPath & fmodPath) & "\""
on error
ExitWithMessage ("Restoring original fmod failed: " & (frameworkPath & fmodPath))
end try
try
do shell script "rm -r \"" & (gdPath & newGeodePath) & "\""
on error
ExitWithMessage ("Removing geode folder failed: " & (gdPath & newGeodePath))
end try
end if
do shell script "sudo rm -rf \"" & binPath & "\""

Binary file not shown.