-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.command
More file actions
executable file
·107 lines (91 loc) · 3.81 KB
/
Copy pathinstall.command
File metadata and controls
executable file
·107 lines (91 loc) · 3.81 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
set -euo pipefail
# KeyPoint only needs a Swift toolchain. Xcode's GUI is not used.
if ! command -v swift >/dev/null 2>&1; then
echo "Error: 'swift' was not found."
echo "Install Xcode Command Line Tools with:"
echo " xcode-select --install"
exit 1
fi
if ! xcode-select -p >/dev/null 2>&1; then
echo "Error: No active developer directory was found."
echo "Install Xcode Command Line Tools with:"
echo " xcode-select --install"
exit 1
fi
ROOT="$(cd "$(dirname "$0")" && pwd)"
APP_NAME="KeyPoint"
BUNDLE_ID="com.keypointapp.macos"
LEGACY_APP_NAME="Neverclick"
LEGACY_BUNDLE_ID="com.neverclick.macos"
BUILT_APP="$ROOT/dist/$APP_NAME.app"
DESTINATION_DIRECTORY="$HOME/Applications"
DESTINATION_APP="$DESTINATION_DIRECTORY/$APP_NAME.app"
LEGACY_DESTINATION_APP="$DESTINATION_DIRECTORY/$LEGACY_APP_NAME.app"
LSREGISTER="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister"
echo "Stopping running application copies..."
pkill -x "$APP_NAME" 2>/dev/null || true
pkill -x "$LEGACY_APP_NAME" 2>/dev/null || true
# Register the legacy bundle while it is still present so tccutil can resolve
# its bundle identifier before the old application is removed.
if [[ -d "$LEGACY_DESTINATION_APP" && -x "$LSREGISTER" ]]; then
echo "Registering the previous application with Launch Services..."
if ! "$LSREGISTER" -f "$LEGACY_DESTINATION_APP" >/dev/null 2>&1; then
echo "Warning: The previous application could not be registered; continuing."
fi
fi
echo "Clearing previous macOS privacy permissions..."
if command -v tccutil >/dev/null 2>&1; then
if ! tccutil reset Accessibility "$LEGACY_BUNDLE_ID" >/dev/null 2>&1; then
echo "Previous Accessibility permission was not present; continuing."
fi
if ! tccutil reset ScreenCapture "$LEGACY_BUNDLE_ID" >/dev/null 2>&1; then
echo "Previous Screen Recording permission was not present; continuing."
fi
else
echo "Warning: tccutil was not found; previous permissions could not be reset."
fi
echo "Building $APP_NAME with Swift Package Manager..."
"$ROOT/Scripts/build-app.sh"
if [[ ! -d "$BUILT_APP" ]]; then
echo "Error: Build succeeded but the app bundle was not found at:"
echo " $BUILT_APP"
exit 1
fi
echo "Installing $APP_NAME in $DESTINATION_DIRECTORY..."
mkdir -p "$DESTINATION_DIRECTORY"
rm -rf "$DESTINATION_APP"
rm -rf "$LEGACY_DESTINATION_APP"
mv "$BUILT_APP" "$DESTINATION_APP"
INSTALLED_BUNDLE_ID="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$DESTINATION_APP/Contents/Info.plist")"
if [[ "$INSTALLED_BUNDLE_ID" != "$BUNDLE_ID" ]]; then
echo "Error: Installed bundle identifier is '$INSTALLED_BUNDLE_ID', expected '$BUNDLE_ID'."
exit 1
fi
# tccutil resolves bundle identifiers through Launch Services. A newly built app
# has not been registered yet, so resetting it otherwise fails with OSStatus -10814.
echo "Registering $APP_NAME with Launch Services..."
if [[ -x "$LSREGISTER" ]]; then
"$LSREGISTER" -f "$DESTINATION_APP"
else
echo "Warning: Launch Services registration tool was not found."
fi
echo "Clearing existing macOS privacy permissions..."
if command -v tccutil >/dev/null 2>&1; then
if ! tccutil reset Accessibility "$BUNDLE_ID"; then
echo "Warning: Accessibility had no resettable permission record."
fi
if ! tccutil reset ScreenCapture "$BUNDLE_ID"; then
echo "Warning: Screen Recording had no resettable permission record."
fi
else
echo "Warning: tccutil was not found; permissions could not be reset."
fi
codesign --verify --deep --strict "$DESTINATION_APP"
echo
echo "Installed: $DESTINATION_APP"
echo "Accessibility and Screen Recording permissions were reset."
echo "KeyPoint will ask you to grant them again."
echo "Logs: $HOME/Library/Logs/KeyPoint/KeyPoint.log"
echo
open "$DESTINATION_APP"