[rkward] macports: use the new postinstall script as default
m.eik michalke
null at kde.org
Mon Apr 16 22:55:23 UTC 2018
Git commit cbed19218d58747ca4aeebc917a23aa8e09830a5 by m.eik michalke.
Committed on 16/04/2018 at 22:53.
Pushed by meikm into branch 'master'.
use the new postinstall script as default
- the old one is still included for reference and for cases where one needs to fallback, but should be removed after a few successful releases
M +122 -2 macports/postinstall
C +0 -0 macports/postinstall_no_uninstaller [from: macports/postinstall - 100% similarity]
D +0 -123 macports/postinstall_with_uninstall
https://commits.kde.org/rkward/cbed19218d58747ca4aeebc917a23aa8e09830a5
diff --git a/macports/postinstall b/macports/postinstall
index c984988c..1f887b90 100755
--- a/macports/postinstall
+++ b/macports/postinstall
@@ -1,3 +1,123 @@
-#!/bin/sh
-/opt/rkward/bin/update-mime-database -V /opt/rkward/share/mime
+#!/usr/bin/env bash
+INSTDIR=$(echo "$2/opt/rkward" | sed 's#//#/#g')
+INSTALLER_USER=$(stat -f '%Su' "${HOME}")
+APPDIR=$(echo "$2/Applications/rkward.app" | sed 's#//#/#g')
+AGENT="org.macports.kf5-rkward"
+RKWARDSHARE="${INSTDIR}/share/rkward"
+SCRIPTDIR="${RKWARDSHARE}/macOS"
+PLISTSOURCE="${SCRIPTDIR}/${AGENT}.plist"
+AGENTSDIR="${HOME}/Library/LaunchAgents"
+PLISTTARGET="${AGENTSDIR}/${AGENT}.plist"
+UNINSTALLER="${SCRIPTDIR}/uninstall.scpt"
+UNINSTALLER_DIR="${HOME}/Applications"
+UNINSTALLER_USER_APP="${UNINSTALLER_DIR}/RKWard_uninstall.app"
+UNINSTALLER_APP="${SCRIPTDIR}/RKWard_uninstall.app"
+OLDRKWARD="$(echo "$2/Applications/RKWard" | sed 's#//#/#g')"
+
+"${INSTDIR}/bin/update-mime-database" -V "${INSTDIR}/share/mime"
+
+if [ -d "${RKWARDSHARE}" ] ; then
+ mkdir -p "${SCRIPTDIR}"
+ # generate uninstall script
+ cat <<EOF > "${UNINSTALLER}"
+set RKWardDir to "${INSTDIR}"
+set RKWardAppDir to "${APPDIR}"
+set appInTrash to POSIX path of (path to trash) & "/rkward.app/Contents/Info.plist"
+set appInDir to POSIX path of RKWardAppDir & "/Contents/Info.plist"
+set haveRKWard to false
+set haveTrash to false
+set haveApp to false
+-- the next variable is not changed by the script itself but during installation
+set manualUninstall to false
+tell application "System Events"
+ if exists file appInTrash then
+ set haveTrash to true
+ end if
+ if exists folder RKWardDir then
+ set haveRKWard to true
+ end if
+ if exists file appInDir then
+ set haveApp to true
+ end if
+end tell
+if haveTrash and haveRKWard then
+ if manualUninstall and haveApp then
+ set addToDialog to " and " & RKWardAppDir
+ else
+ set addToDialog to ""
+ end if
+ try
+ display dialog "Most of RKWard's installation resides in " & RKWardDir & ". To completely uninstall RKWard, both " & RKWardAppDir & " and " & RKWardDir & " should be deleted.\n\nIf you choose this option, all files below " & RKWardDir & addToDialog & " will removed permanently (not moved to Trash)!\n\nDo you want to irrevocably remove " & RKWardDir & addToDialog & " now?" 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
+ set removeRKWardOK to true
+ on error
+ set removeRKWardOK to false
+ display alert "Failed removing " & RKWardDir & "!"
+ end try
+ if manualUninstall and haveApp and removeRKWardOK then
+ try
+ do shell script "rm -rf \"${APPDIR}\""
+ end try
+ end if
+ if removeRKWardOK then
+ try
+ do shell script "rm -rf \"${UNINSTALLER_USER_APP}\""
+ end try
+ try
+ do shell script "rm \"${PLISTTARGET}\""
+ do shell script "launchctl remove \"${AGENT}\""
+ end try
+ end if
+ end if
+ end try
+end if
+EOF
+ # create a standalone uninstaller from a modified version without the check for trash
+ if ! [ -d "${UNINSTALLER_DIR}" ] ; then
+ sudo -u "${INSTALLER_USER}" mkdir -p "${UNINSTALLER_DIR}"
+ fi
+ sed -e "s/set manualUninstall to false/set manualUninstall to true/g" "${UNINSTALLER}" | sed -e "s/if haveTrash and haveRKWard then/if haveRKWard then/g" | osacompile -o "${UNINSTALLER_APP}"
+ sudo -u "${INSTALLER_USER}" cp -r "${UNINSTALLER_APP}" "${UNINSTALLER_DIR}"
+ # generate watch job
+ cat <<EOF > "${PLISTSOURCE}"
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>Label</key>
+ <string>${AGENT}</string>
+ <key>WatchPaths</key>
+ <array>
+ <string>~/.Trash/rkward.app</string>
+ </array>
+ <key>ProgramArguments</key>
+ <array>
+ <string>osascript</string>
+ <string>${UNINSTALLER}</string>
+ </array>
+ <key>KeepAlive</key>
+ <false/>
+ </dict>
+</plist>
+EOF
+ # link watch job
+ if [ -f "${PLISTSOURCE}" ] ; then
+ if ! [ -d "${AGENTSDIR}" ] ; then
+ sudo -u "${INSTALLER_USER}" mkdir -p "${AGENTSDIR}"
+ fi
+ if ! [ -f "${PLISTTARGET}" ] ; then
+ sudo -u "${INSTALLER_USER}" ln -s "${PLISTSOURCE}" "${PLISTTARGET}"
+ fi
+ if ! [ $(launchctl list | grep ${AGENT}) ] ; then
+ sudo -u "${INSTALLER_USER}" launchctl load -w "${PLISTTARGET}"
+ fi
+ fi
+ # finally remove the old RKWard folder if it's still present
+ if [ -d "${OLDRKWARD}" ] ; then
+ mv "${OLDRKWARD}" "${HOME}/.Trash/"
+ fi
+fi
exit 0
diff --git a/macports/postinstall b/macports/postinstall_no_uninstaller
similarity index 100%
copy from macports/postinstall
copy to macports/postinstall_no_uninstaller
diff --git a/macports/postinstall_with_uninstall b/macports/postinstall_with_uninstall
deleted file mode 100755
index 1f887b90..00000000
--- a/macports/postinstall_with_uninstall
+++ /dev/null
@@ -1,123 +0,0 @@
-#!/usr/bin/env bash
-INSTDIR=$(echo "$2/opt/rkward" | sed 's#//#/#g')
-INSTALLER_USER=$(stat -f '%Su' "${HOME}")
-APPDIR=$(echo "$2/Applications/rkward.app" | sed 's#//#/#g')
-AGENT="org.macports.kf5-rkward"
-RKWARDSHARE="${INSTDIR}/share/rkward"
-SCRIPTDIR="${RKWARDSHARE}/macOS"
-PLISTSOURCE="${SCRIPTDIR}/${AGENT}.plist"
-AGENTSDIR="${HOME}/Library/LaunchAgents"
-PLISTTARGET="${AGENTSDIR}/${AGENT}.plist"
-UNINSTALLER="${SCRIPTDIR}/uninstall.scpt"
-UNINSTALLER_DIR="${HOME}/Applications"
-UNINSTALLER_USER_APP="${UNINSTALLER_DIR}/RKWard_uninstall.app"
-UNINSTALLER_APP="${SCRIPTDIR}/RKWard_uninstall.app"
-OLDRKWARD="$(echo "$2/Applications/RKWard" | sed 's#//#/#g')"
-
-"${INSTDIR}/bin/update-mime-database" -V "${INSTDIR}/share/mime"
-
-if [ -d "${RKWARDSHARE}" ] ; then
- mkdir -p "${SCRIPTDIR}"
- # generate uninstall script
- cat <<EOF > "${UNINSTALLER}"
-set RKWardDir to "${INSTDIR}"
-set RKWardAppDir to "${APPDIR}"
-set appInTrash to POSIX path of (path to trash) & "/rkward.app/Contents/Info.plist"
-set appInDir to POSIX path of RKWardAppDir & "/Contents/Info.plist"
-set haveRKWard to false
-set haveTrash to false
-set haveApp to false
--- the next variable is not changed by the script itself but during installation
-set manualUninstall to false
-tell application "System Events"
- if exists file appInTrash then
- set haveTrash to true
- end if
- if exists folder RKWardDir then
- set haveRKWard to true
- end if
- if exists file appInDir then
- set haveApp to true
- end if
-end tell
-if haveTrash and haveRKWard then
- if manualUninstall and haveApp then
- set addToDialog to " and " & RKWardAppDir
- else
- set addToDialog to ""
- end if
- try
- display dialog "Most of RKWard's installation resides in " & RKWardDir & ". To completely uninstall RKWard, both " & RKWardAppDir & " and " & RKWardDir & " should be deleted.\n\nIf you choose this option, all files below " & RKWardDir & addToDialog & " will removed permanently (not moved to Trash)!\n\nDo you want to irrevocably remove " & RKWardDir & addToDialog & " now?" 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
- set removeRKWardOK to true
- on error
- set removeRKWardOK to false
- display alert "Failed removing " & RKWardDir & "!"
- end try
- if manualUninstall and haveApp and removeRKWardOK then
- try
- do shell script "rm -rf \"${APPDIR}\""
- end try
- end if
- if removeRKWardOK then
- try
- do shell script "rm -rf \"${UNINSTALLER_USER_APP}\""
- end try
- try
- do shell script "rm \"${PLISTTARGET}\""
- do shell script "launchctl remove \"${AGENT}\""
- end try
- end if
- end if
- end try
-end if
-EOF
- # create a standalone uninstaller from a modified version without the check for trash
- if ! [ -d "${UNINSTALLER_DIR}" ] ; then
- sudo -u "${INSTALLER_USER}" mkdir -p "${UNINSTALLER_DIR}"
- fi
- sed -e "s/set manualUninstall to false/set manualUninstall to true/g" "${UNINSTALLER}" | sed -e "s/if haveTrash and haveRKWard then/if haveRKWard then/g" | osacompile -o "${UNINSTALLER_APP}"
- sudo -u "${INSTALLER_USER}" cp -r "${UNINSTALLER_APP}" "${UNINSTALLER_DIR}"
- # generate watch job
- cat <<EOF > "${PLISTSOURCE}"
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
- <dict>
- <key>Label</key>
- <string>${AGENT}</string>
- <key>WatchPaths</key>
- <array>
- <string>~/.Trash/rkward.app</string>
- </array>
- <key>ProgramArguments</key>
- <array>
- <string>osascript</string>
- <string>${UNINSTALLER}</string>
- </array>
- <key>KeepAlive</key>
- <false/>
- </dict>
-</plist>
-EOF
- # link watch job
- if [ -f "${PLISTSOURCE}" ] ; then
- if ! [ -d "${AGENTSDIR}" ] ; then
- sudo -u "${INSTALLER_USER}" mkdir -p "${AGENTSDIR}"
- fi
- if ! [ -f "${PLISTTARGET}" ] ; then
- sudo -u "${INSTALLER_USER}" ln -s "${PLISTSOURCE}" "${PLISTTARGET}"
- fi
- if ! [ $(launchctl list | grep ${AGENT}) ] ; then
- sudo -u "${INSTALLER_USER}" launchctl load -w "${PLISTTARGET}"
- fi
- fi
- # finally remove the old RKWard folder if it's still present
- if [ -d "${OLDRKWARD}" ] ; then
- mv "${OLDRKWARD}" "${HOME}/.Trash/"
- fi
-fi
-exit 0
More information about the rkward-tracker
mailing list