#!/bin/bash -e # install-lalsuite-cvs - 2009.04.12 - Peter Csizmadia # Builds and installs LAL, LALApps, Glue, pyLAL etc. # This script is based on the following docs: # https://www.lsc-group.phys.uwm.edu/daswg/docs/howto/lscsoft-install.html # https://www.lsc-group.phys.uwm.edu/daswg/docs/howto/lal-install.html # https://www.lsc-group.phys.uwm.edu/daswg/projects/glue.html # https://www.lsc-group.phys.uwm.edu/daswg/projects/pylal.html ########################################################################### ################################# Settings ################################ ########################################################################### # Separation of installed software. To install programs into the standard # non-lsc, metaio, libframe, glue, lal, lalapps and pylal subdirectories # of $LSCSOFT_PREFIX, use lscsoft_separation="y". # To install them into the common $LSCSOFT_PREFIX/bin, $LSCSOFT_PREFIX/lib # etc. directories, use lscsoft_separation="n". lscsoft_separation="y" # Relative location of Python packages pythonlib_postfix="/lib/python2.4/site-packages" # Non-LSC software LSCSOFT_SRCURL="http://www.lsc-group.phys.uwm.edu/daswg/download/software/source" pkgconfig="" # do not build pkgconfig #pkgconfig="pkgconfig-0.15.0.tar.gz" fftw="" # do not build FFTW #fftw="fftw-3.1.2.tar.gz" gsl="" # do not build GSL #gsl="gsl-1.9.tar.gz" # libFrame, MetaIO, Glue and the environment settings libframe="" # do not build libframe #libframe="libframe-6.24-8.tar.gz" #metaio="" # do not build MetaIO #metaio="8.2" # use MetaIO 8.2 metaio="7.2" # use MetaIO 7.2 #metaio="HEAD" # build the CVS version glue="" # get it from CVS #glue="glue-1.18.tar.gz" lscsoft_user_env="lscsoft-user-env-1.13.tar.gz" default_options[1]="opt/lscsoft-exttrig s5_exttrig_20081003 pylal=s5_exttrig_20090220 lal=lal_s5_exttrig_20081011 libframe=6.24-8 metaio=7.2" default_options[2]="opt/lscsoft-lowcbc s5_2yr_lv_lowcbc_20081009 libframe=6.24-8 metaio=7.2" default_options[3]="opt/lscsoft-lowcbc20081207 s5_2yr_lv_lowcbc_20081207 libframe=6.24-8 metaio=8.2" # libframe and metaio configure requires the --without-matlab option at # ldas-grid.ligo-la.caltech.edu, otherwise it fails with # "configure: error: can not determine Matlab version number" configMatlab="--without-matlab" # See # https://www.lsc-group.phys.uwm.edu/daswg/projects/lal.html CVSROOT=:pserver:anonymous@gravity.phys.uwm.edu:2402/usr/local/cvs/lscsoft export CVSROOT ########################################################################### ########################## Utility functions ############################## ########################################################################### run() { # runs a command and logs its output pkg=$1; shift what=$1; shift logfile="${pkg}.${what}.log" t0_run=`date +%s` echo -n "$pkg: $what " if /bin/sh -vc "$*" >& "$build_dir/$logfile"; then retcode=0 else retcode=$? echo -n "FAILED " fi t1_run=`date +%s` dt=`sh -c "expr $t1_run - $t0_run; exit 0"` minutes=`sh -c "expr $dt / 60; exit 0"` secs=`sh -c "expr $dt - 60 '*' $minutes; exit 0"` printf "[%d:%02d]\n" $minutes $secs if [ "$retcode" != "0" ]; then echo "tail -13 $build_dir/$logfile" tail -13 "$build_dir/$logfile" exit 1 fi } test_rebuild() { # Tests whether a software directory exists and asks the # the user whether to rebuild it rebuild="y" if [ -d "$build_dir/$1" ]; then echo -n "$1: directory exists. " rebuild="" while [ "$rebuild" != "y" -a "$rebuild" != "n" ]; do echo -n "Rebuild [y/n/?] " read rebuild done fi } is_version_number() { echo $1 | egrep '^[0-9]+(\.[0-9]+)*[a-zA-Z0-9]*(-[0-9])*$' >/dev/null } is_defined_in_config_log() { w=`grep "^$1=" config.log |sed "s/$1=//"` [ -n "$w" -a "$w" != "''" -a "$w" != '""' ]; } print_log_info() { pkg=$1 echo "$pkg: >>> $build_dir/$pkg.*.log" } xnonlsc() { # Downloads non-LSC software, extracts it and sets the swdir # environment variable to the name of the new subdirectory. pkg=$1; shift echo "$pkg: cd $build_dir" cd "$build_dir" if [ ! -f "$1" ]; then if [ "$getcmd" = "curl" ]; then echo "$pkg: curl $LSCSOFT_SRCURL/$1 >$1" curl "$LSCSOFT_SRCURL/$1" >$1 if [ "`file $1|sed 's/.*: //;s/HTML .*$/HTML/'`" = "HTML" ] then if grep 'title.*404' $1 >/dev/null; then echo $LSCSOFT_SRCURL/$1 not found exit 1 fi fi elif [ "$getcmd" = "wget" ]; then echo "$pkg: wget $LSCSOFT_SRCURL/$1" wget "$LSCSOFT_SRCURL/$1" else echo "neither curl nor wget found" >&2 exit 1 fi fi swdir=`tar tf "$1" | sort | head -1 | sed 's/\/$//'` if [ "$2" = "force" ]; then echo "$pkg: rm -rf $swdir; tar xzf $1" rm -rf $swdir; tar xzf $1 rebuild="y" echo "$pkg: cd $swdir" cd $swdir print_log_info $pkg else test_rebuild $swdir if [ "$rebuild" = "y" ]; then echo "$pkg: rm -rf $swdir; tar xzf $1" rm -rf $swdir; tar xzf $1 echo "$pkg: cd $swdir" cd $swdir print_log_info $pkg elif [ "$target_was_clean" = "y" ]; then # make install needed print_log_info $pkg fi fi } checkout() { # Checks out LSC software from CVS pkg=$1; shift outdir=$1 if [ -n "$3" ]; then outdir=$3 fi if [ -d "$outdir" ]; then echo "$pkg: rm -rf $outdir" rm -rf "$outdir" fi print_log_info $pkg if [ "$outdir" = "$1" ]; then run "$pkg" "checkout" "CVSROOT=$CVSROOT cvs co -r $2 -P $1" else run "$pkg" "checkout" "CVSROOT=$CVSROOT cvs co -r $2 -P -d $outdir $1" fi } skipped_logs() { pkg=$1 shift w="" for i in $@; do if [ -z "$w" ]; then w=$i else w="$w $i" fi done echo $w } missing_init_py_workaround() { if [ -d "$2" -a ! -f "$2/__init__.py" ]; then # This file is missing in lalapps rev. s5_exttrig_20081003. # (--> pylal_grbsummary cannot find lalapps module) echo "$1: touch $2/__init__.py" touch "$2/__init__.py" fi } ########################################################################### ################### Parse command line arguments ########################## ########################################################################### target_dir="" release="" lal_release="" pylal_release="" for arg in $@; do if echo $arg | grep '^libframe=' > /dev/null; then libframe=`echo $arg | sed 's/^libframe=//'` elif echo $arg | grep '^metaio=' > /dev/null; then metaio=`echo $arg | sed 's/^metaio=//'` elif echo $arg | grep '^lal=' > /dev/null; then lal_release=`echo $arg | sed 's/^lal=//'` elif echo $arg | grep '^pylal=' > /dev/null; then pylal_release=`echo $arg | sed 's/^pylal=//'` else if [ -z "$target_dir" ]; then target_dir=$arg else if [ -n "$release" ]; then echo "$release or $arg?" exit 1 fi release="$arg" fi fi done if is_version_number $libframe; then libframe="libframe-$libframe.tar.gz" fi if is_version_number $metaio; then metaio="metaio-$metaio.tar.gz" fi ########################################################################### ################ Print help if no argument specified ###################### ########################################################################### if [ -z "$1" ]; then # Defaults: cat <&2 exit 1 fi if [ -z "$release" ]; then echo "tag not specified" >&2 exit 1 fi if [ -z "$lal_release" ]; then lal_release=$release; fi if [ -z "$pylal_release" ]; then pylal_release=$release; fi if [ -z "$USER" ]; then echo "\$USER environment variable is not set" exit 1 fi ########################################################################### ###################### Set environment variables ########################## ########################################################################### target_dir=`echo $target_dir | sed "s:^$HOME/::"` # Build directory if [ -n "$LSCSOFT_BUILDDIR" ]; then build_dir=$LSCSOFT_BUILDDIR else for w in /local/$USER /usr1/$USER /people/$USER; do if [ -d $w ]; then LSCSOFT_BUILDDIR="$w/lscbuild" break; fi done if [ -z "$LSCSOFT_BUILDDIR" ]; then LSCSOFT_BUILDDIR="$HOME/src/lscbuild" fi cat </dev/null; then LSCSOFT_PREFIX="$HOME/$target_dir" else LSCSOFT_PREFIX="$target_dir" fi if [ "$lscsoft_separation" = "y" ]; then nonlsc_postfix="/non-lsc" libframe_postfix="/libframe" metaio_postfix="/libmetaio" glue_postfix="/glue" lal_postfix="/lal" lalapps_postfix="/lalapps" pylal_postfix="/pylal" else nonlsc_postfix="" libframe_postfix="" metaio_postfix="" glue_postfix="" lal_postfix="" lalapps_postfix="" pylal_postfix="" fi nonlsc_prefix="${LSCSOFT_PREFIX}${nonlsc_postfix}" libframe_prefix="${LSCSOFT_PREFIX}${libframe_postfix}" metaio_prefix="${LSCSOFT_PREFIX}${metaio_postfix}" glue_prefix="${LSCSOFT_PREFIX}${glue_postfix}" lal_prefix="${LSCSOFT_PREFIX}${lal_postfix}" lalapps_prefix="${LSCSOFT_PREFIX}${lalapps_postfix}" pylal_prefix="${LSCSOFT_PREFIX}${pylal_postfix}" if sh -c "curl --version 2>/dev/null|grep '^curl '" >/dev/null 2>/dev/null; then getcmd="curl" elif sh -c "wget --version" >/dev/null 2>/dev/null; then getcmd="wget" else echo "neither curl nor wget found" >&2 exit 1 fi ########################################################################### ############################## Cleanup #################################### ########################################################################### if [ -d "$build_dir" ]; then if [ `/bin/ls -1 $build_dir | wc -l` != 0 ]; then cat <$build_dir/build.env export PATH="$nonlsc_prefix/bin:$libframe_prefix/bin:$metaio_prefix/bin:$lal_prefix/bin:$lalapps_prefix/bin:$glue_prefix/bin:\$PATH" export LD_LIBRARY_PATH="$nonlsc_prefix/lib:$libframe_prefix/lib:$metaio_prefix/lib:$lal_prefix/bin:\$LD_LIBRARY_PATH" export PYTHONPATH="$lalapps_prefix$pythonlib_postfix:$glue_prefix$pythonlib_postfix:\$PYTHONPATH" export PKG_CONFIG_PATH="$nonlsc_prefix/lib/pkgconfig:$libframe_prefix/lib/pkgconfig:$metaio_prefix/lib/pkgconfig:$lal_prefix/lib/pkgconfig:$lalapps_prefix/lib/pkgconfig:\$PKG_CONFIG_PATH" EOF else cat <$build_dir/build.env export PATH="$LSCSOFT_PREFIX/bin:\$PATH" export LD_LIBRARY_PATH="$LSCSOFT_PREFIX/lib:\$LD_LIBRARY_PATH" export PYTHONPATH="$LSCSOFT_PREFIX$pythonlib_postfix:\$PYTHONPATH" export PKG_CONFIG_PATH="$LSCSOFT_PREFIX/lib/pkgconfig:\$PKG_CONFIG_PATH" EOF fi cat </dev/null; then # build from tar.gz xnonlsc "metaio" $metaio else # build from CVS test_rebuild metaio if [ "$rebuild" = "y" ]; then cd "$build_dir" checkout "metaio" metaio $metaio cd "$build_dir/metaio" run "metaio" "00boot" ./00boot fi fi if [ "$rebuild" = "y" ]; then cppflags_save=$CPPFLAGS if [ "`echo $metaio|sed 's/^metaio-//;s/\..*//'`" = "7" ]; then # MetaIO 7 must be compiled in C99 compatibility mode, # otherwise it would be unable to use zlib. export CPPFLAGS="-std=c99" fi run "metaio" "configure" ./configure --prefix=$metaio_prefix $configMatlab CPPFLAGS=$cppflags_save run "metaio" "make" make run "metaio" "install" make install elif [ "$target_was_clean" = "y" ]; then run "metaio" "install" make install fi fi if [ -n "$glue" ]; then xnonlsc "glue" $glue if [ "$rebuild" = "y" -o "$target_was_clean" = "y" ]; then run "glue" "install" python setup.py install --prefix=$glue_prefix fi source "$glue_prefix/etc/glue-user-env.sh" fi if [ "$lscsoft_separation" = "y" ]; then xnonlsc "lscsoft-user-env" $lscsoft_user_env if [ "$rebuild" = "y" ]; then run "lscsoft-user-env" "configure" ./configure --prefix=$LSCSOFT_PREFIX run "lscsoft-user-env" "make" make run "lscsoft-user-env" "install" make install elif [ "$target_was_clean" = "y" ]; then run "lscsoft-user-env" "install" make install fi source $LSCSOFT_PREFIX/lscsoft-user-env.sh fi ########################################################################### #################### Build lal, lalapps, glue and pylal ################### ########################################################################### test_rebuild lal if [ "$rebuild" = "y" ]; then cd "$build_dir" checkout "lal" lal $release cd "$build_dir/lal" run "lal" "00boot" ./00boot run "lal" "configure" ./configure --prefix=$lal_prefix if ! is_defined_in_config_log FRAME_LIBS; then cat <&1 libframe installation not found. Please rerun the script with libframe build enabled. EOF exit 1 fi run "lal" "make" make run "lal" "install" make install elif [ "$target_was_clean" = "y" ]; then cd "$build_dir/lal" print_log_info "lal" run "lal" "install" make install fi source "$lal_prefix/etc/lal-user-env.sh" test_rebuild lalapps if [ "$rebuild" = "y" ]; then cd "$build_dir" checkout "lalapps" lalapps $release cd "$build_dir/lalapps" run "lalapps" "00boot" ./00boot run "lalapps" "configure" ./configure --prefix=$lalapps_prefix --enable-condor run "lalapps" "make" make run "lalapps" "install" make install missing_init_py_workaround "lalapps" $lalapps_prefix$pythonlib_postfix/lalapps elif [ "$target_was_clean" = "y" ]; then cd "$build_dir/lalapps" print_log_info "lalapps" run "lalapps" "install" make install missing_init_py_workaround "lalapps" $lalapps_prefix$pythonlib_postfix/lalapps fi source "$lalapps_prefix/etc/lalapps-user-env.sh" if [ -z "$glue" ]; then # get it from CVS test_rebuild glue if [ "$rebuild" = "y" ]; then cd "$build_dir" checkout "glue" glue $release cd "$build_dir/glue" run "glue" "install" python setup.py install --prefix=$glue_prefix elif [ "$target_was_clean" = "y" ]; then cd "$build_dir/glue" print_log_info "glue" run "glue" "install" python setup.py install --prefix=$glue_prefix fi source "$glue_prefix/etc/glue-user-env.sh" fi if [ "$lal_release" != "$release" ]; then test_rebuild lal_for_pylal if [ "$rebuild" = "y" ]; then cd "$build_dir" checkout "lal_for_pylal" lal $lal_release lal_for_pylal cd "$build_dir/lal_for_pylal" run "lal_for_pylal" "00boot" ./00boot run "lal_for_pylal" "configure" ./configure --prefix=$LSCSOFT_PREFIX/lal_for_pylal --disable-metaio run "lal_for_pylal" "make" make run "lal_for_pylal" "install" make install elif [ "$target_was_clean" = "y" ]; then cd "$build_dir/lal_for_pylal" print_log_info "lal_for_pylal" run "lal_for_pylal" "install" make install fi source "$LSCSOFT_PREFIX/lal_for_pylal/etc/lal-user-env.sh" fi test_rebuild pylal if [ "$rebuild" = "y" ]; then cd "$build_dir" checkout "pylal" pylal $pylal_release cd "$build_dir/pylal" run "pylal" "install" python setup.py install --prefix=$pylal_prefix elif [ "$target_was_clean" = "y" ]; then cd "$build_dir/pylal" print_log_info "pylal" run "pylal" "install" python setup.py install --prefix=$pylal_prefix fi ########################################################################### #### Create lscsoft-user-env.sh in case of non-standard installation ###### ########################################################################### if [ "$lscsoft_separation" = "n" ]; then cat >$LSCSOFT_PREFIX/lscsoft-user-env.sh </dev/null; then if [ -n "$profiles" ]; then cat <$HOME/.profile LSCSOFT_PREFIX=\$HOME/$target_dir . \$LSCSOFT_PREFIX/lscsoft-user-env.sh . \$LSCSOFT_PREFIX$pylal_postfix/etc/pylal-user-env.sh EOF cp $HOME/.profile $HOME/.zprofile echo echo Created .profile and .zprofile with the following contents: cat $HOME/.profile fi fi #typeset -U path manpath #ld_library_path=(\${(s(:))LD_LIBRARY_PATH}); typeset -U ld_library_path #pythonpath=(\${(s(:))PYTHONPATH}); typeset -U pythonpath #pkg_config_path=(\${(s(:))PKG_CONFIG_PATH}); typeset -U pkg_config_path #export LD_LIBRARY_PATH=\${(j(:))ld_library_path} #export PYTHONPATH=\${(j(:))pythonpath} #export PKG_CONFIG_PATH=\${(j(:))pkg_config_path}