diff --git a/macports/postinstall_with_uninstall b/macports/postinstall_with_uninstall index 036d33b4..065be301 100755 --- a/macports/postinstall_with_uninstall +++ b/macports/postinstall_with_uninstall @@ -1,73 +1,72 @@ #!/bin/bash INSTDIR="$2/opt/rkward" -INSTALLER_USER=$(stat -f '%Su' $HOME) "${INSTDIR}/bin/update-mime-database" -V "${INSTDIR}/share/mime" if [ -d "${INSTDIR}/share/rkward" ] ; then mkdir -p "${INSTDIR}/share/rkward/macOS" # generate uninstall script cat < "${INSTDIR}/share/rkward/macOS/uninstall.scpt" set RKWardDir to "${INSTDIR}" set haveRKWard to false tell application "System Events" if exists folder RKWardDir then set haveRKWard to true end if end tell if haveRKWard try display dialog "Most of RKWard's installation resides in " & RKWardDir & ". To uninstall RKWard completely that directory should be deleted as well.\n\nDo you want to remove it now?\n\nIf you choose this option, all files below " & RKWardDir & " will not be moved to Trash but removed permanently!" buttons {"No, keep for now", "Yes, completely remove"} default button "Yes, completely remove" cancel button "No, keep for now" with title "Remove RKWard completely?" with icon caution set {buttonReturned} to {button returned of result} if buttonReturned is "Yes, completely remove" then try do shell script "rm -rf \"" & RKWardDir & "\"" with administrator privileges do shell script "rm ~/Library/LaunchAgents/org.macports.kf5-rkward.plist" on error display alert "Failed removing " & RKWardDir & "!" end try end if end try end if EOF # generate watch job cat < "${INSTDIR}/share/rkward/macOS/org.macports.kf5-rkward.plist" Label org.macports.kf5-rkward WatchPaths ~/.Trash/rkward.app ProgramArguments osascript ${INSTDIR}/share/rkward/macOS/uninstall.scpt KeepAlive EOF # add watch job agent to startup script if [ $(file "$2/Applications/rkward.app/Contents/MacOS/rkward.rbackend" | grep text) ] ; then sed -i -e "1 a \ AGENT=\"org.macports.kf5-rkward\" \n\ AGENTSDIR=\"~/Library/LaunchAgents\" \n\ PLISTSOURCE=\"${INSTDIR}/share/rkward/macOS/\${AGENT}.plist\" \n\ PLISTTARGET=\"\${AGENTSDIR}/\${AGENT}.plist\" \n\ if [ -f \"\${PLISTSOURCE}\" ] ; then \n\ if ! [ -d \"\${AGENTSDIR}\" ] ; then \n\ mkdir -p \"\${AGENTSDIR}\" \n\ fi \n\ if ! [ -f \"\${PLISTTARGET}\" ] ; then \n\ ln -sf \"\${PLISTSOURCE}\" \"\${PLISTTARGET}\" \n\ fi \n\ if ! [ \$(launchctl list | grep \${AGENT}) ] ; then \n\ launchctl load -w \"\${PLISTTARGET}\" \n\ fi \n\ fi" "$2/Applications/rkward.app/Contents/MacOS/rkward.rbackend" fi fi exit 0