spiegel-keyman/mac/Keyman4MacIM/localdeploy.sh
Marc Durdin 6c5b27365a chore(mac): use mac cp for -R ops
Because we don't know if mac BSD cp or GNU cp will be first on the path,
where there is ambiguity (e.g. with -R flag), we will use the macOS cp
command in /bin to ensure that we have consistent results. The
alternative would be to fixup each instance of the cp parameters so that
they work consistently with either cp command, but given these scripts
can run only on macOS, that seems unnecessary.

This replaces the earlier change in 97c6331b5.
2023-04-09 07:05:44 +07:00

51 lines
No EOL
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Please note that this build script (understandably) assumes that it is running on Mac OS X.
if [[ "${OSTYPE}" != "darwin"* ]]; then
echo "This build script will only run in a Mac environment."
exit 1
fi
IMLIBRARY_PATH="$HOME/Library/Input Methods"
display_usage() {
echo "Use localdeploy.sh to deploy Keyman Input Method app to $IMLIBRARY_PATH."
echo "This kills the existing (running) process if needed. Typically called from"
echo "the Keyman mac build script."
echo
echo "usage: localdeploy.sh keymanInputMethodAppPath"
echo
echo "where keymanInputMethodAppPath is the path to a folder which contains the"
echo "(codesigned) Keyman Input Method app to be deployed locally."
exit 1
}
if [[ $# != 1 ]]; then
display_usage
fi
KMIM_APPNAME="Keyman.app"
KM4MIM_APP_PATH="$1/$KMIM_APPNAME"
if ! [[ -d "$KM4MIM_APP_PATH" ]]; then
display_usage
fi
pid=$(pgrep Keyman)
if [[ -n $pid ]]; then
kill $pid
fi
KM4MIM_INSTALL_PATH="$IMLIBRARY_PATH/$KMIM_APPNAME"
if [[ -d "$KM4MIM_INSTALL_PATH" ]]; then
rm -Rf "$KM4MIM_INSTALL_PATH"
fi
echo "Copying $KM4MIM_APP_PATH to $IMLIBRARY_PATH..."
/bin/cp -R "$KM4MIM_APP_PATH" "$IMLIBRARY_PATH"
if [[ -d "$KM4MIM_INSTALL_PATH" ]]; then
exit 0
fi
exit 1