[rkward] macports: added standalone uninstaller app and limited installations to /

m.eik michalke null at kde.org
Wed Apr 11 19:21:03 UTC 2018


Git commit abde0a4dbae6fce0daa7ce20ee102927ca2072b0 by m.eik michalke.
Committed on 11/04/2018 at 19:20.
Pushed by meikm into branch 'master'.

added standalone uninstaller app and limited installations to /

  - the uninstaller (~/Applications/RKWard_uninstall.app) can be run manually to remove RKWard, should the automatic method fail
  - the bundle script can now also disable the choice of volume to install to; this would result in an unusable installation, as libs are expected to be below /opt/rwkard

M  +33   -2    macports/postinstall_with_uninstall
M  +2    -0    macports/update_bundle.sh

https://commits.kde.org/rkward/abde0a4dbae6fce0daa7ce20ee102927ca2072b0

diff --git a/macports/postinstall_with_uninstall b/macports/postinstall_with_uninstall
index 9d7e15d7..c4006643 100755
--- a/macports/postinstall_with_uninstall
+++ b/macports/postinstall_with_uninstall
@@ -1,6 +1,7 @@
 #!/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"
@@ -8,6 +9,9 @@ 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"
 
 "${INSTDIR}/bin/update-mime-database" -V "${INSTDIR}/share/mime"
 
@@ -16,9 +20,14 @@ if [ -d "${RKWARDSHARE}" ] ; then
   # generate uninstall script
     cat <<EOF > "${UNINSTALLER}"
 set RKWardDir to "${INSTDIR}"
-set appInTrash to POSIX path of (path to trash) & "rkward.app/Contents/Info.plist"
+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
@@ -26,10 +35,18 @@ tell application "System Events"
   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, that directory should be deleted as well.\n\nIf you choose this option, all files below " & RKWardDir & " will not be moved to Trash but removed permanently!\n\nDo you want to remove " & RKWardDir & " 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
+    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
@@ -39,7 +56,15 @@ if haveTrash and haveRKWard then
         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}\""
@@ -49,6 +74,12 @@ if haveTrash and haveRKWard then
   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"?>
diff --git a/macports/update_bundle.sh b/macports/update_bundle.sh
index 4ad05835..238b4038 100755
--- a/macports/update_bundle.sh
+++ b/macports/update_bundle.sh
@@ -800,6 +800,7 @@ if $DOEXCPCK ; then
       echo -en "\nfixing ${TXT_BLUE}Distribution${OFF}..."
       sed -i -e "s|<title>kf5-rkward[-binarydevl]*</title>|<title>RKWard</title>|g" "${BNDLTMP}/bundle/Distribution" || warning "failed!"
       sed -i -e "s|Applications/RKWard/rkward.app|Applications/rkward.app|g" "${BNDLTMP}/bundle/Distribution" || warning "failed!"
+      sed -i -e $'s|</allowed-os-versions>|</allowed-os-versions>\\\n    <domains enable_anywhere="false" enable_currentUserHome="false" enable_localSystem="true"/>|' "${BNDLTMP}/bundle/Distribution"
       alldone
     fi
     echo -en "\nre-packing ${TXT_BLUE}stripped_$(basename ${MPKGNAME})${OFF}..."
@@ -808,6 +809,7 @@ if $DOEXCPCK ; then
     echo -en "removing temporary dir ${TXT_BLUE}${BNDLTMP}${OFF}..."
     rm -rf "${BNDLTMP}" 2>/dev/null || error "failed!"
     alldone
+    bundlesize "$(dirname ${MPKGNAME})/stripped_$(basename ${MPKGNAME})"
   else
     error "${TXT_BLUE}${BNDLTMP}${OFF} exists, can't unpack the bundle archive!"
   fi



More information about the rkward-tracker mailing list