File: mk_dist

package info (click to toggle)
gridengine 8.1.9%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 56,880 kB
  • sloc: ansic: 432,689; java: 87,068; cpp: 31,958; sh: 29,429; jsp: 7,757; perl: 6,336; xml: 5,828; makefile: 4,701; csh: 3,928; ruby: 2,221; tcl: 1,676; lisp: 669; yacc: 519; python: 503; lex: 361; javascript: 200
file content (370 lines) | stat: -rwxr-xr-x 10,442 bytes parent folder | download | duplicates (6)
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
#!/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.
#
#  All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__

# fixme: check on univa change:
# commit 71876bf962d851ddd8806d4ce9803ec4a99ca516
# Author: Joachim Gabler <JGabler@univa.com>
# Date:   Thu Mar 31 10:15:57 2011 +0200

#     JG-2011-03-31-0: Enhancem.:   Make sure the LICENSE file is copied by distin

umask  022

if type gtar 2>/dev/null >/dev/null; then TAR=gtar
else TAR=tar
fi
BASEDIR=/tmp/sge8_dist

RPMSPECFILE=sge.spec

#---------------------------------------------------------------------------
#
ErrUsage()
{
   echo "Usage: mk_dist -vdir vdir -version version [-basedir dir] \\"
   echo "               [-bin] [-common] [-arco] [-doc] 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 "    -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
makebin=false
makecommon=false
makedoc=false
makesgeee=false
makerpm=false
target=file
VDIR=""
VERSION=""
PRODUCT=sge
SELECTED_ARCHS=""
VENDOR="unknown"
PACKAGER="unknown"
COPYRIGHT="SISSL"
PROVIDES="gridengine"
SUMMARY="Grid Engine"
DESCRIPTION="Grid Engine 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`
      ;;
   -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`
      ;;
   -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=$#
      ;;
   -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=""
COMMON_DOCS="doc/*.txt doc/*.asc doc/javadocs doc/LICENCES doc/NEWS"
# This used to include catman, but that's probably not very useful now,
# as all the relevant systems should have a man formatter.
COMMON_PACKAGE="dtrace examples/jobs \
                examples/drmaa hadoop include inst_sge install_qmaster \
                install_execd start_gui_installer \
	    man mpi pvm qmon util lib/JSV.jar lib/drmaa.jar lib/herd.jar lib/juti.jar lib/jgdi.jar"
ARCO_PACKAGE="dbwriter"

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 $COMMON_DOCS
   else
     cd $VDIR
     filename=$BASEDIR/${PRODUCT}-${VERSION}-common.tar.gz
     echo Command: $TAR cvzf $filename $COMMON_PACKAGE $COMMON_DOCS
                  $TAR cvzf $filename $COMMON_PACKAGE $COMMON_DOCS
     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 [ $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
      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

exit 0