forked from pgmodeler/pgmodeler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
windeploy.sh
286 lines (242 loc) · 7.05 KB
/
windeploy.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
#!/bin/bash
QT_INSTALL_VERSION='5.6.2'
QT_BASE_VERSION='5.6'
PGSQL_VERSION='9.6'
INNOSETUP_CMD='/c/Program Files (x86)/Inno Setup 5/ISCC.exe'
LOG=windeploy.log
# Detecting current pgModeler version
DEPLOY_VER=`cat libutils/src/globalattributes.cpp | grep PGMODELER_VERSION | sed 's/PGMODELER_VERSION=QString("//g' | sed 's/"),//g'`
DEPLOY_VER=${DEPLOY_VER/PGMODELER_VERSION=\"/}
DEPLOY_VER=`echo ${DEPLOY_VER/\",/} | tr -d ' '`
DEMO_VERSION_OPT='-demo-version'
DEMO_VERSION=0
BUILD_ALL_OPT='-build-all'
BUILD_ALL=0
# Setting key paths according to the arch build (x86|x64)
# If none of the build type parameter is specified, the default is tu use x86
X64_BUILD_OPT='-x64-build'
X64_BUILD=0
X86_BUILD=1
WIN_BITS="32"
DEST_ARCH="x86"
for param in $@; do
if [[ "$param" == "$DEMO_VERSION_OPT" ]]; then
DEMO_VERSION=1
fi
if [[ "$param" == "$X64_BUILD_OPT" ]]; then
X64_BUILD=1
DEST_ARCH="x64"
WIN_BITS="64"
fi
if [[ "$param" == "$BUILD_ALL_OPT" ]]; then
BUILD_ALL=1
DEMO_VERSION=0
fi
done
# Define the base name of the binary
if [ $DEMO_VERSION = 1 ]; then
PKGNAME="pgmodeler-$DEPLOY_VER-demo-windows$WIN_BITS"
else
PKGNAME="pgmodeler-$DEPLOY_VER-windows$WIN_BITS"
fi
if [ $X64_BUILD = 1 ]; then
# Settings for x64 build
QT_ROOT="/c/Qt/Qt${QT_INSTALL_VERSION}-x64/"
QMAKE_ROOT=$QT_ROOT/bin
MINGW_ROOT="/c/msys64/mingw64/bin"
PGSQL_ROOT="/c/PostgreSQL/${PGSQL_VERSION}-x64/bin"
QMAKE_ARGS="-r -spec win32-g++ CONFIG+=release \
XML_INC+=$PGSQL_ROOT/../include \
XML_LIB=$PGSQL_ROOT/libxml2.dll \
PGSQL_INC+=$PGSQL_ROOT/../include \
PGSQL_LIB+=$PGSQL_ROOT/libpq.dll"
DEP_LIBS="$QMAKE_ROOT/icudt55.dll \
$QMAKE_ROOT/icuin55.dll \
$QMAKE_ROOT/icuuc55.dll \
$MINGW_ROOT/libgcc_s_seh-1.dll \
$MINGW_ROOT/libstdc++-6.dll \
$MINGW_ROOT/libwinpthread-1.dll \
$PGSQL_ROOT/libiconv-2.dll \
$PGSQL_ROOT/libintl-8.dll"
else
# Default setting for x86 build
QT_ROOT="/c/Qt/Qt${QT_INSTALL_VERSION}/${QT_BASE_VERSION}/mingw49_32/"
QMAKE_ROOT=$QT_ROOT/bin
QMAKE_ARGS="-r -spec win32-g++ CONFIG+=release"
MINGW_ROOT="/c/Qt/Qt${QT_INSTALL_VERSION}/Tools/mingw492_32/bin"
PGSQL_ROOT="/c/PostgreSQL/${PGSQL_VERSION}/bin"
DEP_LIBS="$QMAKE_ROOT/icudt54.dll \
$QMAKE_ROOT/icuin54.dll \
$QMAKE_ROOT/icuuc54.dll \
$QMAKE_ROOT/libgcc_s_dw2-1.dll \
$QMAKE_ROOT/libstdc++-6.dll \
$QMAKE_ROOT/libwinpthread-1.dll \
$PGSQL_ROOT/libiconv-2.dll \
$PGSQL_ROOT/libintl-8.dll"
fi
if [ $DEMO_VERSION = 1 ]; then
QMAKE_ARGS="$QMAKE_ARGS DEMO_VERSION+=true"
fi
PKGFILE=$PKGNAME.exe
GENINSTALLER=pgmodeler.exe
INSTALL_ROOT="$PWD/build"
DIST_ROOT="$PWD/dist"
ISSFILE=./installer/windows/pgmodeler.iss
QT_CONF="$INSTALL_ROOT/qt.conf"
DEP_PLUGINS_DIR="$INSTALL_ROOT/qtplugins"
PLUGINS="dummy xml2object"
# Common dependency libraries
DEP_LIBS+=" $QMAKE_ROOT/Qt5Core.dll \
$QMAKE_ROOT/Qt5Gui.dll \
$QMAKE_ROOT/Qt5Widgets.dll \
$QMAKE_ROOT/Qt5PrintSupport.dll \
$QMAKE_ROOT/Qt5Network.dll \
$QMAKE_ROOT/Qt5Svg.dll \
$PGSQL_ROOT/libxml2.dll \
$PGSQL_ROOT/libpq.dll \
$PGSQL_ROOT/libeay32.dll \
$PGSQL_ROOT/ssleay32.dll \
$PGSQL_ROOT/zlib1.dll"
#Dependency qt plugins copied to build dir
DEP_PLUGINS="imageformats/qdds.dll \
imageformats/qgif.dll \
imageformats/qicns.dll \
imageformats/qico.dll \
imageformats/qjpeg.dll \
imageformats/qsvg.dll \
imageformats/qtga.dll \
imageformats/qtiff.dll \
imageformats/qwbmp.dll \
imageformats/qwebp.dll \
platforms/qwindows.dll \
printsupport/windowsprintersupport.dll"
export PATH=$QMAKE_ROOT:$MINGW_ROOT:$PATH
clear
echo
echo "pgModeler Windows deployment script"
echo "PostgreSQL Database Modeler Project - pgmodeler.com.br"
echo "Copyright 2006-2017 Raphael A. Silva <raphael@pgmodeler.com.br>"
# Identifying Qt version
if [ -e "$QMAKE_ROOT/qmake" ]; then
QT_VER=`$QMAKE_ROOT/qmake --version | grep '[0-9].[0-9].[0-9]'`
QT_VER=${QT_VER:0:5}
fi
# If Qt was not found
if [ -z "$QT_VER" ]; then
echo
echo "** No Qt framework was found!"
echo
exit 1
else
# Checking if identified version is valid (>= 5.0.0)
if [[ "$QT_VER" < "5.0.0" ]]; then
echo
echo "** Qt framework found but in no suitable version (>= 5.0.0)!"
echo "** Installed Qt version: $QT_VER"
echo
exit 1
fi
fi
echo
echo "Deploying version: $DEPLOY_VER"
if [ $DEMO_VERSION = 1 ]; then
echo "Building demonstration version. (Found $DEMO_VERSION_OPT)"
fi
echo "Building for arch: $DEST_ARCH"
echo "Cleaning previous compilation..."
if [ $BUILD_ALL -eq 1 ]; then
rm -r $DIST_ROOT/* > $LOG 2>&1
fi
rm -r build/* > $LOG 2>&1
$MINGW_ROOT/mingw32-make.exe distclean >> $LOG 2>&1
echo "Running qmake..."
$QMAKE_ROOT/qmake.exe $QMAKE_ARGS >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Failed to execute qmake with arguments '$QMAKE_ARGS'"
echo
exit 1
fi
echo "Compiling code..."
$MINGW_ROOT/mingw32-make.exe -j7 >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Compilation failed!"
echo
exit 1
fi
echo "Deploying application..."
$MINGW_ROOT/mingw32-make.exe install >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Deployment failed!"
echo
exit 1
fi
echo "Installing dependencies..."
for dll in $DEP_LIBS; do
cp $dll $INSTALL_ROOT >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Installation failed!"
echo
exit 1
fi
done
#Creates the file build/qt.conf to bind qt plugins
mkdir -p $DEP_PLUGINS_DIR
echo "[Paths]" > $QT_CONF
echo "Prefix=." >> $QT_CONF
echo "Plugins=qtplugins" >> $QT_CONF
echo "Libraries=." >> $QT_CONF
#Copies the qt plugins to build/qtplugins
for plug in $DEP_PLUGINS; do
pdir=`dirname $plug`
mkdir -p $DEP_PLUGINS_DIR/$pdir >> $LOG 2>&1
cp $QT_ROOT/plugins/$plug $DEP_PLUGINS_DIR/$pdir >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Installation failed!"
echo
exit 1
fi
done
$MINGW_ROOT/mingw32-make.exe install >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Installation failed!"
echo
exit 1
fi
echo "Packaging installation..."
"$INNOSETUP_CMD" $ISSFILE >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Failed to create installer package!"
echo "** Proceeding with basic deployment."
mkdir $PKGNAME >> $LOG 2>&1
mv $INSTALL_ROOT/* $PKGNAME >> $LOG 2>&1
mv $PKGNAME $INSTALL_ROOT >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo "** Failed to execute basic deployment!"
exit 1
fi
echo
echo "Directory created: $PKGNAME"
else
mv $GENINSTALLER build/$PKGFILE >> $LOG 2>&1
echo "File created: $PKGFILE"
fi
mkdir -p $DIST_ROOT >> $LOG 2>&1
mv $INSTALL_ROOT/$PKGFILE $DIST_ROOT >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo "** Failed to move $PKGFILE to $DIST_ROOT!"
exit 1
fi
echo "pgModeler successfully deployed!"
echo
if [ $BUILD_ALL -eq 1 ]; then
sh windeploy.sh -demo-version
sh windeploy.sh -x64-build
sh windeploy.sh -x64-build -demo-version
fi