forked from pgmodeler/pgmodeler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
windeploy.sh
186 lines (156 loc) · 4.34 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
#/bin/bash
QT_VERSION='5.2.0'
PGSQL_VERSION='9.3'
QT_ROOT="/c/Qt/Qt${QT_VERSION}/${QT_VERSION}/mingw48_32/"
QMAKE_ROOT=$QT_ROOT/bin
MINGW_ROOT="/c/Qt/Qt${QT_VERSION}/Tools/mingw48_32/bin"
PGSQL_ROOT="/c/PostgreSQL/${PGSQL_VERSION}/bin"
QMAKE_ARGS="-r -spec win32-g++"
INNOSETUP_CMD='/c/Program Files (x86)/Inno Setup 5/ISCC.exe'
LOG=windeploy.log
# Detecting current pgModeler version
DEPLOY_VER=`cat libutils/src/globalattributes.h | grep PGMODELER_VERSION | grep '[0-9].[0-9].[0-9]\(.\)*'`
DEPLOY_VER=${DEPLOY_VER/PGMODELER_VERSION=\"/}
DEPLOY_VER=`echo ${DEPLOY_VER/\",/} | tr -d ' '`
BUILD_NUM=$(date '+%Y%m%d')
PKGNAME="pgmodeler-$DEPLOY_VER-windows"
WITH_BUILD_NUM='-with-build-num'
if [[ "$*" == "$WITH_BUILD_NUM" ]]; then
PKGNAME="${PKGNAME}_${BUILD_NUM}"
fi
PKGFILE=$PKGNAME.exe
GENINSTALLER=pgmodeler.exe
ISSFILE=pgmodeler.iss
QT_CONF=build/qt.conf
DEP_PLUGINS_DIR=build/qtplugins
PLUGINS="dummy xml2object"
DEP_LIBS="$QMAKE_ROOT/icudt51.dll \
$QMAKE_ROOT/icuin51.dll \
$QMAKE_ROOT/icuuc51.dll \
$QMAKE_ROOT/libgcc_s_dw2-1.dll \
$QMAKE_ROOT/libstdc++-6.dll \
$QMAKE_ROOT/libwinpthread-1.dll \
$QMAKE_ROOT/libxml2-2.dll \
$QMAKE_ROOT/libiconv-2.dll \
$QMAKE_ROOT/Qt5Core.dll \
$QMAKE_ROOT/Qt5Gui.dll \
$QMAKE_ROOT/Qt5Widgets.dll \
$QMAKE_ROOT/Qt5PrintSupport.dll \
$PGSQL_ROOT/libpq.dll \
$PGSQL_ROOT/libintl.dll \
$PGSQL_ROOT/libeay32.dll \
$PGSQL_ROOT/ssleay32.dll \
$PGSQL_ROOT/zlib1.dll"
#Dependency qt plugins copied to build dir
DEP_PLUGINS="imageformats/qgif.dll \
imageformats/qico.dll \
imageformats/qjpeg.dll \
imageformats/qmng.dll \
imageformats/qsvg.dll \
imageformats/qtga.dll \
imageformats/qtiff.dll \
imageformats/qwbmp.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-2014 Raphael A. Silva <rkhaotix@gmail.com>"
# 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"
echo "Cleaning previous compilation..."
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 -j5 >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Compilation failed!"
echo
exit 1
fi
echo "Installing dependencies..."
for dll in $DEP_LIBS; do
cp $dll build/ >> $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 $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
#Fixing the pgModeler plugin deployment.
#Moving dlls from build/plugins/[PLUGIN]/build to build/plugins/[PLUGIN]
for plugin in $PLUGINS; do
mv build/plugins/$plugin/build/* build/plugins/$plugin >> $LOG 2>&1
rm -r build/plugins/$plugin/build/ >> $LOG 2>&1
done
if [ $? -ne 0 ]; then
echo
echo "** Installation failed!"
echo
exit 1
fi
echo "Packaging installation..."
rm -r $PKGNAME >> $LOG 2>&1
"$INNOSETUP_CMD" $ISSFILE >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Failed to create package!"
echo
exit 1
fi
mv $GENINSTALLER $PKGFILE >> $LOG 2>&1
echo "File created: $PKGFILE"
echo "pgModeler successfully deployed!"
echo