File: MAKE_INSTALL

package info (click to toggle)
acedb 4.9.39+dfsg.02-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 33,796 kB
  • sloc: ansic: 256,989; perl: 2,803; cpp: 2,534; csh: 1,712; python: 862; sh: 658; makefile: 300; awk: 249; lex: 225; yacc: 221
file content (337 lines) | stat: -rwxr-xr-x 9,835 bytes parent folder | download | duplicates (2)
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
#!/bin/ksh
#
#                   MAKE_INSTALL
#
#   A tool to make install files for to go on the ftp site.
#
#   NOTE, you cannot use this script to make tar files for the
#   the server for acedb versions earlier than 4_8 because it
#   only produces archives of the socket server binaries.
#
#
###################################################################
#
#
# All download files should be of the pattern:
#
#        ACEDB-<package>.<version>.tar.gz
#
# where
#        <package> is currently   binary<ARCH> | source | docs | help | tools | demo
#
#        <version> is of the form "version"_"release""update", e.g. 4_8d
#
# e.g.       ACEDB-source.4_8d.tar.gz
#       ACEDB-binaryALPHA.4_7l.tar.gz
#
# The INSTALL script in wtools expects that the files will have this
# naming pattern and will probably break if this is not so.
#
#
# NOTES:
#        1) -q option doesn't do anything at the moment.     
#
#        2) When this is thoroughly tested the "-v" option needs to be
#           removed from the tar commands to cut down on output.
#
#        3) script calls wtools/aceGetVersion
#
#
#


# Set to non-NULL to turn on debug in whole script.
debug=""


#--------------------------  functions  -------------------------------

function print_usage
{
  if [[ -n $1 ]]
  then
    print
    print "Warning: $1"
  fi

  print
  print "Usage:        MAKE_INSTALL [-b|-e|-d|-h|-k|-l|-s|-t|-w] [-q] [-a <nnn>] <source_directory>"
  print
  print "  -b|-e|-d|-h|-k|-l|-s  specifies type of archive (-b is default), where:"
  print
  print "     -b  ALPHA | LINUX | DARWIN  makes a non-server binary archive for named platform"
  print "     -c  ALPHA | LINUX | DARWIN  makes a dotter, blixem & belvu binary archive for the named platform"
  print "     -e  ALPHA | LINUX | DARWIN  makes a server binary archive for named platform"
  print "     -d  makes a documents archive"
  print "     -h  makes an acedb help files archive"
  print "     -s  makes a source code archive"
  print "     -t  makes a tools code archive"
  print "     -w  makes a demo database archive"
  print
  print "  -q        MAKE_INSTALL will without asking any questions and will just fail"
  print "            if there is any doubt about overwriting files etc."
  print
  print "  -a  <nnn> specifies directory where archive should be placed, default is PWD"
  print
  print "  <source_directory> specifies directory from which archive is to be made,"
  print "                     directory should be one of the standard acedb build directories"
  print "                     named RELEASE.nnn. Program will then construct archive either"
  print "                     from RELEASE.nnn or RELEASE.nnn.BUILD"
  print

  exit 1
}

function bomb_out
{
  print
  print "Fatal Error : $1"
  print

  exit 1
}

function print_divider
{
  print
  print '====================================================================='
  print
}



#------------------------- main routine -------------------------------


# filenames
prefix='ACEDB'

srcname='source'
srcpattern='./makefile ./w*'
binname='binary'
staticbinname='STATIC_binary'
binpattern='./acediff ./giface ./tace ./tagcount ./taql ./xace ./xremote'
servername='server'
staticservername='STATIC_server'
serverpattern='./makeUserPasswd ./saceclient ./saceserver ./sgifaceserver                          ./sxaceclient'
blixemname='blixem'
staticblixemname='STATIC_blixem'
blixempattern='./blixem ' 
helpname='help'
helppattern='./*'
docname='doc'
docpattern='./*'
toolsname='tools'
toolspattern='./*'
demoname='demo'
demopattern='./*'

#tarprog='gtar'
tarprog='tar'
suffix='tar'
gzsuffix='gz'

# machine architectures
alpha='ALPHA'
linux='LINUX_4'
darwin='DARWIN'


# set some defaults
tar_type=$binname
pattern=$binpattern
architecture=$alpha
target_dir=$PWD
work_dir='/tmp'
quiet=""
currdir=$PWD


# Do the flags... (see usage string for description of switches/arguments)
while getopts :b:c:e:dhstwqa: arguments
do
  case $arguments in
    'b') case $OPTARG in
           $alpha | $linux | $darwin) architecture=$OPTARG ;;
           *) print_usage "-$arguments must be followed by: $alpha | $linux | $darwin"
         esac
         tar_type=$binname
         pattern=$binpattern ;;
    'c') case $OPTARG in
           $alpha | $linux | $darwin) architecture=$OPTARG ;;
           *) print_usage "-$arguments must be followed by: $alpha | $linux | $darwin"
         esac
         tar_type=$blixemname
         pattern=$blixempattern ;;
    'e') case $OPTARG in
           $alpha | $linux | $darwin) architecture=$OPTARG ;;
           *) print_usage "-$arguments must be followed by: $alpha | $linux | $darwin"
         esac
         tar_type=$servername
         pattern=$serverpattern ;;
    'd') tar_type=$docname
         pattern=$docpattern ;;
    'h') tar_type=$helpname
         pattern=$helppattern ;;
    's') tar_type=$srcname
         pattern=$srcpattern ;;
    't') tar_type=$toolsname
         pattern=$toolspattern ;;
    'w') tar_type=$demoname
         pattern=$demopattern ;;
    'q') quiet="yes" ;;
    'a') if [[ -d $OPTARG ]]
         then
           target_dir=$OPTARG
         else
           bomb_out "argument to -$arguments ($OPTARG) is not a directory."
         fi ;;

    # garbage input
    '?') print_usage "-$OPTARG is not a valid switch" ;;
    ':') print_usage "You forgot the argument for switch -$OPTARG" ;;
  esac
