From 55cc8659ee37595a9afccb8823c0e3687b2192f9 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Thu, 31 Mar 2022 14:50:55 +0800 Subject: [PATCH] PKG // Upgrade post-installation script to fix wrong installations. --- Installer/pkgPostInstall.sh | 18 +++++++++++++++++- Installer/pkgPreInstall.sh | 15 ++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Installer/pkgPostInstall.sh b/Installer/pkgPostInstall.sh index 9805eb5f..babb41e8 100644 --- a/Installer/pkgPostInstall.sh +++ b/Installer/pkgPostInstall.sh @@ -1,2 +1,18 @@ #!/bin/sh -~/Library/Input\ Methods/vChewing.app/Contents/MacOS/vChewing install --all +loggedInUser=$(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 + +sleep 1 + +# Second, clean the wrongfully installed contents: +rm -rf /Library/Input\ Methods/vChewing.app || true +rm -rf /Library/Keyboard\ Layouts/vChewing* || 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 diff --git a/Installer/pkgPreInstall.sh b/Installer/pkgPreInstall.sh index 82d041b5..fc3cb9a6 100644 --- a/Installer/pkgPreInstall.sh +++ b/Installer/pkgPreInstall.sh @@ -1,5 +1,18 @@ #!/bin/sh -killall vChewing +loggedInUser=$(stat -f%Su /dev/console) + +killall vChewing || true + +if [ "$loggedInUser" = 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 + rm -rf /Library/Keyboard\ Layouts/vChewing\ ETen.keylayout || true + rm -rf /Library/Keyboard\ Layouts/vChewing\ FakeSeigyou.keylayout || true + rm -rf /Library/Keyboard\ Layouts/vChewing\ IBM.keylayout || true + rm -rf /Library/Keyboard\ Layouts/vChewing\ MiTAC.keylayout || true +fi + rm -rf ~/Library/Input\ Methods/vChewing.app rm -rf ~/Library/Keyboard\ Layouts/vChewingKeyLayout.bundle rm -rf ~/Library/Keyboard\ Layouts/vChewing\ Dachen.keylayout