-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·75 lines (60 loc) · 2.36 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·75 lines (60 loc) · 2.36 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
#!/bin/bash
#
# build.sh
#
# Exit on error
set -e
if [ $# -eq 0 ] || { [ "$1" != "Debug" ] && [ "$1" != "Release" ] && [ "$1" != "Clean" ]; }; then
echo "Usage: build.sh [Debug|Release|Clean]"
exit 1
fi
# Get the path to this script
SCRIPT_PATH="$(dirname "$0")"
killall MouseFilter || true
if [ "$1" == "Clean" ]; then
echo "Cleaning build directory"
rm -rf "$SCRIPT_PATH/build"
echo "Deregistering from launchd"
(launchctl bootout GUI/$(id -u) ~/Library/LaunchAgents/com.rdinse.MouseFilter.plist \
> /dev/null 2>&1) || true
echo "Removing system files"
rm -f ~/Library/Preferences/com.rdinse.MouseFilter.plist
rm -f ~/Library/LaunchAgents/com.rdinse.MouseFilter.plist
tccutil reset Accessibility com.rdinse.MouseFilter
exit 0
fi
xcodebuild -configuration $1 build
if [ $1 == "Release" ]; then
# Create dmg
TMPDIR=$(mktemp -d)
cp -r "$SCRIPT_PATH/build/Release/MouseFilter.app" "$TMPDIR"
ln -s "/Applications" "$TMPDIR/Applications"
hdiutil create -volname "MouseFilter" -srcfolder "$TMPDIR" -ov -format UDZO \
"$SCRIPT_PATH/build/Release/MouseFilter.dmg"
rm -rf "$TMPDIR"
(cd $SCRIPT_PATH/build/Release; zip -r MouseFilter.zip MouseFilter.app)
# Put the app in quarantine in ~/Downloads to simulate a fresh download.
dlfile="$HOME/Downloads/MouseFilter.app"
uuid=$(/usr/bin/uuidgen)
url="http://${uuid}.example.com/MouseFilter.zip"
app="Safari"
date="$(printf %x $(date +%s))"
ndate=$(($(date +%s) - 978307200))
cp -r "$SCRIPT_PATH/build/Release/MouseFilter.app" "$dlfile"
/usr/bin/xattr -w com.apple.quarantine "0002;${date};${app};${uuid}" "$dlfile"
/usr/bin/sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2 \
"INSERT INTO \"LSQuarantineEvent\" VALUES('${uuid}',${ndate},'com.apple.${app}','${app}','${url}',NULL,NULL,0,NULL,'${url}',NULL);"
# Set the download url.
/usr/bin/xattr -w com.apple.metadata:kMDItemWhereFroms "${url}" "$dlfile"
# Reset accessibility permissions.
tccutil reset Accessibility com.rdinse.MouseFilter
open $SCRIPT_PATH/build/Release/
open "$(dirname "$dlfile")"
echo "Build completed. Exiting..."
exit 0
fi
if [ $1 == "Debug" ]; then
lldb build/Debug/MouseFilter.app --one-line "run" --one-line-on-crash "bt"
# Run target immediately. Quit lldb when the target quits. Print the stack trace
# on crash.
fi