This repository has been archived by the owner on Jun 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
make_openamq
executable file
·451 lines (421 loc) · 14.3 KB
/
make_openamq
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
#!/bin/bash
#
# make_openamq - OpenAMQ packager
#
# Copyright (c) 1996-2009 iMatix Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# For information on alternative licensing for OEMs, please contact
# iMatix Corporation.
#
# make_openamq [-r revision] [-b branch] [-v version] [-m model] [-c] [-r] [-s] [-a] [-p] [-i where]
#
# * revision = svn revision number, default = head
# * branch = "trunk" or "xxx" where branch name is "/branches/prod_openamq_xxx", e.g. "1.2d"
# * version = "x.yRn", default is same as current
# * model = "mtr", "mtd", "str", or "std", default is mtd
# * -c means checkout sources from SVN
# * -r means recover after a partial checkout
# * -s means just report status and exit
# * -a means automatically do svn commits
# * -p means update local project.pdl files
# * -i means install packages to svpublic.imatix.com directory
#
# Working directories
# ~/build-$BRANCH-$REVISION-$MODEL BUILD directory for this version
# ~/ibase-$BRANCH-$REVISION-$MODEL IBASE for build from svn sources
# ~/ibase-$BRANCH-$REVISION-$MODEL-kit IBASE for build from source kit
# ~/ibase-boot IBASE binary bootstrap packages
# $BUILD/OpenAMQ-$VERSION package root
#
# Prerequisites
#
# make_build.gsl must be installed into ibase-boot
#
# Part 0
#
# * If -s (status) option specified, reports status and then exits
#
# Part 1: done always
#
# * Prepare ibase-boot directory
# - if it does not exist, create from IBASE/bin after user confirms
# * Prepare the IBASE directory
# - empty it if -c (clean) option was specified
# * Prepare the BUILD directory
# - if clean option used, delete directory
# * Checks out products (foreign, base1, gsl4, base2, openamq) into BUILD
# - if clean not specified, leave old sources
# * Does boom on each product
# - does "boom all", no shortcuts when making a package
#
# Part 2: done if a version is specified
#
# * Builds source kit for each product
# * Generates a manifest.xml file in the openamq directory // should be pkgroot!
# * Updates project.pdl of openamq projects with version number
# * If -a (commit) specified, commits changes back to svn
# * Creates OpenAMQ-$VERSION package root
# * Generates readme.txt, build.sh, build.bat in package root
# * Unpacks source kits into package root and creates final source kits
# * Unpacks source kit into new package root and runs build.sh
#
croak() {
if [ -n "$*" ]; then
echo "E: $* - stop" 1>&2
else
echo "E: stop" 1>&2
fi
exit 1
}
carp() {
echo "I: $*" 1>&2
}
trap 'croak "Interrupted"' INT
trap 'croak "Terminated"' TERM
trap 'croak "Quit"' QUIT
# Set global options for script
SVN_ROOT=https://svn.imatix.com/imatix
PRODUCTS="foreign base1 gsl4 base2 openamq"
MANIFEST=manifest.xml
RUNLOG=/tmp/make_openamq_$$.log
# Set defaults for processing options
REVISION=head
BRANCH=trunk
VERSION=""
MODEL=mtd
CLEAN=0
RECOVER=0
STATUS=0
COMMIT=0
INSTALL=""
# Parse command line
while [ ! -z "$1" ]; do
if [ "$1" = "-h" ]; then
carp 'make_openamq [-r revision] [-b branch] [-v version] [-m model] [-c] [-s] [-a] [-p] [-i where]'
carp ' revision = svn revision number, default = head'
carp ' branch = "trunk" or "xxx" where branch name is "/branches/prod_openamq_xxx", e.g. "1.2d"'
carp ' version = "x.yRn", default is same as current'
carp ' model = "mtr", "mtd", "str", or "std", default is mtd'
carp ' -c means do clean checkout and build'
carp ' -r means recover after a partial checkout'
carp ' -s means just report status and exit'
carp ' -a means automatically do svn commits'
carp ' -p means patch local project.pdl files'
carp ' -i means install packages to svpublic.imatix.com directory'
exit 1;
elif [ "$1" = "-c" ]; then
CLEAN=1 # Clean checkout and rebuild
elif [ "$1" = "-r" ]; then
RECOVER=1 # Recover failed checkout, rebuild
elif [ "$1" = "-s" ]; then
STATUS=1 # Report status and then exit
elif [ "$1" = "-a" ]; then
COMMIT=1 # Automatically do svn commits
elif [ "$1" = "-p" ]; then
UPDATE=1 # Update project files
elif [ "$1" = "-i" ]; then
shift
if [ ! -z "$1" ]; then
INSTALL=$1
else
croak "use '-i stable/unstable'"
fi
elif [ "$1" = "-r" ]; then
shift
if [ ! -z "$1" ]; then
REVISION=$1
else
croak "use '-r revision'"
fi
elif [ "$1" = "-b" ]; then
shift
if [ ! -z "$1" ]; then
BRANCH=$1
else
croak "use '-b branch'"
fi
elif [ "$1" = "-v" ]; then
shift
if [ ! -z "$1" ]; then
VERSION=$1
else
croak "use '-v version'"
fi
elif [ "$1" = "-m" ]; then
shift
if [ ! -z "$1" ]; then
MODEL=$1
else
croak "use '-m model'"
fi
else
croak "invalid option '$1' - use -h to see available options"
fi
shift
done
# Set environment variables for work
MYNAME=$BRANCH-$REVISION-$MODEL
BUILD=~/build-$MYNAME
IBASE=~/ibase-$MYNAME
if [ $MODEL = "mtd" ]; then
BOOM_MODEL=debug,mt
elif [ $MODEL = "mtr" ]; then
BOOM_MODEL=release,mt
elif [ $MODEL = "std" ]; then
BOOM_MODEL=debug,st
elif [ $MODEL = "str" ]; then
BOOM_MODEL=release,st
else
croak "invalid model '$MODEL' - use mtd, mtr, std, or str"
fi
# If -p specified, update local project.pdl files & exit
if [ ! -z "$UPDATE" ]; then
if [ -z "$VERSION" ]; then
croak "Specify a version number: make_openamq -p -v X.xnx"
fi
if [ -d clients ]; then
PROJECTS="common clients server operate"
else
PROJECTS="common wireapi server shell zyre"
fi
for PROJECT in . $PROJECTS; do
perl -n -p -e 's/version = "....."/version = "'$VERSION'"/' < $PROJECT/project.pdl > _tmp
mv _tmp $PROJECT/project.pdl
done
PRODVER=`perl -n -e '/version .*= "(.*)"/ && print $1' project.pdl`
carp "in `pwd`: project.pdl patched to $PRODVER"
exit 0
fi
# Report where we'll work & what we'll do
if [ $CLEAN = 1 ]; then
carp "** doing full rebuild and installation from SVN"
else
carp "** WARNING: doing quick & dirty rebuild"
fi
if [ "$VERSION" = "" ]; then
carp "** version empty - no source kits will be produced!"
else
carp "** preparing source kits for OpenAMQ-$VERSION"
fi
carp "IBASE directory: $IBASE"
carp "build directory: $BUILD"
carp "Boom model: $BOOM_MODEL"
carp "svn revision: $REVISION"
carp "svn path root: $SVN_ROOT"
if [ $STATUS = 1 ]; then
if [ -f ~/ibase-boot/gsl ]; then
carp "found: $HOME/ibase-boot contains bootstrap binaries"
else
carp "empty: $HOME/ibase-boot is empty"
fi
if [ -d $BUILD/openamq/.svn ]; then
carp "found: $BUILD contains checked-out sources"
else
carp "empty: $BUILD is empty"
fi
if [ -f $BUILD/openamq/server/amq_server ]; then
carp "found: $BUILD contains built packages"
else
carp "empty: $BUILD not yet built"
fi
if [ -f $IBASE/lib/libamq_server.a ]; then
carp "found: $IBASE contains installation"
else
carp "empty: $IBASE is empty"
fi
exit 0
fi
# Check that ibase-boot exists
if [ ! -d ~/ibase-boot ]; then
carp "no ~/ibase-boot directory exists"
if [ -d $IBASE/bin ]; then
echo -n "Enter 'y' to create ~/ibase-boot from $IBASE/bin: "
read answer
if [ "$answer" = "y" ]; then
carp "creating ibase-boot..."
mkdir ~/ibase-boot || croak
cd $IBASE/bin
# Copy everything useful to the ibase-boot
cp lr* gsl* boom* pdl* pwl* ~/ibase-boot || croak
cp *.gsl *.pdl *.pwl ~/ibase-boot || croak
cd $HOME
fi
fi
test -d ~/ibase-boot || croak
fi
# Check required applications
for PROGRAM in boom pax zip; do
if [ -z "`which $PROGRAM`" ]; then
croak "need $PROGRAM on path to run"
fi
done
carp "**** Starting ****"
# Prepare ibase directory
# - if clean option used, then empty directory
if [ -d $IBASE -a $CLEAN = 1 ]; then
carp "in $IBASE: deleting everything..."
rm -rf $IBASE || croak
fi
if [ ! -d $IBASE ]; then
mkdir $IBASE || croak
mkdir $IBASE/bin || croak
cp ~/ibase-boot/* $IBASE/bin || croak
fi
PATH=$IBASE/bin:/usr/local/bin:/usr/bin:/bin
if [ ! -f $IBASE/bin/make_build.gsl ]; then
carp "make_build.gsl needs to be in $IBASE/bin"
carp "suggestion: copy into ~/ibase-boot and delete $IBASE"
croak
fi
# Prepare build directory
# - if directory has been checked out then update
# - if directory does not exist then checkout
# - if clean option used, then delete and checkout
if [ -d $BUILD ]; then
if [ $CLEAN = 1 ]; then
carp "in $BUILD: deleting everything..."
rm -rf $BUILD || croak
mkdir $BUILD || croak
fi
else
mkdir $BUILD || croak
fi
cd $BUILD || croak
# Checkout all products into build directory, if needed
if [ $CLEAN = 1 -o $RECOVER = 1 ]; then
for PRODUCT in $PRODUCTS; do
if [ "$BRANCH" = "trunk" ]; then
SVN_URI=$SVN_ROOT/$PRODUCT/trunk
else
SVN_URI=$SVN_ROOT/$PRODUCT/branches/prod_openamq_$BRANCH
fi
carp "in `pwd`: get '$SVN_URI' into $PRODUCT..."
svn checkout -r $REVISION $SVN_URI $PRODUCT || croak
done
fi
# If version specified, update OpenAMQ project.pdl files
if [ ! -z "$VERSION" ]; then
cd $BUILD/openamq || croak
if [ -d clients ]; then
PROJECTS="common clients server operate"
else
PROJECTS="common wireapi server shell zyre"
fi
for PROJECT in . $PROJECTS; do
perl -n -p -e 's/version = "[^"]+"/version = "'$VERSION'"/' < $PROJECT/project.pdl > _tmp
mv _tmp $PROJECT/project.pdl
done
PRODVER=`perl -n -e '/version .*= "([^"]+)"/ && print $1' project.pdl`
carp "in `pwd`: project.pdl patched to $PRODVER"
fi
# Do full rebuild for each product
for PRODUCT in $PRODUCTS; do
cd $BUILD/$PRODUCT || croak
carp "in `pwd`: boom all..."
boom all > $RUNLOG 2>&1
if [ $? -ne 0 ]; then
cat $RUNLOG
croak
fi
done
# If version not specified, we're finished now
if [ -z "$VERSION" ]; then
carp "**** Finished without making source kits ****"
exit
fi
# Determine name-version for each product
for PRODUCT in $PRODUCTS; do
cd $BUILD/$PRODUCT || croak
eval "export $PRODUCT\_version=`boom version`"
if [ -z "`eval echo \\$${PRODUCT}_version`" ]; then
croak "Unable to determine version of $PRODUCT"
fi
done
# Create package manifest
# Get real revision number
if [ "$REVISION" = "head" ]; then
REVISION=`svn info | egrep Revision | cut -f 2 -d" "`
fi
cd $BUILD/openamq || croak
echo '<?xml version="1.0"?>'> $MANIFEST
echo '<package name = "OpenAMQ" release = "'$VERSION'">' >> $MANIFEST
for PRODUCT in $PRODUCTS; do
if [ "$BRANCH" = "trunk" ]; then
SVN_URI=$SVN_ROOT/$PRODUCT/trunk
else
SVN_URI=$SVN_ROOT/$PRODUCT/branches/prod_openamq_$BRANCH
fi
PRODVER=`perl -n -e '/version .*= "(.*)"/ && print $1' $BUILD/$PRODUCT/project.pdl`
echo ' <product name = "'$PRODUCT'" url = "'$SVN_URI'" revision = "'$REVISION'" release = "'$PRODVER'" />'>> $MANIFEST
done
echo '</package>'>> $MANIFEST
# Commit new manifest and project.pdl files
if [ $COMMIT = 1 ]; then
carp "in `pwd`: svn commit of $VERSION update"
svn commit -m "[make_openamq] Prepare to release version $VERSION" || croak
else
carp "in `pwd`: svn stat (manual commit recommended):"
svn stat
fi
# Build source kit, first using distsrc in each product
for PRODUCT in $PRODUCTS; do
cd $BUILD/$PRODUCT || croak
rm -f *.tar.gz *.zip
carp "in `pwd`: boom distsrc..."
boom configure distsrc > $RUNLOG 2>&1
if [ $? -ne 0 ]; then
cat $RUNLOG
croak
fi
done
cd $BUILD
carp "in `pwd`: building OpenAMQ-$VERSION tar/zip kits..."
rm -rf OpenAMQ-$VERSION || croak
mkdir OpenAMQ-$VERSION || croak
cd OpenAMQ-$VERSION || croak
# Generate readme.txt and build.sh files for package
mv $BUILD/openamq/manifest.xml .
gsl -q -script:make_build manifest.xml
# Unzip source kits to create OpenAMQ package tree
for PRODUCT in $PRODUCTS; do
PRODVER=`eval echo \\$${PRODUCT}_version`
tar -xzf $BUILD/$PRODUCT/$PRODVER-src.tar.gz || croak
mv $PRODVER $PRODUCT
done
cd $BUILD
# Pax does tar -czf but creates POSIX-compatible tar file
pax -w OpenAMQ-$VERSION | gzip -c > OpenAMQ-${VERSION}.tar.gz || croak
zip -lqrm OpenAMQ-${VERSION}.zip OpenAMQ-$VERSION || croak
carp "in `pwd`: successfully built source kits:"
ls -l OpenAMQ-${VERSION}.tar.gz OpenAMQ-${VERSION}.zip
# Unpack the Linux source kit and do a full build
tar -xzf OpenAMQ-${VERSION}.tar.gz
cd OpenAMQ-$VERSION
rm -rf ~/ibase-$MYNAME-kit || croak
IBASE=~/ibase-$MYNAME-kit
PATH=$IBASE/bin:/usr/local/bin:/usr/bin:/bin
carp "in `pwd`: testing build from source kit"
sh build.sh > $RUNLOG 2>&1
if [ $? -ne 0 ]; then
cat $RUNLOG
croak
fi
rm -rf ~/ibase-$MYNAME-kit || croak
# SSH session must be loaded
if [ ! -z "$INSTALL" ]; then
cd $BUILD
scp OpenAMQ-${VERSION}.tar.gz OpenAMQ-${VERSION}.zip svpublic.imatix.com:/web/xiadmin/vhosts/download.imatix.com/openamq/$INSTALL/
echo "* **[https://download.imatix.com/openamq/$INSTALL/OpenAMQ-${VERSION}.tar.gz OpenAMQ-${VERSION}.tar.gz] for UNIX** - `date +%Y/%m/%d`"
echo "* **[https://download.imatix.com/openamq/$INSTALL/OpenAMQ-${VERSION}.zip OpenAMQ-${VERSION}.zip ] for Windows** - `date +%Y/%m/%d`"
fi
carp "**** Finished making & testing source kits ****"