-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmk_dist
executable file
·447 lines (408 loc) · 12 KB
/
mk_dist
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
#!/bin/sh
#
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# Portions of this software are Copyright (c) 2024 HPC-Gridware GmbH
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
umask 022
which gtar >/dev/null 2>&1
if [ $? -eq 0 ]; then
TAR=gtar
else
TAR=tar
fi
BASEDIR=/tmp/sge6_dist
RPMSPECFILE=sge.spec
#---------------------------------------------------------------------------
#
ErrUsage()
{
echo "Usage: mk_dist -vdir vdir -version version [-basedir dir] \\"
echo " [-bin] [-common] [-arco] [-doc] [-drmaaj] binarchs ..."
echo ""
echo " -vdir vdir use subdirectory vdir to create distribution"
echo " -version <version> string to build filename of distribution"
echo " -basedir <basedir> set base directory for outputfile location"
echo " default: $BASEDIR"
echo " -tar <tarcmd> tar command which supports \"z\" option"
echo " -bin create tar.gz files from binaries in bin/,"
echo " utilbin/ and examples/jobsbin"
echo " -common create tar.gz file of \"common\" files"
echo " -arco create tar.gz file of \"arco\" files"
echo " -doc create tar.gz file of \"doc\" files"
echo " -drmaaj create tar.gz file of \"drmaa-java\" files"
echo " -rpm create RPM packages instead of tar files"
echo ""
exit 1
}
#---------------------------------------------------------------------------
#
Execute()
{
if [ "$verbose" = true ]; then
echo $*
fi
$*
if [ $? != 0 ]; then
echo
echo "Command failed: $*"
echo ""
exit 1
fi
}
ReplaceRpmPlaceholder()
{
echo "s%$1%$2%g" > sed.tmp
Execute sed -f sed.tmp $RPMSPECFILE > $RPMSPECFILE.$$
rm sed.tmp
Execute mv $RPMSPECFILE.$$ $RPMSPECFILE
}
CreateRpm() # Arguments: package arch files
{
PACKAGE=$1; shift
ARCH=$1; shift
cp scripts/rpm-template.spec "$RPMSPECFILE"
ReplaceRpmPlaceholder "#product#" "$PRODUCT"
ReplaceRpmPlaceholder "#version#" "$VERSION"
ReplaceRpmPlaceholder "#vdir#" "$VDIR"
ReplaceRpmPlaceholder "#arch#" "$ARCH"
ReplaceRpmPlaceholder "#basedir#" "$BASEDIR"
ReplaceRpmPlaceholder "#copyright#" "$COPYRIGHT"
ReplaceRpmPlaceholder "#vendor#" "$VENDOR"
ReplaceRpmPlaceholder "#packager#" "$PACKAGER"
ReplaceRpmPlaceholder "#provides#" "$PROVIDES"
ReplaceRpmPlaceholder "#summary#" "$SUMMARY"
ReplaceRpmPlaceholder "#description#" "$DESCRIPTION"
echo "%files $PACKAGE" >> $RPMSPECFILE
echo "%defattr(-,root,root)" >> $RPMSPECFILE
for i in $*; do
echo "$VDIR/$i" >> $RPMSPECFILE
done
rpmbuild -bb $RPMSPECFILE
}
#------------------------------------------------------------------------
#-------------------------------------------------------------------------
# MAIN section
#
makearco=false
makedrmaaj=false
makebin=false
maketestbin=false
makecommon=false
makedoc=false
makesgeee=false
makerpm=false
target=file
VDIR=""
VERSION=""
PRODUCT=ocs
SELECTED_ARCHS=""
VENDOR="unknown"
PACKAGER="unknown"
COPYRIGHT="SISSL"
PROVIDES="clusterscheduler"
SUMMARY="Cluster Scheduler"
DESCRIPTION="Cluster Scheduler distributes computational workload"
ARGC=$#
while [ $ARGC -gt 0 ]; do
case $1 in
-basedir)
shift
ARGC=`expr $ARGC - 1`
if [ $ARGC -lt 1 ]; then
echo ""
echo "Error: Missing argument to -basedir switch!"
echo ""
ErrUsage
fi
BASEDIR=$1
shift
ARGC=`expr $ARGC - 1`
;;
-bin)
echo "Creating tar file(s) of binaries in bin/ utilbin/ examples/jobsbin"
makebin=true
shift
ARGC=`expr $ARGC - 1`
;;
-testbin)
echo "Creating tar file(s) of test binaries in testbin/"
maketestbin=true
shift
ARGC=`expr $ARGC - 1`
;;
-common)
echo "Creating tar file with common files of distribution"
makecommon=true
shift
ARGC=`expr $ARGC - 1`
;;
-arco)
echo "Creating tar file with arco files of distribution"
makearco=true
shift
ARGC=`expr $ARGC - 1`
;;
-doc)
echo "Creating tar file with doc files of distribution"
makedoc=true
shift
ARGC=`expr $ARGC - 1`
;;
-drmaaj)
echo "Creating tar file with drmaa-java files of distribution"
makedrmaaj=true
shift
ARGC=`expr $ARGC - 1`
;;
-h|-help)
ErrUsage
;;
-tar)
shift
ARGC=`expr $ARGC - 1`
if [ $ARGC -lt 1 ]; then
echo ""
echo "Error: Missing argument to -tar switch!"
echo ""
ErrUsage
fi
TAR=$1
shift
ARGC=`expr $ARGC - 1`
;;
-vdir)
shift
ARGC=`expr $ARGC - 1`
if [ $ARGC -lt 1 ]; then
echo ""
echo "Error: Missing argument to -dir switch!"
echo ""
ErrUsage
fi
VDIR=$1
shift
ARGC=`expr $ARGC - 1`
if [ -f localext/$VDIR/mk_dist.private ]; then
. ./localext/$VDIR/mk_dist.private
fi
ARGC=$#
;;
-product)
shift
ARGC=`expr $ARGC - 1`
if [ $ARGC -lt 1 ]; then
echo ""
echo "Error: Missing argument to -product switch!"
echo ""
ErrUsage
fi
PRODUCT=$1
shift
ARGC=`expr $ARGC - 1`
;;
-version)
shift
ARGC=`expr $ARGC - 1`
if [ $ARGC -lt 1 ]; then
echo ""
echo "Error: Missing argument to -version switch!"
echo ""
ErrUsage
fi
VERSION=$1
shift
ARGC=`expr $ARGC - 1`
;;
-rpm)
echo "Creating RPM packages instead of tar files"
makerpm=true
shift
ARGC=`expr $ARGC - 1`
;;
-*)
echo ""
echo "Error: Unknown option: $1"
ErrUsage $0
;;
*)
ARGC=0
;;
esac
done
#--- END-OF-COMMANDLINE-PARSING------------------------------------------
DOC_PACKAGE="doc man"
COMMON_PACKAGE="3rd_party ckpt dtrace examples/jobs \
examples/drmaa hadoop include inst_sge \
install_qmaster install_execd \
mpi util"
ARCO_PACKAGE="dbwriter"
DRMAAJ_PACKAGE="lib/jdrmaa-1.0.jar lib/drmaa.jar"
if [ "$VERSION" = "" -o "$VDIR" = "" ]; then
ErrUsage
fi
RPMSPECFILE=$VDIR/$RPMSPECFILE
Execute mkdir -p $BASEDIR
SELECTED_ARCHS=$*
if [ $makecommon = true ]; then
# do any necessary postprocessing of the "common" package here
if [ -f localext/$VDIR/mk_dist.private.common ]; then
echo executing commands from mk_dist.private.common
. ./localext/$VDIR/mk_dist.private.common
fi
if [ $makerpm = true ]; then
CreateRpm common noarch $COMMON_PACKAGE
else
cd $VDIR
filename=$BASEDIR/${PRODUCT}-${VERSION}-common.tar.gz
echo Command: $TAR cvzf $filename $COMMON_PACKAGE
$TAR cvzf $filename $COMMON_PACKAGE
cd ..
fi
fi
if [ $makearco = true ]; then
# do any necessary postprocessing of the "arco" package here
if [ -f localext/$VDIR/mk_dist.private.arco ]; then
echo executing commands from mk_dist.private.arco
. ./localext/$VDIR/mk_dist.private.arco
fi
if [ $makerpm = true ]; then
CreateRpm arco noarch $ARCO_PACKAGE
else
cd $VDIR
filename=$BASEDIR/${PRODUCT}-${VERSION}-arco.tar.gz
echo Command: $TAR cvzf $filename $ARCO_PACKAGE
$TAR cvzf $filename $ARCO_PACKAGE
cd ..
fi
fi
if [ $makedrmaaj = true ]; then
# do any necessary postprocessing of the "drmaaj" package here
if [ -f localext/$VDIR/mk_dist.private.drmaaj ]; then
echo executing commands from mk_dist.private.drmaaj
. ./localext/$VDIR/mk_dist.private.drmaaj
fi
if [ $makerpm = true ]; then
CreateRpm drmaaj noarch $DRMAAJ_PACKAGE
else
cd $VDIR
filename=$BASEDIR/${PRODUCT}-${VERSION}-drmaaj.tar.gz
echo Command: $TAR cvzf $filename $DRMAAJ_PACKAGE
$TAR cvzf $filename $DRMAAJ_PACKAGE
cd ..
fi
fi
if [ $makedoc = true ]; then
# do any necessary postprocessing of the "doc" package here
if [ -f localext/$VDIR/mk_dist.private.doc ]; then
echo executing commands from mk_dist.private.doc
. ./localext/$VDIR/mk_dist.private.doc
fi
if [ $makerpm = true ]; then
CreateRpm doc noarch $DOC_PACKAGE
else
cd $VDIR
# copy release notes into package directory
cp doc/pdf/release-notes.pdf $BASEDIR/${PRODUCT}-${VERSION}-release-notes.pdf
# create the doc package
filename=$BASEDIR/${PRODUCT}-${VERSION}-doc.tar.gz
echo Command: $TAR cvzf $filename $DOC_PACKAGE
$TAR cvzf $filename $DOC_PACKAGE
cd ..
fi
fi
if [ $makebin = true ]; then
if [ $makerpm = true ]; then
ARCH=`$VDIR/util/arch`
if [ "`echo "$SELECTED_ARCHS" | grep $ARCH`" != "" ]; then
ADIR="bin/$ARCH utilbin/$ARCH examples/jobsbin/$ARCH lib/$ARCH"
if [ $ARCH = lx-x86 ]; then
CreateRpm bin i586 $ADIR
elif [ $ARCH = lx-amd64 ]; then
CreateRpm bin x86_64 $ADIR
else
echo "RPM packages are not supported for your architecture $ARCH!"
fi
else
echo "RPM packages can only be build on the selected architecture"
fi
else
if [ "$SELECTED_ARCHS" = "" ]; then
ErrUsage
fi
# do any necessary postprocessing of the "bin" package here
if [ -f localext/$VDIR/mk_dist.private.bin ]; then
echo executing commands from mk_dist.private.bin
. ./localext/$VDIR/mk_dist.private.bin
fi
cd $VDIR
echo creating tar.gz files for $SELECTED_ARCHS
for i in $SELECTED_ARCHS; do
if [ $i = "sol-sparc64" ]; then
ADIR="bin/$i utilbin/$i examples/jobsbin/$i lib/$i lib/sol-sparc"
else
ADIR="bin/$i utilbin/$i examples/jobsbin/$i lib/$i"
fi
filename=$BASEDIR/${PRODUCT}-${VERSION}-bin-${i}.tar.gz
echo Command: $TAR cvzf $filename $ADIR
$TAR cvzf $filename $ADIR
done
cd ..
fi
fi
if [ $maketestbin = true ]; then
if [ "$SELECTED_ARCHS" = "" ]; then
ErrUsage
fi
# do any necessary postprocessing of the "testbin" package here
if [ -f localext/$VDIR/mk_dist.private.bin ]; then
echo executing commands from mk_dist.private.bin
. ./localext/$VDIR/mk_dist.private.bin
fi
cd $VDIR
echo creating testbin tar.gz files for $SELECTED_ARCHS
for i in $SELECTED_ARCHS; do
ADIR="testbin/$i"
filename=$BASEDIR/${PRODUCT}-${VERSION}-testbin-${i}.tar.gz
echo Command: $TAR cvzf $filename $ADIR
$TAR cvzf $filename $ADIR
done
cd ..
fi
if [ -x /usr/bin/md5sum ]; then
cd $BASEDIR
/usr/bin/md5sum *.tar.gz *.pdf *.rpm >"$BASEDIR/${PRODUCT}-${VERSION}-md5sum.txt"
else
echo "unable to create file with md5 checksums"
exit 1
fi
exit 0