done

# Now do the remaining args...
((args_left = OPTIND - 1))                  
shift $args_left

if [[ -z $1 ]]
then
  print_usage "You did not specify a directory from which to make the install file"
elif [[ -n $2 ]]
then
  print_usage "Too many command line arguments: $*"
else
  source_dir=$1
fi


# check source directory that is to be archived.
if [[ ! -d $source_dir || ! -d $source_dir'.BUILD' ]]
then
  bomb_out "Both $source_dir & $source_dir.BUILD are required to make the archive."
fi


# Get the release number using wtools script.
verprog=$source_dir'.BUILD/wtools/aceGetVersion'
vertarget=$source_dir'.BUILD/wnq'
if [[ ! -d $vertarget || ! -f $verprog || ! -x $verprog ]]
then
  bomb_out "Can't find out acedb release version, need $verprog and $vertarget"
fi
release=$($verprog $vertarget)



if [[ -n $debug ]]
then
  print "startup values:"
  print "tar_type=$tar_type, pattern=$pattern, architecture=$architecture"
  print "source_dir=$source_dir, target_dir=$target_dir, release=$release"
fi


print_divider
print "      ACEDB build of $tar_type installation file starting..."
print_divider


# check for directory and try to cd to it.
if [[ $tar_type != $binname && $tar_type != $servername && $tar_type != $staticbinname && $tar_type != $staticservername && $tar_type != $blixemname && $tar_type != $staticblixemname ]]
then
  source_dir=$source_dir'.BUILD'
fi
if [[ -d $source_dir ]]
then
  print "Using $source_dir to make $tar_type installation file"
  print
else
  bomb_out "$source_dir is not a directory"
fi
cd $source_dir || bomb_out "cannot cd to $source_dir"


# construct file names for archives.
if [[ $tar_type = $binname || $tar_type = $servername || $tar_type = $staticbinname || $tar_type = $staticservername  || $tar_type = $blixemname || $tar_type = $staticblixemname ]]
then
  archive_name=$prefix'-'$tar_type$architecture'.'$release'.'$suffix
else
  archive_name=$prefix'-'$tar_type'.'$release'.'$suffix
fi

short_name=$archive_name
long_name=$archive_name'.'$gzsuffix
archive_name="$target_dir/$archive_name"

print "Archive will be created as $long_name"
print


# For some archives we need to cd to a specific directory to make the archive,
# a bit mucky for the bin dir, where more is required than I thought...
case $tar_type in
  $binname) tar_dir=$(ls | grep -i 'bin.'$architecture)  ;;
  $servername) tar_dir=$(ls | grep -i 'bin.'$architecture)  ;;
  $staticbinname) tar_dir=$(ls | grep -i 'bin-STATIC.'$architecture)  ;;
  $staticservername) tar_dir=$(ls | grep -i 'bin-STATIC.'$architecture)  ;;
  $blixemname) tar_dir=$(ls | grep -i 'bin.'$architecture)  ;;
  $staticblixemname) tar_dir=$(ls | grep -i 'bin-STATIC.'$architecture)  ;;
  $helpname) tar_dir='whelp' ;;
  $docname) tar_dir='wdoc' ;;
  $toolsname) tar_dir='wtools' ;;
  $demoname) tar_dir='wdemo' ;;
  *) tar_dir='./' ;;
esac
cd $tar_dir || bomb_out "Can't cd to $tar_dir"

# OK, tar up the files...
print "Creating tar file archive $short_name"
$tarprog -cvf$archive_name $pattern >/dev/null || bomb_out "tar of $tar_type files failed."
print

# For the binary archive we need to stick some extra stuff on the end of the
# archive.
if [[ $tar_type = $binname || $tar_type = $staticbinname ]]
then
  tar_dir=$source_dir'.BUILD'
  cd $currdir || bomb_out "Can't return to intial directory $currdir"
  cd $tar_dir || bomb_out "Can't cd to $tar_dir to finish $tar_type tar."

  pattern="./wspec ./wdoc ./wquery ./wscripts ./wgf ./wtools"

  $tarprog -rvf$archive_name $pattern >/dev/null || bomb_out "tar of extra $tar_type files failed."
fi

# For the server archive we also need to add some extra files

if [[ $tar_type = $servername ]]
then
  tar_dir=$source_dir'.BUILD'
  cd $currdir || bomb_out "Can't return to intial directory $currdir"
  cd $tar_dir || bomb_out "Can't cd to $tar_dir to finish $tar_type tar."

  pattern="./wspec/serverconfig.wrm ./wspec/serverpasswd.wrm ./wdoc/Socket_Server"

  $tarprog -rvf$archive_name $pattern >/dev/null || bomb_out "tar of extra $tar_type files failed."
fi

# Now check that the archive got made successfully using tar -t
$tarprog -tf$archive_name >/dev/null || bomb_out "check of tar file integrity failed."


# do the gzip...
print "Compressing $short_name into $short_name.$gzsuffix"
gzip $archive_name || bomb_out "could not run compress $archive_name"
print
archive_name=$archive_name'.'$gzsuffix


print "The installation file is stored as $archive_name"

print_divider

exit 0