forked from virtuallynathan/qpep
-
Notifications
You must be signed in to change notification settings - Fork 1
/
installer_osx.sh
106 lines (86 loc) · 2.85 KB
/
installer_osx.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
99
100
101
102
103
104
105
106
#!/bin/bash -xe
function fail() {
msg=$1
echo "$msg"
echo "***************************"
echo "**** RESULT: FAILURE ****"
echo "***************************"
exit 1
}
export QPEP_VERSION=$1
echo "************************************"
echo "**** QPEP OSX INSTALLER BUILDER ****"
echo "**** VERSION: ${QPEP_VERSION}"
echo "************************************"
echo
if [[ "${QPEP_VERSION}" -eq "" ]]; then
fail "Version not specified"
fi
echo [Prerequisites check: PLATFORM MAC]
uname -a | grep Darwin
if [[ ! "$?" -eq "0" ]]; then
fail "Not found"
fi
echo [Prerequisites check: GO]
go version
if [[ ! "$?" -eq "0" ]]; then
fail "Not found"
fi
echo [Prerequisites check: CMAKE]
cmake --version
if [[ ! "$?" -eq "0" ]]; then
fail "Not found"
fi
echo [Prerequisites check: DMGBUILD]
dmgbuild -h &> /dev/null || true
if [[ ! "$?" -eq "0" ]]; then
fail "Not found"
fi
echo [Prerequisites check: PRODUCTBUILD]
productbuild -h &> /dev/null || true
if [[ ! "$?" -eq "0" ]]; then
fail "Not found"
fi
echo [Cleanup]
cd installer-osx
rm -rf ./*.pkg
rm -rf QPep.app/Contents/MacOS/*
echo "OK"
echo [Copy artifacts]
if [[ ! -d "../build" ]]; then
fail "Error: No build directory found"
fi
if [[ ! -f "../build/qpep" ]]; then
fail "Error: No qpep executable found"
fi
if [[ ! -f "../build/qpep-tray" ]]; then
fail "Error: No qpep-tray executable found"
fi
mkdir -p QPep.app/Contents/MacOS/config
cp ../build/qpep QPep.app/Contents/MacOS/
cp ../build/qpep-tray QPep.app/Contents/MacOS/
mkdir -p Uninstaller.app/Contents/MacOS/
export QPEP_GATEWAY=192.168.1.100
export QPEP_ADDRESS=0.0.0.0
export QPEP_PORT=1443
export QPEP_BACKEND=quic-go
export QPEP_CCA=reno
export QPEP_SLOWSTART=search
envsubst < ./qpep.yml.tpl > QPep.app/Contents/MacOS/config/qpep.yml
cp ./server_cert.pem QPep.app/Contents/MacOS/server_cert.pem
envsubst < ./Info.plist.tpl > QPep.app/Contents/Info.plist
echo [Generate Install Bundle]
pkgbuild --root "QPep.app" --identifier com.project-faster.qpep --scripts Scripts --install-location "/Applications/QPep.app" DistributionInstall.pkg
echo [Generate Uninstall Bundle]
pkgbuild --root "Uninstaller.app" --identifier com.project-faster.qpep --scripts UninstallScripts --install-location "/Applications" DistributionUninstall.pkg
# for reference if needed to recreate the xml
# productbuild --synthesize --package DistributionInstall.pkg DistributionInstall.xml
# productbuild --synthesize --package DistributionUninstall.pkg DistributionUninstall.xml
echo [Generating Installer]
productbuild --distribution DistributionInstall.xml --package-path . --resources "./Resources" QPepInstaller.pkg
echo [Generating Uninstaller]
productbuild --distribution DistributionUninstall.xml --package-path . --resources "./UninstallerResources" QPepUninstall.pkg
echo "***************************"
echo "**** RESULT: SUCCESS ****"
echo "***************************"
exit 0