forked from pgmodeler/pgmodeler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
linuxdeploy.sh
executable file
·126 lines (103 loc) · 2.63 KB
/
linuxdeploy.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
#/bin/bash
QMAKE_ROOT=/usr/bin
FALLBACK_QMAKE_ROOT=/usr/local/qt-5.0.2/5.0.2/gcc_64/bin
LOG=linuxdeploy.log
# Detecting current pgModeler version
DEPLOY_VER=`cat libutils/src/globalattributes.h | grep PGMODELER_VERSION | grep -o '[0-9].[0-9].[0-9]\(.\)*'`
DEPLOY_VER=${DEPLOY_VER/\",/}
# Identify architecture
case `uname -m` in
"x86_64")
ARCH="linux64"
QMAKE_ARGS="-r -spec linux-g++-64"
;;
*)
ARCH="linux32"
QMAKE_ARGS="-r -spec linux-g++"
;;
esac
PKGNAME="pgmodeler-$DEPLOY_VER-$ARCH"
PKGFILE=$PKGNAME.tar.gz
clear
echo
echo "pgModeler Linux deployment script"
echo "PostgreSQL Database Modeler Project - pgmodeler.com.br"
echo "Copyright 2006-2013 Raphael A. Silva <[email protected]>"
# Identifying System Qt version
if [ -e "$QMAKE_ROOT/qmake" ]; then
QT_VER_1=`$QMAKE_ROOT/qmake --version | grep -m 1 -o '[0-9].[0-9].[0-9]'`
QT_VER_1=${QT_VER_1:0:5}
fi
# Identifying Fallback Qt version
if [ -e "$FALLBACK_QMAKE_ROOT/qmake" ]; then
QT_VER_2=`$FALLBACK_QMAKE_ROOT/qmake --version | grep -m 1 -o '[0-9].[0-9].[0-9]'`
QT_VER_2=${QT_VER_2:0:5}
fi
# If Qt was not found in system path or fallback path
if [ -z "$QT_VER_1" -a -z "$QT_VER_2" ]; then
echo
echo "** No Qt framework was found!"
echo
exit 1
else
# Checking if identified versions are valid (>= 5.0.0)
if [[ "$QT_VER_1" < "5.0.0" ]]; then
if [[ "$QT_VER_2" < "5.0.0" ]]; then
if [ -z $QT_VER_2 ]; then
QT_VER_2="not found"
fi
echo
echo "** Qt framework found but in no suitable version (>= 5.0.0)!"
echo "** System Qt version: $QT_VER_1"
echo "** Fallback Qt version: $QT_VER_2"
echo
exit 1
else
# If fallback Qt is suitable then change the standard qmake root dir
QMAKE_ROOT=$FALLBACK_QMAKE_ROOT
fi
fi
fi
echo
echo "Deploying version: $DEPLOY_VER"
echo "Cleaning previous compilation..."
rm -r build/* &> $LOG
make distclean >> $LOG 2>&1
echo "Running qmake..."
$QMAKE_ROOT/qmake $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..."
make -j5 >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Compilation failed!"
echo
exit 1
fi
echo "Installing dependencies..."
make install >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Installation failed!"
echo
exit 1
fi
echo "Packaging installation..."
rm -r $PKGNAME >> $LOG 2>&1
mkdir $PKGNAME >> $LOG 2>&1
cp -r build/* $PKGNAME >> $LOG 2>&1
tar -zcvf $PKGFILE $PKGNAME >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Failed to create package!"
echo
exit 1
fi
echo "File created: $PKGFILE"
echo "pgModeler successfully deployed!"
echo