2011-07-06 21:19:40 +00:00
|
|
|
#!/bin/sh -l
|
2011-03-03 08:40:58 +00:00
|
|
|
#
|
|
|
|
# Install script inspired by the ebuild system of Gentoo Linux
|
|
|
|
#
|
2013-01-21 14:02:52 +00:00
|
|
|
# Christoph Niethammer <niethammer@hlrs.de> (C) 2011-2013
|
2011-03-03 08:40:58 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# exit on any error!
|
|
|
|
set -e
|
2012-07-17 14:47:36 +00:00
|
|
|
# for debugging:
|
|
|
|
# set -x
|
2011-03-03 08:40:58 +00:00
|
|
|
|
2011-03-03 09:21:10 +00:00
|
|
|
SIT_PATH=$(dirname $PWD/$0)
|
2011-03-03 08:40:58 +00:00
|
|
|
SIT_CONFIG_FILE=$SIT_PATH/etc/sit.conf
|
2012-05-11 08:02:14 +00:00
|
|
|
SIT_USER_CONFIG_FILE=$HOME/.sit
|
2011-03-03 08:40:58 +00:00
|
|
|
|
2012-05-11 08:02:14 +00:00
|
|
|
# Reading in user configuration file if it exists
|
|
|
|
if [[ -e $SIT_USER_CONFIG_FILE ]] ; then
|
|
|
|
source $SIT_USER_CONFIG_FILE
|
|
|
|
fi
|
2011-03-03 08:40:58 +00:00
|
|
|
# Reading in global configuration file
|
|
|
|
if [[ -e $SIT_CONFIG_FILE ]] ; then
|
|
|
|
source $SIT_CONFIG_FILE
|
|
|
|
fi
|
|
|
|
source "$SIT_PATH/functions.sh"
|
|
|
|
|
2011-08-03 12:26:08 +00:00
|
|
|
# identify platform manually if no environment variable was set
|
2013-01-11 14:43:36 +00:00
|
|
|
PLATFORM=${PLATFORM:=$SITE_PLATFORM_NAME}
|
2011-11-30 21:55:01 +00:00
|
|
|
if [ -z $PLATFORM ]; then
|
2013-01-11 14:43:36 +00:00
|
|
|
sit_info "Unknown platform using default platform '${DEFAULT_PLATFORM}' configuration"
|
|
|
|
PLATFORM="${DEFAULT_PLATFORM}"
|
2011-08-03 12:26:08 +00:00
|
|
|
fi
|
2011-07-06 21:19:40 +00:00
|
|
|
|
|
|
|
sit_info "Platform: $PLATFORM"
|
2011-03-03 13:07:56 +00:00
|
|
|
|
2011-03-03 08:40:58 +00:00
|
|
|
# compiler to use
|
|
|
|
# (gnu|intel|pgi)
|
2011-07-07 16:35:51 +00:00
|
|
|
COMPILER=${COMPILER:=${DEFAULT_COMPILER}}
|
2011-03-03 08:40:58 +00:00
|
|
|
# use specific compiler version
|
|
|
|
COMPILER_VERSION=${COMPILER_VERSION:=}
|
|
|
|
|
|
|
|
|
|
|
|
# add a descriptor at the end of the installation path e.g. for special config options etc.
|
|
|
|
PACKAGE_DESCRIPTOR=${PACKAGE_DESCRIPTOR:+-$PACKAGE_DESCRIPTOR}
|
|
|
|
|
|
|
|
|
|
|
|
# Compiler specifications
|
2011-07-06 21:19:40 +00:00
|
|
|
COMPILER_CONFIG_FILE="$SIT_PATH/etc/platform-configs/${PLATFORM}/compiler/${COMPILER}"
|
|
|
|
if [ -e $COMPILER_CONFIG_FILE ] ; then
|
|
|
|
source $COMPILER_CONFIG_FILE
|
|
|
|
else
|
|
|
|
sit_fail "Could not find configuration file for compiler '${COMPILER}' on platform '${PLATFORM}'."
|
2011-03-03 08:40:58 +00:00
|
|
|
fi
|
|
|
|
|
2011-07-06 21:19:40 +00:00
|
|
|
|
2011-12-01 10:29:58 +00:00
|
|
|
if [ "$COMPILER" == "system" ] ; then
|
|
|
|
echo "Using system default compiler"
|
|
|
|
COMPILER="" # prevent any compiler specs in the prefix
|
|
|
|
else
|
|
|
|
case $PLATFORM in
|
2011-12-03 20:23:46 +00:00
|
|
|
hermit|hermit1)
|
2011-11-30 21:55:01 +00:00
|
|
|
module swap $(module list -l 2>&1 | awk '/^PrgEnv-/{print $1}') PrgEnv-${COMPILER}
|
|
|
|
if [ ! -z "$COMPILER_VERSION" ] ; then
|
|
|
|
if [ "${COMPILER}" == "gnu" ] ; then
|
|
|
|
module swap gcc gcc/$COMPILER_VERSION
|
|
|
|
else
|
|
|
|
module swap $COMPILER $COMPILER/$COMPILER_VERSION
|
|
|
|
fi
|
|
|
|
fi
|
2011-12-01 10:29:58 +00:00
|
|
|
;;
|
|
|
|
laki|*)
|
2011-11-30 21:55:01 +00:00
|
|
|
if [ -z "$COMPILER_VERSION" ] ; then
|
|
|
|
COMPILER_MODULE=compiler/${COMPILER}
|
|
|
|
else
|
|
|
|
COMPILER_MODULE=compiler/${COMPILER}/${COMPILER_VERSION}
|
|
|
|
fi
|
|
|
|
echo "Loading compiler module ${COMPILER_MODULE}"
|
|
|
|
module load ${COMPILER_MODULE}
|
2011-12-01 10:29:58 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2011-03-23 11:40:02 +00:00
|
|
|
|
2011-07-10 21:12:27 +00:00
|
|
|
if [ ! -z "${COMPILER}" ] ; then
|
2011-11-30 21:55:01 +00:00
|
|
|
# reevaluate compiler version
|
|
|
|
COMPILER_VERSION=$(eval "$COMPILER_VERSION_CMD")
|
2011-07-10 21:12:27 +00:00
|
|
|
fi
|
2011-03-03 08:40:58 +00:00
|
|
|
# make the compiler variables CC, CXX, FC and F77 available
|
2011-04-11 09:32:27 +00:00
|
|
|
if [ ! -z "$COMPILER_OPTS" ] ; then
|
2011-11-30 21:55:01 +00:00
|
|
|
echo "Compiler env: ${COMPILER_OPTS}"
|
2011-03-23 11:40:02 +00:00
|
|
|
export ${COMPILER_OPTS}
|
|
|
|
fi
|
2011-07-27 08:58:17 +00:00
|
|
|
if [ ! -z $COMPILER ] ; then
|
2011-11-30 21:55:01 +00:00
|
|
|
echo "Using compiler: $COMPILER version: $COMPILER_VERSION"
|
2011-07-27 08:58:17 +00:00
|
|
|
fi
|
2011-03-03 08:40:58 +00:00
|
|
|
|
|
|
|
if [ ! -z "$MPI" ] ; then
|
|
|
|
MPI_MODULE="mpi/$MPI"
|
|
|
|
if [ ! -z "$MPI_VERSION" ] ; then
|
2011-03-15 15:30:00 +00:00
|
|
|
MPI_VERSION_NUM=${MPI_VERSION%%-*}
|
2013-06-17 08:36:57 +00:00
|
|
|
case $MPI in
|
|
|
|
impi)
|
|
|
|
MPI_MODULE=${MPI_MODULE}${MPI_VERSION_NUM:+"/${MPI_VERSION_NUM}"}
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
MPI_MODULE=${MPI_MODULE}${MPI_VERSION_NUM:+"/${MPI_VERSION_NUM}-$COMPILER-$COMPILER_VERSION"}
|
|
|
|
;;
|
|
|
|
esac
|
2011-03-03 08:40:58 +00:00
|
|
|
fi
|
|
|
|
echo "Loading MPI module ${MPI_MODULE}"
|
|
|
|
module load $MPI_MODULE
|
2013-06-17 08:36:57 +00:00
|
|
|
|
2013-03-14 12:26:44 +00:00
|
|
|
case $COMPILER in
|
2013-06-17 08:36:57 +00:00
|
|
|
intel)
|
2013-06-19 09:38:34 +00:00
|
|
|
if [[ $MPI == "impi" ]] ; then
|
2013-06-17 08:36:57 +00:00
|
|
|
MPICC="mpiicc"
|
|
|
|
MPICXX="mpiicpc"
|
|
|
|
MPIFC="mpiifort"
|
|
|
|
else
|
|
|
|
MPICC="mpicc"
|
|
|
|
MPICXX="mpicxx"
|
|
|
|
MPIFC="mpif90"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
gnu|*)
|
|
|
|
MPICC="mpicc"
|
|
|
|
MPICXX="mpicxx"
|
|
|
|
MPIFC="mpif90"
|
|
|
|
;;
|
2013-03-14 12:26:44 +00:00
|
|
|
esac
|
2013-06-17 08:36:57 +00:00
|
|
|
echo "MPI compiler env: MPICC=$MPICC, MPICXX=$MPICXX, MPIFC=$MPIFC"
|
2011-07-08 11:24:49 +00:00
|
|
|
MPI_DIR=${MPI_DIR:=$(dirname $(dirname $(which $MPICC)))}
|
2011-03-03 08:40:58 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
SCLASSFILE=$1
|
|
|
|
ACTION=$2
|
|
|
|
|
|
|
|
if [ -f $SCLASS_DIR/$SCLASSFILE ] ; then
|
|
|
|
source $SCLASS_DIR/$SCLASSFILE
|
|
|
|
else
|
|
|
|
sit_fail "Could not find file $SCLASS_DIR/$SCLASSFILE"
|
|
|
|
fi
|
|
|
|
|
2011-07-06 21:19:40 +00:00
|
|
|
PACKAGENAME=${PACKAGENAME:=$PACKAGE}
|
2011-03-03 08:40:58 +00:00
|
|
|
|
|
|
|
# construct the final installation directory path
|
2012-06-28 15:16:09 +00:00
|
|
|
if [ -z $PREFIX ] ; then
|
2011-03-03 08:40:58 +00:00
|
|
|
PREFIX="${PREFIX_BASE}/${CATEGORY}/${PACKAGE}/${VERSION}"
|
2011-03-15 15:30:00 +00:00
|
|
|
PREFIX_SUFFIX=${MPI:+"-$MPI"}${MPI_VERSION_NUM:+"-$MPI_VERSION_NUM"}
|
2011-03-03 08:40:58 +00:00
|
|
|
PREFIX_SUFFIX=$PREFIX_SUFFIX${COMPILER:+"-$COMPILER"}${COMPILER_VERSION:+"-$COMPILER_VERSION"}
|
|
|
|
PREFIX_SUFFIX=$PREFIX_SUFFIX${PACKAGE_DESCRIPTOR}
|
|
|
|
|
|
|
|
PREFIX=$PREFIX${PREFIX_SUFFIX:+"$PREFIX_SUFFIX"}
|
2012-06-28 15:16:09 +00:00
|
|
|
fi
|
2011-03-03 08:40:58 +00:00
|
|
|
|
|
|
|
# final working directory path
|
|
|
|
WORKDIR=${WORKDIR_BASE}/${CATEGORY}/${PACKAGE}/${VERSION}$PREFIX_SUFFIX
|
|
|
|
|
|
|
|
# path to the source code directory
|
|
|
|
SRCDIR=${WORKDIR}/${P}
|
|
|
|
|
|
|
|
# build directory (should be different from source directory):
|
2011-04-07 00:12:53 +00:00
|
|
|
BUILDDIR=${WORKDIR}/build
|
2011-03-03 08:40:58 +00:00
|
|
|
|
|
|
|
# logfile directory
|
|
|
|
LOGDIR=${WORKDIR}
|
2011-03-04 15:53:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
# source the package class file a second time, so we can modify variables
|
|
|
|
# using their default values. (Defaults depend on other vairables in
|
|
|
|
# the class file like CATEGORY or PACKAGE)
|
|
|
|
source $SCLASS_DIR/$SCLASSFILE
|
|
|
|
|
2011-07-06 21:19:40 +00:00
|
|
|
echo "Package name: $PACKAGENAME"
|
2011-03-04 15:53:49 +00:00
|
|
|
echo "Installation PREFIX: $PREFIX"
|
|
|
|
echo "Working dir: $WORKDIR"
|
|
|
|
echo "Source dir: $SRCDIR"
|
|
|
|
echo "Build dir: $BUILDDIR"
|
2011-03-03 08:40:58 +00:00
|
|
|
echo "Logfile dir: $LOGDIR"
|
|
|
|
|
2011-07-06 21:19:40 +00:00
|
|
|
sit_countdown 3
|
2011-03-03 08:40:58 +00:00
|
|
|
|
2012-02-13 13:44:46 +00:00
|
|
|
if [ -d ${WORKDIR} ] ; then
|
|
|
|
sit_info "Removing existing working directory ${WORKDIR}"
|
|
|
|
sit_countdown 5
|
|
|
|
rm -rf ${WORKDIR}
|
|
|
|
fi
|
2011-03-03 08:40:58 +00:00
|
|
|
mkdir -p ${WORKDIR}
|
|
|
|
mkdir -p ${BUILDDIR}
|
2012-01-10 11:31:07 +00:00
|
|
|
if [ ! -z ${LOGDIR} ] ; then
|
|
|
|
mkdir -p ${LOGDIR}
|
|
|
|
else
|
2012-02-13 11:26:30 +00:00
|
|
|
# TODO: this is dangerous as we compress and copy all *.log files inside LOGDIR!
|
2012-01-10 11:31:07 +00:00
|
|
|
LOGDIR="/tmp"
|
|
|
|
fi
|
2011-03-04 15:53:49 +00:00
|
|
|
|
2011-08-19 09:18:16 +00:00
|
|
|
sit_sitinfo >> "$LOGDIR/sit_cmd.log"
|
2012-03-26 15:39:32 +00:00
|
|
|
sit_unpack 2>&1 | tee "$LOGDIR/unpack.log"; ( exit ${PIPESTATUS[0]} )
|
|
|
|
sit_prepare 2>&1 | tee "$LOGDIR/prepare.log"; ( exit ${PIPESTATUS[0]} )
|
|
|
|
sit_configure 2>&1 | tee "$LOGDIR/configure.log"; ( exit ${PIPESTATUS[0]} )
|
|
|
|
sit_build 2>&1 | tee "$LOGDIR/make.log"; ( exit ${PIPESTATUS[0]} )
|
|
|
|
|
|
|
|
sit_pretest 2>&1 | tee "$LOGDIR/pretest.log"; ( exit ${PIPESTATUS[0]} )
|
|
|
|
sit_install 2>&1 | tee "$LOGDIR/make_install.log"; ( exit ${PIPESTATUS[0]} )
|
|
|
|
sit_posttest 2>&1 | tee "$LOGDIR/posttest.log"; ( exit ${PIPESTATUS[0]} )
|
2013-06-17 07:44:20 +00:00
|
|
|
sit_postinst 2>&1 | tee "$LOGDIR/postinst.log"; ( exit ${PIPESTATUS[0]} )
|
2011-03-03 08:40:58 +00:00
|
|
|
sit_copy_logs
|
|
|
|
sit_setperms
|
|
|
|
|
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
##############################################################################
|
|
|
|
# IMPORTANT!
|
|
|
|
##############################################################################
|
|
|
|
# Do not forget to provide a module file!
|
|
|
|
##############################################################################
|
|
|
|
EOF
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|