| 1 |
#!/bin/ksh |
| 2 |
# |
| 3 |
# MAKE_INSTALL |
| 4 |
# |
| 5 |
# A tool to make install files for to go on the ftp site. |
| 6 |
# |
| 7 |
# NOTE, you cannot use this script to make tar files for the |
| 8 |
# the server for acedb versions earlier than 4_8 because it |
| 9 |
# only produces archives of the socket server binaries. |
| 10 |
# |
| 11 |
# |
| 12 |
################################################################### |
| 13 |
# |
| 14 |
# |
| 15 |
# All download files should be of the pattern: |
| 16 |
# |
| 17 |
# ACEDB-<package>.<version>.tar.gz |
| 18 |
# |
| 19 |
# where |
| 20 |
# <package> is currently binary<ARCH> | source | docs | help | tools | demo |
| 21 |
# |
| 22 |
# <version> is of the form "version"_"release""update", e.g. 4_8d |
| 23 |
# |
| 24 |
# e.g. ACEDB-source.4_8d.tar.gz |
| 25 |
# ACEDB-binaryALPHA.4_7l.tar.gz |
| 26 |
# |
| 27 |
# The INSTALL script in wtools expects that the files will have this |
| 28 |
# naming pattern and will probably break if this is not so. |
| 29 |
# |
| 30 |
# |
| 31 |
# NOTES: |
| 32 |
# 1) -q option doesn't do anything at the moment. |
| 33 |
# |
| 34 |
# 2) When this is thoroughly tested the "-v" option needs to be |
| 35 |
# removed from the tar commands to cut down on output. |
| 36 |
# |
| 37 |
# 3) script calls wtools/aceGetVersion |
| 38 |
# |
| 39 |
# |
| 40 |
# |
| 41 |
|
| 42 |
|
| 43 |
# Set to non-NULL to turn on debug in whole script. |
| 44 |
debug="" |
| 45 |
|
| 46 |
|
| 47 |
#-------------------------- functions ------------------------------- |
| 48 |
|
| 49 |
function print_usage |
| 50 |
{ |
| 51 |
if [[ -n $1 ]] |
| 52 |
then |
| 53 |
print |
| 54 |
print "Warning: $1" |
| 55 |
fi |
| 56 |
|
| 57 |
print |
| 58 |
print "Usage: MAKE_INSTALL [-b|-e|-d|-h|-k|-l|-s|-t|-w] [-q] [-a <nnn>] <source_directory>" |
| 59 |
print |
| 60 |
print " -b|-e|-d|-h|-k|-l|-s specifies type of archive (-b is default), where:" |
| 61 |
print |
| 62 |
print " -b ALPHA | LINUX | DARWIN makes a non-server binary archive for named platform" |
| 63 |
print " -c ALPHA | LINUX | DARWIN makes a dotter, blixem & belvu binary archive for the named platform" |
| 64 |
print " -e ALPHA | LINUX | DARWIN makes a server binary archive for named platform" |
| 65 |
print " -d makes a documents archive" |
| 66 |
print " -h makes an acedb help files archive" |
| 67 |
print " -s makes a source code archive" |
| 68 |
print " -t makes a tools code archive" |
| 69 |
print " -w makes a demo database archive" |
| 70 |
print |
| 71 |
print " -q MAKE_INSTALL will without asking any questions and will just fail" |
| 72 |
print " if there is any doubt about overwriting files etc." |
| 73 |
print |
| 74 |
print " -a <nnn> specifies directory where archive should be placed, default is PWD" |
| 75 |
print |
| 76 |
print " <source_directory> specifies directory from which archive is to be made," |
| 77 |
print " directory should be one of the standard acedb build directories" |
| 78 |
print " named RELEASE.nnn. Program will then construct archive either" |
| 79 |
print " from RELEASE.nnn or RELEASE.nnn.BUILD" |
| 80 |
print |
| 81 |
|
| 82 |
exit 1 |
| 83 |
} |
| 84 |
|
| 85 |
function bomb_out |
| 86 |
{ |
| 87 |
print |
| 88 |
print "Fatal Error : $1" |
| 89 |
print |
| 90 |
|
| 91 |
exit 1 |
| 92 |
} |
| 93 |
|
| 94 |
function print_divider |
| 95 |
{ |
| 96 |
print |
| 97 |
print '=====================================================================' |
| 98 |
print |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
#------------------------- main routine ------------------------------- |
| 104 |
|
| 105 |
|
| 106 |
# filenames |
| 107 |
prefix='ACEDB' |
| 108 |
|
| 109 |
srcname='source' |
| 110 |
srcpattern='./makefile ./w*' |
| 111 |
binname='binary' |
| 112 |
staticbinname='STATIC_binary' |
| •113 |
binpattern='./acediff ./giface ./tace ./tagcount ./taql ./xace ./xremote' |
| 114 |
servername='server' |
| 115 |
staticservername='STATIC_server' |
| 116 |
serverpattern='./makeUserPasswd ./saceclient ./saceserver ./sgifaceserver ./sxaceclient' |
| 117 |
blixemname='blixem' |
| 118 |
staticblixemname='STATIC_blixem' |
| •119 |
blixempattern='./blixem ' |
| 120 |
helpname='help' |
| 121 |
helppattern='./*' |
| 122 |
docname='doc' |
| 123 |
docpattern='./*' |
| 124 |
toolsname='tools' |
| 125 |
toolspattern='./*' |
| 126 |
demoname='demo' |
| 127 |
demopattern='./*' |
| 128 |
|
| 129 |
#tarprog='gtar' |
| 130 |
tarprog='tar' |
| 131 |
suffix='tar' |
| 132 |
gzsuffix='gz' |
| 133 |
|
| 134 |
# machine architectures |
| 135 |
alpha='ALPHA' |
| 136 |
linux='LINUX_4' |
| 137 |
darwin='DARWIN' |
| 138 |
|
| 139 |
|
| 140 |
# set some defaults |
| 141 |
tar_type=$binname |
| 142 |
pattern=$binpattern |
| 143 |
architecture=$alpha |
| 144 |
target_dir=$PWD |
| 145 |
work_dir='/tmp' |
| 146 |
quiet="" |
| 147 |
currdir=$PWD |
| 148 |
|
| 149 |
|
| 150 |
# Do the flags... (see usage string for description of switches/arguments) |
| 151 |
while getopts :b:c:e:dhstwqa: arguments |
| 152 |
do |
| 153 |
case $arguments in |
| 154 |
'b') case $OPTARG in |
| 155 |
$alpha | $linux | $darwin) architecture=$OPTARG ;; |
| 156 |
*) print_usage "-$arguments must be followed by: $alpha | $linux | $darwin" |
| 157 |
esac |
| 158 |
tar_type=$binname |
| 159 |
pattern=$binpattern ;; |
| 160 |
'c') case $OPTARG in |
| 161 |
$alpha | $linux | $darwin) architecture=$OPTARG ;; |
| 162 |
*) print_usage "-$arguments must be followed by: $alpha | $linux | $darwin" |
| 163 |
esac |
| 164 |
tar_type=$blixemname |
| 165 |
pattern=$blixempattern ;; |
| 166 |
'e') case $OPTARG in |
| 167 |
$alpha | $linux | $darwin) architecture=$OPTARG ;; |
| 168 |
*) print_usage "-$arguments must be followed by: $alpha | $linux | $darwin" |
| 169 |
esac |
| 170 |
tar_type=$servername |
| 171 |
pattern=$serverpattern ;; |
| 172 |
'd') tar_type=$docname |
| 173 |
pattern=$docpattern ;; |
| 174 |
'h') tar_type=$helpname |
| 175 |
pattern=$helppattern ;; |
| 176 |
's') tar_type=$srcname |
| 177 |
pattern=$srcpattern ;; |
| 178 |
't') tar_type=$toolsname |
| 179 |
pattern=$toolspattern ;; |
| 180 |
'w') tar_type=$demoname |
| 181 |
pattern=$demopattern ;; |
| 182 |
'q') quiet="yes" ;; |
| 183 |
'a') if [[ -d $OPTARG ]] |
| 184 |
then |
| 185 |
target_dir=$OPTARG |
| 186 |
else |
| 187 |
bomb_out "argument to -$arguments ($OPTARG) is not a directory." |
| 188 |
fi ;; |
| 189 |
|
| 190 |
# garbage input |
| 191 |
'?') print_usage "-$OPTARG is not a valid switch" ;; |
| 192 |
':') print_usage "You forgot the argument for switch -$OPTARG" ;; |
| 193 |
esac |
| 194 |
done |
| 195 |
|
| 196 |
# Now do the remaining args... |
| 197 |
((args_left = OPTIND - 1)) |
| 198 |
shift $args_left |
| 199 |
|
| 200 |
if [[ -z $1 ]] |
| 201 |
then |
| 202 |
print_usage "You did not specify a directory from which to make the install file" |
| 203 |
elif [[ -n $2 ]] |
| 204 |
then |
| 205 |
print_usage "Too many command line arguments: $*" |
| 206 |
else |
| 207 |
source_dir=$1 |
| 208 |
fi |
| 209 |
|
| 210 |
|
| 211 |
# check source directory that is to be archived. |
| 212 |
if [[ ! -d $source_dir || ! -d $source_dir'.BUILD' ]] |
| 213 |
then |
| 214 |
bomb_out "Both $source_dir & $source_dir.BUILD are required to make the archive." |
| 215 |
fi |
| 216 |
|
| 217 |
|
| 218 |
# Get the release number using wtools script. |
| 219 |
verprog=$source_dir'.BUILD/wtools/aceGetVersion' |
| 220 |
vertarget=$source_dir'.BUILD/wnq' |
| 221 |
if [[ ! -d $vertarget || ! -f $verprog || ! -x $verprog ]] |
| 222 |
then |
| 223 |
bomb_out "Can't find out acedb release version, need $verprog and $vertarget" |
| 224 |
fi |
| 225 |
release=$($verprog $vertarget) |
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
if [[ -n $debug ]] |
| 230 |
then |
| 231 |
print "startup values:" |
| 232 |
print "tar_type=$tar_type, pattern=$pattern, architecture=$architecture" |
| 233 |
print "source_dir=$source_dir, target_dir=$target_dir, release=$release" |
| 234 |
fi |
| 235 |
|
| 236 |
|
| 237 |
print_divider |
| 238 |
print " ACEDB build of $tar_type installation file starting..." |
| 239 |
print_divider |
| 240 |
|
| 241 |
|
| 242 |
# check for directory and try to cd to it. |
| 243 |
if [[ $tar_type != $binname && $tar_type != $servername && $tar_type != $staticbinname && $tar_type != $staticservername && $tar_type != $blixemname && $tar_type != $staticblixemname ]] |
| 244 |
then |
| 245 |
source_dir=$source_dir'.BUILD' |
| 246 |
fi |
| 247 |
if [[ -d $source_dir ]] |
| 248 |
then |
| 249 |
print "Using $source_dir to make $tar_type installation file" |
| 250 |
print |
| 251 |
else |
| 252 |
bomb_out "$source_dir is not a directory" |
| 253 |
fi |
| 254 |
cd $source_dir || bomb_out "cannot cd to $source_dir" |
| 255 |
|
| 256 |
|
| 257 |
# construct file names for archives. |
| 258 |
if [[ $tar_type = $binname || $tar_type = $servername || $tar_type = $staticbinname || $tar_type = $staticservername || $tar_type = $blixemname || $tar_type = $staticblixemname ]] |
| 259 |
then |
| 260 |
archive_name=$prefix'-'$tar_type$architecture'.'$release'.'$suffix |
| 261 |
else |
| 262 |
archive_name=$prefix'-'$tar_type'.'$release'.'$suffix |
| 263 |
fi |
| 264 |
|
| 265 |
short_name=$archive_name |
| 266 |
long_name=$archive_name'.'$gzsuffix |
| 267 |
archive_name="$target_dir/$archive_name" |
| 268 |
|
| 269 |
print "Archive will be created as $long_name" |
| 270 |
print |
| 271 |
|
| 272 |
|
| 273 |
# For some archives we need to cd to a specific directory to make the archive, |
| 274 |
# a bit mucky for the bin dir, where more is required than I thought... |
| 275 |
case $tar_type in |
| 276 |
$binname) tar_dir=$(ls | grep -i 'bin.'$architecture) ;; |
| 277 |
$servername) tar_dir=$(ls | grep -i 'bin.'$architecture) ;; |
| 278 |
$staticbinname) tar_dir=$(ls | grep -i 'bin-STATIC.'$architecture) ;; |
| 279 |
$staticservername) tar_dir=$(ls | grep -i 'bin-STATIC.'$architecture) ;; |
| 280 |
$blixemname) tar_dir=$(ls | grep -i 'bin.'$architecture) ;; |
| 281 |
$staticblixemname) tar_dir=$(ls | grep -i 'bin-STATIC.'$architecture) ;; |
| 282 |
$helpname) tar_dir='whelp' ;; |
| 283 |
$docname) tar_dir='wdoc' ;; |
| 284 |
$toolsname) tar_dir='wtools' ;; |
| 285 |
$demoname) tar_dir='wdemo' ;; |
| 286 |
*) tar_dir='./' ;; |
| 287 |
esac |
| 288 |
cd $tar_dir || bomb_out "Can't cd to $tar_dir" |
| 289 |
|
| 290 |
# OK, tar up the files... |
| 291 |
print "Creating tar file archive $short_name" |
| 292 |
$tarprog -cvf$archive_name $pattern >/dev/null || bomb_out "tar of $tar_type files failed." |
| 293 |
print |
| 294 |
|
| 295 |
# For the binary archive we need to stick some extra stuff on the end of the |
| 296 |
# archive. |
| 297 |
if [[ $tar_type = $binname || $tar_type = $staticbinname ]] |
| 298 |
then |
| 299 |
tar_dir=$source_dir'.BUILD' |
| 300 |
cd $currdir || bomb_out "Can't return to intial directory $currdir" |
| 301 |
cd $tar_dir || bomb_out "Can't cd to $tar_dir to finish $tar_type tar." |
| 302 |
|
| 303 |
pattern="./wspec ./wdoc ./wquery ./wscripts ./wgf ./wtools" |
| 304 |
|
| 305 |
$tarprog -rvf$archive_name $pattern >/dev/null || bomb_out "tar of extra $tar_type files failed." |
| 306 |
fi |
| 307 |
|
| 308 |
# For the server archive we also need to add some extra files |
| 309 |
|
| 310 |
if [[ $tar_type = $servername ]] |
| 311 |
then |
| 312 |
tar_dir=$source_dir'.BUILD' |
| 313 |
cd $currdir || bomb_out "Can't return to intial directory $currdir" |
| 314 |
cd $tar_dir || bomb_out "Can't cd to $tar_dir to finish $tar_type tar." |
| 315 |
|
| 316 |
pattern="./wspec/serverconfig.wrm ./wspec/serverpasswd.wrm ./wdoc/Socket_Server" |
| 317 |
|
| 318 |
$tarprog -rvf$archive_name $pattern >/dev/null || bomb_out "tar of extra $tar_type files failed." |
| 319 |
fi |
| 320 |
|
| 321 |
# Now check that the archive got made successfully using tar -t |
| 322 |
$tarprog -tf$archive_name >/dev/null || bomb_out "check of tar file integrity failed." |
| 323 |
|
| 324 |
|
| 325 |
# do the gzip... |
| 326 |
print "Compressing $short_name into $short_name.$gzsuffix" |
| 327 |
gzip $archive_name || bomb_out "could not run compress $archive_name" |
| 328 |
print |
| 329 |
archive_name=$archive_name'.'$gzsuffix |
| 330 |
|
| 331 |
|
| 332 |
print "The installation file is stored as $archive_name" |
| 333 |
|
| 334 |
print_divider |
| 335 |
|
| 336 |
exit 0 |
| 337 |
|