Repository navigation
Expand file tree
/
Copy pathInstall.command
More file actions
executable file
·46 lines (46 loc) · 1.7 KB
/
Copy pathInstall.command
File metadata and controls
executable file
·46 lines (46 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd -P)"
STAGE=''
OLD=''
DEST="$HOME/Applications/ClickLilt.app"
cleanup() {
local status=$?
if [[ $status -ne 0 && -n "$OLD" && -d "$OLD" && ! -e "$DEST" ]]; then
mv "$OLD" "$DEST"
fi
[[ -z "$STAGE" ]] || rm -rf "$STAGE"
if [[ $status -ne 0 ]]; then
echo
echo 'Installation stopped. Read the error above, then run Install.command again.'
fi
if [[ -t 0 ]]; then read -r -p 'Press Return to close this window.' _ || true; fi
}
trap cleanup EXIT
[[ "$(uname -s)" == Darwin ]] || { echo 'ClickLilt requires macOS 13 or later.' >&2; exit 1; }
MAJOR="$(sw_vers -productVersion | cut -d. -f1)"
[[ "$MAJOR" -ge 13 ]] || { echo 'ClickLilt requires macOS 13 or later.' >&2; exit 1; }
if ! xcrun --find clang >/dev/null 2>&1; then
echo "Apple's Command Line Tools are required to build the app."
xcode-select --install || true
echo 'Complete the Apple installer, then double-click Install.command again.'
exit 0
fi
if /usr/bin/pgrep -x ClickLilt >/dev/null; then
echo 'Quit ClickLilt, then run Install.command again.' >&2
exit 1
fi
if [[ -e "$DEST" ]]; then
IDENTIFIER="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$DEST/Contents/Info.plist" 2>/dev/null || true)"
[[ "$IDENTIFIER" == org.clicklilt.ClickLilt ]] || { echo "$DEST belongs to another app; move it before installing." >&2; exit 1; }
fi
mkdir -p "$HOME/Applications"
STAGE="$(mktemp -d "$HOME/Applications/.ClickLilt-install.XXXXXX")"
CLICKLILT_DIST_DIR="$STAGE/build" /bin/bash "$ROOT/scripts/build_macos.sh" --app-only
if [[ -e "$DEST" ]]; then
OLD="$STAGE/previous.app"
mv "$DEST" "$OLD"
fi
mv "$STAGE/build/ClickLilt.app" "$DEST"
echo "Installed: $DEST"
open "$DEST"