-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathinstall-mac.sh
98 lines (74 loc) · 3.65 KB
/
install-mac.sh
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
#!/bin/bash
set -e
pushd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null
_ID='owon-vds-tiny'
_NAME='OWON VDS1022'
_FULLNAME='OWON VDS1022 Oscilloscope'
_VENDOR='Copyright (C) Fujian Lilliput Optoelectronics Technology Co.,Ltd'
_SUMMARY='Application for the OWON VDS1022 oscilloscope'
_HOMEPAGE='https://github.com/florentbr/OWON-VDS1022'
_VERSION=$(<./version.txt)
_ARCH=$(uname -m)
write () {
echo -e "$(</dev/stdin)" > "$1"
[ -z "$2" ] || chmod "$2" "$1"
}
raise () {
printf "Error: $1\n\n" >&2
exit 1
}
echo "==========================================================="
echo " Install ${_NAME} ${_VERSION} "
echo " ${_HOMEPAGE} "
echo "==========================================================="
echo "Check environement ..."
[ $EUID -eq 0 ] || raise "This script requires eleveted privileges."
[ -d /Applications ] || raise "Folder /Applications missing"
[ -d lib/mac/$_ARCH ] || raise "Architecture not supported: ${_ARCH}"
echo "Locate Java Runtime ..."
JAVA_HOME=$(/usr/libexec/java_home 2>/dev/null || true)
[ -d "$JAVA_HOME" ] || raise "Java not installed."
echo "$JAVA_HOME"
echo "Install to /Applications/$_NAME.app ..."
rm -fr "/Applications/$_NAME"*.app
mkdir -p "/Applications/$_NAME.app/Contents"/{MacOS,Resources}
mkdir -p "/Applications/$_NAME.app/Contents"/Resources/{api,doc,fwr,lib}
cp version.txt "/Applications/$_NAME.app/Contents/Resources/"
cp ico/icon.icns "/Applications/$_NAME.app/Contents/Resources/"
cp fwr/*.bin "/Applications/$_NAME.app/Contents/Resources/fwr/"
cp lib/*.jar "/Applications/$_NAME.app/Contents/Resources/lib/"
cp lib/mac/$_ARCH/*.dylib "/Applications/$_NAME.app/Contents/Resources/lib/"
cp -r doc/* "/Applications/$_NAME.app/Contents/Resources/doc/"
write "/Applications/$_NAME.app/Contents/MacOS/launch" +x <<EOF
#!/bin/bash
cd '/Applications/$_NAME.app/Contents/Resources'
/usr/libexec/java_home --exec java -Xdock:name='$_NAME' -Xdock:icon=icon.icns -cp 'lib/*' com.owon.vds.tiny.Main
EOF
write "/Applications/$_NAME.app/Contents/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key> <string>${_ID}</string>
<key>CFBundleDisplayName</key> <string>${_FULLNAME}</string>
<key>CFBundleName</key> <string>${_FULLNAME}</string>
<key>CFBundleGetInfoString</key> <string>${_SUMMARY}</string>
<key>CFBundleVersion</key> <string>${_VERSION}</string>
<key>CFBundleShortVersionString</key> <string>${_VERSION}</string>
<key>CFBundleExecutable</key> <string>launch</string>
<key>CFBundleIconFile</key> <string>icon.icns</string>
<key>CFBundleDevelopmentRegion</key> <string>English</string>
<key>CFBundleInfoDictionaryVersion</key> <string>6.0</string>
<key>CFBundlePackageType</key> <string>APPL</string>
<key>CSResourcesFileMapped</key> <true/>
<key>LSRequiresCarbon</key> <true/>
<key>NSHumanReadableCopyright</key> <string>${_VENDOR}</string>
<key>NSPrincipalClass</key> <string>NSApplication</string>
<key>NSHighResolutionCapable</key> <true/>
</dict>
</plist>
EOF
echo 'Initialize "~/Library/Application Support/OWON VDS1022" ...'
rm -fr /Users/*/.owon-vds-tiny
rm -f /Users/*/"Library/Application Support/$_NAME"/preferences*
printf "\nSUCCESS !\n"