PKG // Upgrade post-installation script to fix wrong installations.

This commit is contained in:
ShikiSuen 2022-03-31 14:50:55 +08:00
parent 0a69389743
commit 5689687003
2 changed files with 31 additions and 2 deletions

View File

@ -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

View File

@ -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