From 5badd9837e88a54eca98dc4ce9df399ed5d53c28 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Thu, 15 Sep 2022 14:44:03 +0800 Subject: [PATCH] PKG // Do not run certain postflight script content since macOS 12. --- Installer/pkgPostInstall.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Installer/pkgPostInstall.sh b/Installer/pkgPostInstall.sh index 8e8df3ae..adbb0cff 100644 --- a/Installer/pkgPostInstall.sh +++ b/Installer/pkgPostInstall.sh @@ -3,18 +3,22 @@ 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/"${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 +base_ver=12.0 +ver=$(sw_vers | grep ProductVersion | cut -d':' -f2 | tr -d ' ') +if [ $(echo -e $base_ver"\n"$ver | sort -V | tail -1) == "$base_ver" ] +then + # Copy the wrongfully installed contents to the right location: + 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 -sleep 1 - -# Second, clean the wrongfully installed contents: -rm -rf /Library/Input\ Methods/"${TARGET}".app || true -rm -rf /Library/Keyboard\ Layouts/"${TARGET}"* || true -sleep 1 + # Clean the wrongfully installed contents: + 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 + rm -rf /Library/Input\ Methods/"${TARGET}".app || true + rm -rf /Library/Keyboard\ Layouts/"${TARGET}"* || true + sleep 1 +fi # Finally, register the input method: /Users/"${login_user}"/Library/Input\ Methods/"${TARGET}".app/Contents/MacOS/"${TARGET}" install --all || true