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
|
#!/bin/bash
#
# Script to install a given version of Davix
# created from the xrootd similar script
#
# Syntax:
# ./installDavix.sh [<installdir>] [-h|--help] [-d|--debug] [-o|--optimized]
# [-v <version>|--version=<version>]
# [-t <tarball>|--tarball=<tarball>]
# [-b <where-to-build>|--builddir=<where-to-build>]
# [--dvxopts="<opts-to-davix>"]
# [--vers-subdir[=<version-root>]] [--no-vers-subdir]
# [-j <concurrent-build-jobs>|--jobs=<concurrent-build-jobs>]
# [-k|--keep] [--bzip2]
#
# See printhelp for a description of the options.
#
printhelp()
{
echo " "
echo " Script to install a given version of Davix"
echo " "
echo " Syntax:"
echo " ./installDavix.sh [<installdir>] [-h|--help] [-d|--debug] [-o|--optimized]"
echo " [-v <version>|--version=<version>]"
echo " [-t <tarball>|--tarball=<tarball>]"
echo " [-b <where-to-build>|--builddir=<where-to-build>]"
echo " [--dvxopts=\"<opts-to-davix>\"]"
echo " [-j <concurrent-build-jobs>|--jobs=<concurrent-build-jobs>]"
echo " [--vers-subdir[=<version-root>]] [--no-vers-subdir]"
echo " [-k|--keep] [--bzip2]"
echo " "
echo " where"
echo " <installdir>: the directory where the bin, lib, include/davix, share and"
echo " man directories will appear (see also --vers-subdir)"
echo " The default is ."
echo " -b <where-to-build>, --builddir=<where-to-build>"
echo " directory where to build; default /tmp/davix-<version>"
echo " -d,--debug build in debug mode (no optimization)"
echo " -h, --help print this help screen"
echo " -o,--optimized build in optimized mode without any debug symbol"
echo " -t <tarball>, --tarball=<tarball>"
echo " full local path to source tarball"
echo " -v <version>, --version=<version>"
echo " version in the form x.j.w[-hash-or-tag] ;"
echo " current default 0.2.7-3"
echo " --dvxopts=<opts-to-davix>"
echo " additional configuration options to davix"
echo " (see davix web site)"
echo " --no-vers-subdir install in <installdir> instead of <installdir>/davix-<version>"
echo " (or <installdir>/<version-root><version>, see --vers-subdir"
echo " --vers-subdir[=<version-root>]"
echo " install in <installdir>/<version-root><version> instead of"
echo " <installdir>/davix-<version> or <installdir>. Has priority"
echo " over --no-vers-subdir. Default <version-root>=davix-."
echo " This option is on by default."
echo " -j <jobs>, --jobs=<jobs>"
echo " number of build jobs to run simultaneously when bulding;"
echo " default is <number-of-cores> + 1."
echo " -k, --keep"
echo " keep the build directory"
echo " --bzip2"
echo " use bzip2 to manage the tarball (when extension is .b2z)"
echo " "
echo " When relevant, the script uses 'wget' ('curl' on MacOS X) to retrieve"
echo " the tarball"
}
cleanbuilddir()
{
if test ! "x$KEEP" = "xyes"; then
if test ! "x$BUILDDIR" = "x" && test -d $BUILDDIR ; then
rm -rf $BUILDDIR
fi
fi
}
DBGOPT="-DCMAKE_BUILD_TYPE=RelWithDebInfo"
TGTDIR="."
VERS=""
TARBALL=""
BUILDDIR=""
XRDOPTS=""
VSUBDIR="davix-"
MAKEMJ=""
KEEP=""
UNZIP="gunzip"
TUNZIP="xzf"
#
# Parse long options first
other_args=
short_opts=
is_short="no"
for i in $@ ; do
opt=""
case $i in
--*) opt=`echo "$i" | sed 's/--//'` ;;
-*) if test "x$short_opts" = "x" ; then
short_opts="$i" ;
else
short_opts="$short_opts $i" ;
fi; is_short="yes" ;;
*) if test "x$is_short" = "xyes" ; then
if test "x$short_opts" = "x" ; then
short_opts="$i" ;
else
short_opts="$short_opts $i" ;
fi;
is_short="no"
else
if test "x$other_args" = "x" ; then
other_args="$i";
else
other_args="$other_args $i";
fi;
fi;
esac
if test ! "x$opt" = "x" ; then
case "$opt" in
*=*) oarg=`echo "$opt" | sed 's/[-_a-zA-Z0-9]*=//'`;;
*) oarg= ;;
esac ;
case $opt in
builddir=*) BUILDDIR="$oarg" ;;
debug) DBGOPT="-DCMAKE_BUILD_TYPE=Debug" ;;
help) printhelp ; exit ;;
jobs) MAKEMJ="-j$OPTARG" ;;
no-vers-subdir) VSUBDIR="" ;;
optimized) DBGOPT="-DCMAKE_BUILD_TYPE=Release" ;;
tarball=*) TARBALL="$oarg" ;;
version=*) VERS="$oarg" ;;
vers-subdir) VSUBDIR="davix-" ;;
vers-subdir=*) VSUBDIR="$oarg" ;;
xrdopts=*) XRDOPTS="$oarg" ;;
keep) KEEP="yes" ;;
bzip2) UNZIP="bunzip2" ; TUNZIP="xjf" ;;
esac
fi
done
if test ! "x$short_opts" = "x" ; then
while getopts b:j:t:v:dhok i $short_opts ; do
case $i in
b) BUILDDIR="$OPTARG" ;;
d) DBGOPT="-DCMAKE_BUILD_TYPE=Debug" ;;
h) printhelp ; exit ;;
j) MAKEMJ="-j$OPTARG" ;;
o) DBGOPT="-DCMAKE_BUILD_TYPE=Release" ;;
t) TARBALL="$OPTARG" ;;
v) VERS="$OPTARG" ;;
k) KEEP="yes" ;;
\?) printhelp; exit 1 ;;
esac
if test ! "x$OPTARG" = "x" ; then
noa=
for a in $other_args ; do
if test ! "x$OPTARG" = "x$a" ; then
if test "x$noa" = "x" ; then
noa="$a"
else
noa="$noa $a"
fi
fi
done
other_args=$noa
fi
done
fi
# Fill empty fields with any non-prefixed argument
if test ! "x$other_args" = "x" ; then
TGTDIR="$other_args"
fi
XMK=make
WRKDIR=$PWD
if test "x$TGTDIR" = "x" ; then
echo " Install dir undefined!"
printhelp
exit 1
else
tgtd="$TGTDIR"
TGTDIR=`(cd $tgtd && pwd)`
if [ "$?" -ne "0" ]; then
echo "Install dir $tgtd does not exist, please create it first."
exit 1
fi
fi
if test "x$VERS" = "x" ; then
VERS="0.2.10"
fi
echo "Version: $VERS"
if test ! "x$VSUBDIR" = "x" ; then
TGTDIR="$TGTDIR/$VSUBDIR$VERS"
fi
echo "Installing in: $TGTDIR"
retrieve="yes"
if test ! "x$TARBALL" = "x" && test -f $TARBALL ; then
retrieve="no"
TGTBALL=$TARBALL
fi
if test "x$retrieve" = "xyes" ; then
if test "x$TARBALL" = "x" ; then
TARBALL="http://grid-deployment.web.cern.ch/grid-deployment/dms/lcgutil/tar/davix/davix-$VERS.tar.gz"
TGTBALL="davix-$VERS.tar.gz"
else
TGTBALL=`basename $TARBALL`
fi
fi
if test "x$retrieve" = "xyes" ; then
echo "Retrieving source from tarball $TARBALL"
else
echo "Building tarball $TARBALL"
fi
# Build dir
if test "x$BUILDDIR" = "x"; then
BUILDDIR="/tmp/davix-$VERS-$RANDOM"
fi
if test ! -d $BUILDDIR ; then
mkdir -p $BUILDDIR
if test ! -d $BUILDDIR ; then
echo "Could not create build dir $BUILDDIR, exiting..."
exit 1
fi
else
# Builddir already exists, exit
echo "Build dir $BUILDDIR already exists, exiting..."
exit 1
fi
echo "Build dir: $BUILDDIR"
cd $BUILDDIR
# Retrieving source
ARCH=`uname -s`
if test "x$retrieve" = "xyes" ; then
if test "x$ARCH" = "xDarwin" ; then
curl $TARBALL -o $TGTBALL
else
wget $TARBALL -O $TGTBALL
fi
if test ! -f $TGTBALL ; then
echo "Tarball retrieval failed!"
cd $WRKDIR
cleanbuilddir
exit 1
fi
fi
# Untar tarball
if test "x$ARCH" = "xSunOS" ; then
XMK="gmake"
$UNZIP -c $TGTBALL > "$TGTBALL.tar"
tar xf "$TGTBALL.tar"
rm -f "$TGTBALL.tar"
else
tar $TUNZIP $TGTBALL
fi
if test ! -d davix-$VERS ; then
echo "Could not find source sub-directory davix-$VERS"
cd $WRKDIR
cleanbuilddir
exit 1
fi
cd davix-$VERS
# CMake or old {make,configure} ?
if test -f CMakeLists.txt ; then
# CMake: check if there
XCMK=`which cmake 2> /dev/null`
echo "XCMK = '$XCMK'"
if test "x$XCMK" = "x" || test ! -f $XCMK ; then
echo " "
echo "To build davix cmake is required: "
echo "you can get it from http://cmake.org/cmake/resources/software.html"
echo "or from the software manager of your system"
echo " "
cd $WRKDIR
cleanbuilddir
exit 1
fi
# Check that we can build this version
#if test ! -r VERSION_INFO ; then
# echo "VERSION_INFO file not found: this davix version is probably too old and cannot be built by this script"
# cd $WRKDIR
# cleanbuilddir
# exit 1
#fi
# Create build directory
mkdir build
cd build
# Configure
$XCMK -DCMAKE_INSTALL_PREFIX=$TGTDIR $DBGOPT $XRDOPTS ..
# Get the '-j' setting if not specified
if test "x$MAKEMJ" = "x" ; then
MJ=`grep -c bogomips /proc/cpuinfo 2> /dev/null`
[ "$?" != 0 ] && MJ=`sysctl hw.ncpu | cut -b10 2> /dev/null`
let MJ++
MAKEMJ="-j$MJ"
fi
# Build
$XMK $MAKEMJ
if [ "$?" != "0" ] ; then
echo "Problems running $XMK $MAKEMJ ..."
cd $WRKDIR
cleanbuilddir
exit "$?"
fi
# Install
$XMK install
if [ "$?" != "0" ] ; then
echo "Problems running $XMK install ..."
cd $WRKDIR
cleanbuilddir
exit "$?"
fi
else
# Old {configure,make}
# Check that we can build this version
if test ! -r configure.classic ; then
echo "configure.classic file not found: this davix version cannot be built by this script"
cd $WRKDIR
cleanbuilddir
exit 1
fi
# Configure options
if test "x$DBGOPT" = "xRelease" ; then
DBGOPT=""
else
DBGOPT="--build=debug"
fi
CFGOPT="--disable-krb4 --no-arch-subdirs --disable-mon --enable-krb5"
# Configure
./configure.classic --prefix=$TGTDIR $DBGOPT $CFGOPT $XRDOPTS
if [ "$?" != "0" ] ; then
echo "Problems running configure.classic ..."
cd $WRKDIR
cleanbuilddir
exit "$?"
fi
# Make
$XMK
if [ "$?" != "0" ] ; then
echo "Problems running $XMK ..."
cd $WRKDIR
cleanbuilddir
exit "$?"
fi
# Install
$XMK install
fi
# Go back where we started
cd $WRKDIR
cleanbuilddir
exit
|