From 6ab87306d7b4986e0853ed181a4dc5be63c3ed70 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 6 Apr 2022 12:17:47 +0800 Subject: [PATCH] Pkg // Update pre/post install scripts. --- Installer/pkgPostInstall.sh | 18 ++++++++++-------- Installer/pkgPreInstall.sh | 3 +-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Installer/pkgPostInstall.sh b/Installer/pkgPostInstall.sh index babb41e8..529f53f7 100644 --- a/Installer/pkgPostInstall.sh +++ b/Installer/pkgPostInstall.sh @@ -1,18 +1,20 @@ #!/bin/sh -loggedInUser=$(stat -f%Su /dev/console) + +TARGET='vChewing' +login_user=`/usr/bin/stat -f%Su /dev/console` # First, copy the wrongfully installed contents to the right location: -cp -r /Library/Input\ Methods/vChewing.app /Users/$(stat -f%Su /dev/console)/Library/Input\ Methods/ || true -cp -r /Library/Keyboard\ Layouts/vChewing* /Users/$(stat -f%Su /dev/console)/Library/Keyboard\ Layouts/ || true -chown "$loggedInUser" /Users/$(stat -f%Su /dev/console)/Library/Input\ Methods/vChewing.app || true -chown "$loggedInUser" /Users/$(stat -f%Su /dev/console)/Library/Keyboard\ Layouts/vChewing* || true +cp -r /Library/Input\ Methods/"${TARGET}".app /Users/"${login_user}"/Library/Input\ Methods/ || true +cp -r /Library/Keyboard\ Layouts/"${TARGET}"* /Users/"${login_user}"/Library/Keyboard\ Layouts/ || true +chown "${login_user}" /Users/"${login_user}"/Library/Input\ Methods/"${TARGET}".app || true +chown "${login_user}" /Users/"${login_user}"/Library/Keyboard\ Layouts/"${TARGET}"* || true sleep 1 # Second, clean the wrongfully installed contents: -rm -rf /Library/Input\ Methods/vChewing.app || true -rm -rf /Library/Keyboard\ Layouts/vChewing* || true +rm -rf /Library/Input\ Methods/"${TARGET}".app || true +rm -rf /Library/Keyboard\ Layouts/"${TARGET}"* || true sleep 1 # Finally, register the input method: -/Users/$(stat -f%Su /dev/console)/Library/Input\ Methods/vChewing.app/Contents/MacOS/vChewing install --all || true +/Users/"${login_user}"/Library/Input\ Methods/"${TARGET}".app/Contents/MacOS/"${TARGET}" install --all || true diff --git a/Installer/pkgPreInstall.sh b/Installer/pkgPreInstall.sh index fc3cb9a6..72c22905 100644 --- a/Installer/pkgPreInstall.sh +++ b/Installer/pkgPreInstall.sh @@ -1,9 +1,8 @@ #!/bin/sh -loggedInUser=$(stat -f%Su /dev/console) killall vChewing || true -if [ "$loggedInUser" = root ]; then +if [ "${login_user}" = root ]; then rm -rf /Library/Input\ Methods/vChewing.app || true rm -rf /Library/Keyboard\ Layouts/vChewingKeyLayout.bundle || true rm -rf /Library/Keyboard\ Layouts/vChewing\ Dachen.keylayout || true