forked from pgmodeler/pgmodeler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macdeploy.sh
executable file
·167 lines (137 loc) · 4.66 KB
/
macdeploy.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
#!/bin/bash
USR=`whoami`
PGSQL_ROOT=/Library/PostgreSQL/13
QT_ROOT=/Users/$USR/Qt/5.15.2/clang_64
QMAKE_ARGS="pgmodeler.pro -r CONFIG+=x86_64 CONFIG+=release -spec macx-clang"
LOG=macdeploy.log
# Detecting current pgModeler version
DEPLOY_VER=`cat libs/libutils/src/globalattributes.cpp | grep PgModelerVersion | sed 's/.*PgModelerVersion=QString("//g' | sed 's/")//g' | sed 's/^ *//g'`
BUILD_NUM=`date '+%Y%m%d'`
DEMO_VERSION_OPT='-demo-version'
DEMO_VERSION=0
SNAPSHOT_OPT='-snapshot'
SNAPSHOT=0
for param in $@; do
if [[ "$param" == "$DEMO_VERSION_OPT" ]]; then
DEMO_VERSION=1
QMAKE_ARGS="$QMAKE_ARGS DEMO_VERSION+=true"
fi
if [[ "$param" == "$SNAPSHOT_OPT" ]]; then
SNAPSHOT=1
QMAKE_ARGS="$QMAKE_ARGS SNAPSHOT_BUILD+=true"
DEPLOY_VER="${DEPLOY_VER}_snapshot${BUILD_NUM}"
fi
done
if [ $DEMO_VERSION = 1 ]; then
PKGNAME="pgmodeler-$DEPLOY_VER-demo-macos"
else
PKGNAME="pgmodeler-$DEPLOY_VER-macos"
fi
PKGFILE=$PKGNAME.dmg
APPNAME=pgmodeler
INSTALL_ROOT="$PWD/build"
APP_PREFIX="Applications"
BUNDLE="$INSTALL_ROOT/$APP_PREFIX/$APPNAME.app"
clear
echo
echo "pgModeler macOS deployment script"
echo "PostgreSQL Database Modeler Project - pgmodeler.io"
echo "Copyright 2006-2021 Raphael A. Silva <[email protected]>"
# Identifying System Qt version
if [ -e "$QT_ROOT/bin/qmake" ]; then
QT_VER=`$QT_ROOT/bin/qmake --version | grep -m 1 -o -E '[0-9]\.[0-9]+\.[0-9]+'`
QT_VER=${QT_VER:0:6}
fi
# If Qt was not found in system path
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 "Qt version detected: $QT_VER"
if [ $SNAPSHOT = 1 ]; then
echo "Building snapshot version. (Found $SNAPSHOT_OPT)"
fi
if [ $DEMO_VERSION = 1 ]; then
echo "Building demonstration version. (Found $DEMO_VERSION_OPT)"
fi
echo "Cleaning previous compilation..."
rm -r $INSTALL_ROOT/* &> $LOG
mkdir -p ./dist >> $LOG 2>&1
make distclean >> $LOG 2>&1
echo "Running qmake..."
$QT_ROOT/bin/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 -j6 >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Compilation failed!"
echo
exit 1
fi
echo "Installing dependencies..."
make install INSTALL_ROOT=$INSTALL_ROOT >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Installation failed!"
echo
exit 1
fi
echo "Packaging installation..."
# Deploy the Qt libraries onto app bundle
$QT_ROOT/bin/macdeployqt $BUNDLE -executable=$BUNDLE/Contents/MacOS/pgmodeler-ch -executable=$BUNDLE/Contents/MacOS/pgmodeler-cli -executable=$BUNDLE/Contents/MacOS/pgmodeler-se >> $LOG 2>&1
cp $PGSQL_ROOT/lib/libpq.5.dylib $BUNDLE/Contents/Frameworks >> $LOG 2>&1
cp $PGSQL_ROOT/lib/libssl.1.* $BUNDLE/Contents/Frameworks >> $LOG 2>&1
cp $PGSQL_ROOT/lib/libcrypto.1.* $BUNDLE/Contents/Frameworks >> $LOG 2>&1
# Fixing the support of ssl by forcing the usage of the bundled libpq
install_name_tool -change "@loader_path/../lib/libcrypto.1.1.dylib" "@loader_path/../Frameworks/libcrypto.1.1.dylib" $BUNDLE/Contents/Frameworks/libssl.1.1.dylib >> $LOG 2>&1
install_name_tool -change "@loader_path/../lib/libcrypto.1.1.dylib" "@loader_path/../Frameworks/libcrypto.1.1.dylib" $BUNDLE/Contents/Frameworks/libpq.5.dylib >> $LOG 2>&1
install_name_tool -change "@loader_path/../lib/libssl.1.1.dylib" "@loader_path/../Frameworks/libssl.1.1.dylib" $BUNDLE/Contents/Frameworks/libpq.5.dylib >> $LOG 2>&1
install_name_tool -change libpq.5.dylib "@loader_path/../Frameworks/libpq.5.dylib" $BUNDLE/Contents/Frameworks/libconnector.dylib >> $LOG 2>&1
# Creates an empty dmg file named
cp installer/macosx/installer_icon.icns $INSTALL_ROOT/.VolumeIcon.icns >> $LOG 2>&1
mv $BUNDLE $INSTALL_ROOT >> $LOG 2>&1
rm -r "$INSTALL_ROOT/$APP_PREFIX" >> $LOG 2>&1
ln -s /Applications $INSTALL_ROOT/Applications >> $LOG 2>&1
rm $PKGFILE >> $LOG 2>&1
hdiutil create -format UDRW -fs HFS+ $PKGFILE -volname $APPNAME -srcfolder $INSTALL_ROOT >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Failed to create package!"
echo
exit 1
fi
echo "Updating package default icon..."
open $PKGFILE --hide >> $LOG 2>&1
sleep 3
SetFile -a C /Volumes/$APPNAME >> $LOG 2>&1
umount /Volumes/$APPNAME >> $LOG 2>&1
if [ $? -ne 0 ]; then
echo
echo "** Failed to update package icon!"
echo
exit 1
fi
mv $PKGFILE ./dist/ >> $LOG 2>&1
PKGFILE="dist/$PKGFILE"
echo "File created: $PKGFILE"
echo "pgModeler successfully deployed!"
echo