-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.sh
executable file
·361 lines (314 loc) · 8.12 KB
/
build.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
#!/bin/bash
# PostgreSQL Installer build system
# Dave Page, EnterpriseDB
# Common utilties
source ./common.sh
# Package Versions
source ./versions.sh
# Get the build settings
if [ ! -f ./settings.sh ];
then
_die "The is no settings.sh file present. Please copy settings.sh.in and edit as required before rebuilding."
fi
source ./settings.sh
########
# Usage
########
usage()
{
echo "Usage: $0 [Options]\n"
echo " Options:"
echo " [-skipbuild]"
echo " [-skippvtpkg]"
echo " Examples:"
echo " $0 -skipbuild -skippvtpkg"
echo " $0 -skippvtpkg"
echo ""
exit 1;
}
################################################################################
# Initialise the build system
################################################################################
_init() {
# Grab the working directory
WD=`pwd`
# Ensure we have an output directory
if [ ! -d output ];
then
mkdir output || _die "Failed to create the output directory"
fi
# Set the package versions string
PG_PACKAGE_VERSION=$PG_MAJOR_VERSION.`echo $PG_MINOR_VERSION | sed -e 's/\./-/'`
# Setup CVS
export CVS_RSH=ssh
}
################################################################################
# Check a Unix VM is accessible and can reach the buildfarm directory
################################################################################
_check_unix_vm() {
RETVAL=`ssh $1 ls $2/settings.sh 2>&1`
if [ "$RETVAL" != "$2/settings.sh" ];
then
_die "The build VM $1 is inaccessible or does not have access to the buildfarm repository at $2"
fi
# Check if chrpath exists on the given VM
HAS_CHRPATH=`ssh $1 which chrpath 2>/dev/null`
if [ x$HAS_CHRPATH == x ]; then
_die "Need to install chrpath utility in order to build the installer on the build VM $1"
fi
}
################################################################################
# Check a Windows VM is accessible and can reach the buildfarm directory
################################################################################
_check_windows_vm() {
RETVAL=`ssh $1 ls $2 2>&1`
RESULT1=`echo "$RETVAL" | grep 'No such file or directory' | wc -l`
RESULT2=`echo "$RETVAL" | grep 'Operation timed out' | wc -l`
if [ "$RESULT1" -ne "0" -o "$RESULT2" -ne "0" ];
then
_die "The build VM $1 is inaccessible or does not have access to the buildfarm repository at $2"
fi
}
################################################################################
# Rock 'n' roll
################################################################################
while [ "$#" -gt "0" ]; do
case "$1" in
-skipbuild) SKIPBUILD=$1; shift 1;;
-skippvtpkg) SKIPPVTPACKAGES=$1; shift 1;;
-h|-help) usage;;
*) echo -e "error: no such option $1. -h for help"; exit 1;;
esac
done
if [ "$SKIPBUILD" = "-skipbuild" ];
then
SKIPBUILD=1
else
SKIPBUILD=0
fi
if [ "$SKIPPVTPACKAGES" = "-skippvtpkg" ];
then
SKIPPVTPACKAGES=1
else
SKIPPVTPACKAGES=0
fi
# Check the VMs
if [ $PG_ARCH_WINDOWS_X64 = 1 ];
then
_check_windows_vm $PG_SSH_WINDOWS_X64 $PG_PATH_WINDOWS_X64
fi
# Initialise the build system
_init
cd $WD
echo "PG-INSTALLER repo details:"
echo "Branch: `git branch | sed -n -e 's/^\* \(.*\)/\1/p'`"
echo "Last commit:"
git log -n 1
echo "################################################"
echo " Build common utilities or modularized packages"
echo "################################################"
# Build each package. This may have interdepencies so must be built in order
echo "############################################################################"
echo " Build Packages"
echo "############################################################################"
# Package: Server
if [ $PG_PACKAGE_SERVER = 1 ];
then
echo "### Package: Server"
cd $WD
source ./server/build.sh
PG_BUILD_SERVER=0
if [ $SKIPBUILD = 0 ];
then
(_prep_server && _build_server)
if [ $? == 0 ]; then
PG_BUILD_SERVER=1
fi
fi
(_postprocess_server)
fi
# Package: LanguagePack
if [ $PG_PACKAGE_LANGUAGEPACK = 1 ];
then
cd $WD
source ./languagepack/build.sh
PG_BUILD_LANGUAGEPACK=0
if [ $SKIPBUILD = 0 ];
then
(_prep_languagepack && _build_languagepack)
if [ $? == 0 ]; then
PG_BUILD_LANGUAGEPACK=1
fi
fi
(_postprocess_languagepack)
fi
# Package: PEM-HTTPD
if [ $PG_PACKAGE_PEMHTTPD = 1 ];
then
echo "### Package: PEM-HTTPD"
cd $WD
source ./PEM-HTTPD/build.sh
PG_BUILD_PEMHTTPD=0
if [ $SKIPBUILD = 0 ];
then
(_prep_PEM-HTTPD && _build_PEM-HTTPD)
if [ $? == 0 ]; then
PG_BUILD_PEMHTTPD=1
fi
fi
(_postprocess_PEM-HTTPD)
fi
# Package: pgJDBC
if [ $PG_PACKAGE_PGJDBC = 1 ];
then
echo "### Package: pgJDBC"
cd $WD
source ./pgJDBC/build.sh
PG_BUILD_PGJDBC=0
if [ $SKIPBUILD = 0 ];
then
(_prep_pgJDBC && _build_pgJDBC)
if [ $? == 0 ]; then
PG_BUILD_PGJDBC=1
fi
fi
(_postprocess_pgJDBC)
fi
# Package: psqlODBC
if [ $PG_PACKAGE_PSQLODBC = 1 ];
then
echo "### Package: psqlODBC"
cd $WD
source ./psqlODBC/build.sh
PG_BUILD_PSQLODBC=0
if [ $SKIPBUILD = 0 ];
then
(_prep_psqlODBC && _build_psqlODBC)
if [ $? == 0 ]; then
PG_BUILD_PSQLODBC=1
fi
fi
(_postprocess_psqlODBC)
fi
# Package: PostGIS
if [ $PG_PACKAGE_POSTGIS = 1 ];
then
echo "### Package: PostGIS"
cd $WD
source ./PostGIS/build.sh
PG_BUILD_POSTGIS=0
if [ $SKIPBUILD = 0 ];
then
(_prep_PostGIS && _build_PostGIS)
if [ $? == 0 ]; then
PG_BUILD_POSTGIS=1
fi
fi
(_postprocess_PostGIS)
fi
# Package: Slony
if [ $PG_PACKAGE_SLONY = 1 ];
then
echo "### Package: Slony"
cd $WD
source ./Slony/build.sh
PG_BUILD_SLONY=0
if [ $SKIPBUILD = 0 ];
then
(_prep_Slony && _build_Slony)
if [ $? == 0 ]; then
PG_BUILD_SLONY=1
fi
fi
(_postprocess_Slony)
fi
# Package: Npgsql
if [ $PG_PACKAGE_NPGSQL = 1 ];
then
echo "### Package: Npgsql"
cd $WD
source ./Npgsql/build.sh
PG_BUILD_NPGSQL=0
if [ $SKIPBUILD = 0 ];
then
(_prep_Npgsql && _build_Npgsql)
if [ $? == 0 ]; then
PG_BUILD_NPGSQL=1
fi
fi
(_postprocess_Npgsql)
fi
# Package: pgAgent
if [ $PG_PACKAGE_PGAGENT = 1 ];
then
echo "### Package: pgAgent"
cd $WD
source ./pgAgent/build.sh
PG_BUILD_PGAGENT=0
if [ $SKIPBUILD = 0 ];
then
(_prep_pgAgent && _build_pgAgent)
if [ $? == 0 ]; then
PG_BUILD_PGAGENT=1
fi
fi
(_postprocess_pgAgent)
fi
# Package: pgmemcache
if [ $PG_PACKAGE_PGMEMCACHE = 1 ];
then
echo "### Package: pgmemcache"
cd $WD
source ./pgmemcache/build.sh
PG_BUILD_PGMEMCACHE=0
if [ $SKIPBUILD = 0 ];
then
(_prep_pgmemcache && _build_pgmemcache)
if [ $? == 0 ]; then
PG_BUILD_PGMEMCACHE=1
fi
fi
(_postprocess_pgmemcache)
fi
# Package: pgbouncer
if [ $PG_PACKAGE_PGBOUNCER = 1 ];
then
echo "### Package: pgbouncer"
cd $WD
source ./pgbouncer/build.sh
PG_BUILD_PGBOUNCER=0
if [ $SKIPBUILD = 0 ];
then
(_prep_pgbouncer && _build_pgbouncer)
if [ $? == 0 ]; then
PG_BUILD_PGBOUNCER=1
fi
fi
(_postprocess_pgbouncer)
fi
# Package: SQLPROTECT
if [ $PG_PACKAGE_SQLPROTECT = 1 ];
then
cd $WD
source ./sqlprotect/build.sh
PG_BUILD_SQLPROTECT=0
if [ $SKIPBUILD = 0 ];
then
(_prep_sqlprotect && _build_sqlprotect)
if [ $? == 0 ]; then
PG_BUILD_SQLPROTECT=1
fi
fi
(_postprocess_sqlprotect)
fi
# Check for private builds
if [ $SKIPPVTPACKAGES = 0 ];
then
if [ -e $WD/pvt_build.sh ];
then
[ -z "${PVT_BUILD_LOG}" ] && PVT_BUILD_LOG=$WD/output/build-pvt.log
source $WD/pvt_build.sh > "${PVT_BUILD_LOG}" 2>&1
fi
fi
# Archive the symbols
_archive_symbols