-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_installer.sh
executable file
·398 lines (311 loc) · 8.34 KB
/
make_installer.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
#!/bin/bash
version=''
num_version=''
read -p "enter the branch name/version : " version
read -p "enter the version number : " num_version
# TODO: use a regex instead
if [ $version == '' ]; then
exit -1
fi;
if [ $num_version == '' ]; then
exit -1;
fi;
WINDOWS=0
MAC=0
UNKNOWN_OS=0
OS=$(echo $OSTYPE | tr '[:upper:]' '[:lower:]')
if [[ $OS == *"msys"* ]]; then
WINDOWS=1
elif [[ $OS == *"darwin"* ]]; then
MAC=1
else
UNKOWN_OS=1
fi;
PARENT_DIR=$PWD
BREAKPAD_TOOLS=$PWD/breakpad_tools/
MAVEN_DIR="$PARENT_DIR/maven_repo/"
MAVEN_SRC="$PARENT_DIR/maven_repo/ElMaven/"
MAVEN_BIN="$PARENT_DIR/maven_repo/ElMaven/bin/"
BIN="$PARENT_DIR/bin/"
MAVEN_REPO="https://github.com/ElucidataInc/ElMaven.git"
NODE_MAC="$PARENT_DIR/node_mac/"
NODE_WIN="$PARENT_DIR/node_win/"
ARCHIVE_FILE="maven.7z"
CONIFG="$PWD/config/"
PACKAGE_DATA="$PWD/packages/com.vendor.product/data/"
PACKAGE_META="$PWD/packages/com.vendor.product/meta/"
INSTALLER="El-Maven-$version"
success=$'\xe2\x9c\x93\0a'
failed=$'\xe2\x9c\x97\0a'
ERROR_MSG=''
clone()
{
if [ ! -d $MAVEN_DIR ]; then
mkdir $MAVEN_DIR
fi;
cd $MAVEN_DIR
# will not clone if the repo is already present
git clone --quiet $MAVEN_REPO &>/dev/null
if [ ! -f $PARENT_DIR/keys ]; then
ERROR_MSG='keys file not found. Crash Reporter will not work without the keys file'
return -1;
fi;
cp $PARENT_DIR/keys $MAVEN_SRC/
}
compile()
{
# the source repo does not exist. This might happen if cloning
# of repo failed
if [ ! -d $MAVEN_SRC ]; then
return -1
fi;
cd $MAVEN_SRC
git checkout develop &>/dev/null
if [ $? != 0 ]; then
ERROR_MSG='checkout to develop failed. Make sure your working dir/staging area is clean'
return -1;
fi;
git pull &>/dev/null
if [ $? != 0 ]; then
ERROR_MSG='git pull failed.'
return -1;
fi;
git checkout $version &>/dev/null
if [ $? != 0 ]; then
ERROR_MSG='git checkout failed. Make sure the the branch/version $version exists'
return -1;
fi;
./uninstall.sh &>/dev/null
find . -name "Makefile" -delete
qmake CONFIG+=release CONFIG+=force_debug_info NOTESTS=yes &>/dev/null
if [ $? != 0 ]; then
ERROR_MSG='qmake failed. Make sure it is in system path'
return -1
fi;
echo "building ......."
make --silent -j4 &>/dev/null
if [ $? != 0 ]; then
ERROR_MSG="make failed"
return -1
fi;
return 0
}
collect_runtime_plugins()
{
cd $PARENT_DIR
if [ ! -d $BIN ]; then
mkdir $BIN
fi;
cd $BIN
rm -rf *
if [ $WINDOWS -eq 1 ]; then
rsync -av --progress --exclude 'linux' --exclude 'node' --exclude 'node_bin' --exclude 'node.exe' $MAVEN_BIN .
fi;
if [ $MAC -eq 1 ]; then
rsync -av --progress --exclude 'windows' --exclude 'linux' --exclude 'node' --exclude 'node_bin' --exclude 'node.exe' $MAVEN_BIN .
fi;
if [ $MAC -eq 1 ]; then
#prepare dSYM file
dsymutil "El-MAVEN.app/Contents/MacOS/El-MAVEN" -o "El-MAVEN.dSYM"
macdeployqt El-MAVEN.app &>/dev/null
macdeployqt peakdetector.app &>/dev/null
macdeployqt crashreporter.app &>/dev/null
install_name_tool -add_rpath @executable_path/../Frameworks "El-MAVEN.app/Contents/MacOS/crashserver"
if [ $? != 0 ]; then
return -1
fi;
fi;
if [ $WINDOWS -eq 1 ]; then
libs=$(ldd El-MAVEN.exe peakdetector.exe)
if [ $? != 0 ]; then
return -1
fi;
while read -r line; do
lib=$(echo $line | sed -n 's/.*=>\s*\(.*dll\).*/\1/p')
if [[ $lib == *"bin"* ]]; then
cp $lib $BIN
fi;
done <<< "$libs"
# since Qt5.9.7, windeployqt has stopped working. Going to use some copy paste magic instead
# to get all the extra plugins required.
#windeployqt.exe --no-translations El-MAVEN.exe &>/dev/null
#if [ $? != 0 ]; then
# return -1
#fi;
qt_plugins_path=$(qmake -query QT_INSTALL_PLUGINS)
echo $qt_plugins_path
cp -r "$qt_plugins_path/platforms" .
cp -r "$qt_plugins_path/imageformats" .
cp -r "$qt_plugins_path/printsupport" .
cp -r "$qt_plugins_path/sqldrivers" .
cp -r "$qt_plugins_path/bearer" .
cp -r "$qt_plugins_path/mediaservice" .
# QtNetwork module requires extra ssl dlls to work
cp ../libs/OpenSSL/* $PWD
#generate qt.conf
touch qt.conf
echo "[Paths]\nPrefix = .\n" > qt.conf
fi;
return 0
}
strip_upload_symbols()
{
cd $BIN
echo "stripping symbols"
if [ $WINDOWS -eq 1 ]; then
$BREAKPAD_TOOLS/windows/strip_symbols.sh $BREAKPAD_TOOLS El-MAVEN.exe El-MAVEN
rm El-MAVEN.pdb
fi;
if [ $MAC -eq 1 ]; then
$BREAKPAD_TOOLS/mac/strip_symbols.sh $BREAKPAD_TOOLS "El-MAVEN.app/Contents/MacOS/El-MAVEN" El-MAVEN
rm -r *.dSYM
fi;
}
copy_node()
{
if [ $MAC -eq 1 ]; then
cp -r $NODE_MAC $BIN
fi;
if [ $WINDOWS -eq 1 ]; then
cp -r $NODE_WIN/* $BIN
fi;
return 0
}
generate_archive()
{
cd $PARENT_DIR
if [ -f $ARCHIVE_FILE ]; then
rm $ARCHIVE_FILE
fi;
if [ -f $PACKAGE_DATA/$ARCHIVE_FILE ]; then
rm $PACKAGE_DATA/$ARCHIVE_FILE
fi;
if [ $MAC -eq 1 ]; then
archivegen $ARCHIVE_FILE $BIN &>/dev/null
if [ $? != 0 ]; then
ERROR_MSG="Make sure archivegen is in system path"
return -1
fi;
fi;
if [ $WINDOWS -eq 1 ]; then
archivegen.exe $ARCHIVE_FILE $BIN &>/dev/null
if [ $? != 0 ]; then
return -1
fi;
fi;
mkdir $PACKAGE_DATA
cp $ARCHIVE_FILE $PACKAGE_DATA
return 0
}
update_version()
{
cd $PARENT_DIR
if [ $MAC -eq 1 ]; then
python update_version.py $num_version
fi;
if [ $WINDOWS -eq 1 ]; then
if hash python.exe 2>/dev/null; then
python.exe update_version.py $num_version
elif hash python2.7.exe 2>/dev/null; then
python2.7.exe update_version.py $num_version
elif hash python3.6.exe 2>/dev/null; then
python3.6.exe update_version.py $num_version
else
echo "could not find python"
return -1;
fi;
fi;
if [ $? != 0 ]; then
return -1;
fi;
return 0;
}
create_installer()
{
cd $PARENT_DIR
if [ $MAC -eq 1 ]; then
binarycreator --ignore-translations -r extras.qrc -c config/config.xml -p packages/ $INSTALLER &>/dev/null
if [ $? != 0 ]; then
ERROR_MSG="Make sure binarycreator is in system path"
return -1
fi;
fi;
if [ $WINDOWS -eq 1 ]; then
binarycreator -r extras.qrc -c config/config.xml -p packages/ $INSTALLER &>/dev/null
if [ $? != 0 ]; then
ERROR_MSG="Make sure binarycreator is in system path"
return -1
fi;
fi;
return 0
}
codesign_installer()
{
cd $PARENT_DIR
if [ $MAC -eq 1 ]; then
codesign -s "Elucidata Corporation" $INSTALLER.app &> /dev/null
if [ $? != 0 ]; then
ERROR_MSG="Make sure that the certificate name is correct"
return -1
fi;
fi;
return 0
}
clone
if [ $? != 0 ]; then
echo "ERROR: $ERROR_MSG"
exit -1
else
echo "clone $success"
fi;
compile
if [ $? != 0 ]; then
echo "build $failed "
echo "Log: $ERROR_MSG"
exit -1
else
echo "build $success"
fi;
collect_runtime_plugins
if [ $? != 0 ]; then
echo "collecting plugins $failed"
exit -1
else
echo "collecting plugins $success"
fi;
strip_upload_symbols
copy_node
if [ $? != 0 ]; then
echo "copying node $failed"
exit -1
else
echo "copying node $success"
fi;
generate_archive
if [ $? != 0 ]; then
echo "generating the archive $failed"
exit -1
else
echo "generating the archive $success"
fi;
update_version
if [ $? != 0 ]; then
echo "updating the version $failed"
exit -1
else
echo "updating the version $success"
fi;
create_installer
if [ $? != 0 ]; then
echo "creating the installer $failed"
exit -1
else
echo "creating the installer $success"
fi;
codesign_installer
if [ $? != 0 ]; then
echo "codesigning the installer $failed"
exit -1
else
echo "codesigning the installer $success"
fi;