2016-05-03 06:52:23 +00:00
|
|
|
#!/bin/bash
|
2011-03-03 08:40:58 +00:00
|
|
|
#
|
|
|
|
# Install script inspired by the ebuild system of Gentoo Linux
|
|
|
|
#
|
2022-11-02 15:44:17 +00:00
|
|
|
# Copyright (c) 2011-2022 Christoph Niethammer <niethammer@hlrs.de>
|
2011-03-03 08:40:58 +00:00
|
|
|
#
|
|
|
|
|
2016-05-03 06:52:25 +00:00
|
|
|
set -e
|
2022-08-04 09:06:44 +00:00
|
|
|
#set -x
|
2011-03-03 08:40:58 +00:00
|
|
|
|
2022-11-02 15:44:17 +00:00
|
|
|
#source colors.sh
|
|
|
|
#echo -e "${RED}DEBUGME: $MPI_VERSION${ENDCOLOR}"
|
|
|
|
|
2016-05-03 06:52:25 +00:00
|
|
|
function show_help() {
|
|
|
|
echo "Usage: $0 [options] [action] <sit package name>"
|
|
|
|
echo "Options:"
|
|
|
|
echo " -h,--help"
|
|
|
|
echo " -v,--verbose"
|
|
|
|
echo " --debug"
|
|
|
|
echo
|
2016-05-02 08:55:19 +00:00
|
|
|
echo "Valid actions:"
|
2016-05-02 09:44:05 +00:00
|
|
|
echo " sitinfo"
|
2016-05-02 08:55:19 +00:00
|
|
|
echo " unpack"
|
|
|
|
echo " prepare"
|
|
|
|
echo " configure"
|
|
|
|
echo " build"
|
|
|
|
echo " pretest"
|
|
|
|
echo " install"
|
|
|
|
echo " posttest"
|
|
|
|
echo " postinst"
|
|
|
|
echo " copy_logs"
|
|
|
|
echo " setperms"
|
|
|
|
echo " all"
|
|
|
|
}
|
|
|
|
|
2016-05-18 14:02:54 +00:00
|
|
|
declare -i verbose=0
|
|
|
|
declare -i debug=0
|
2016-05-03 06:52:25 +00:00
|
|
|
sit_classfile="" # sit class file to be installed
|
|
|
|
sit_action="all" # sit action to be performed
|
2016-05-02 09:35:39 +00:00
|
|
|
|
2016-05-02 09:44:05 +00:00
|
|
|
while [ "$1" != "" ] ; do
|
2016-05-02 09:35:39 +00:00
|
|
|
case $1 in
|
2016-05-03 06:52:25 +00:00
|
|
|
-h|-\?|--help)
|
|
|
|
show_help
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
--debug)
|
|
|
|
echo "Debug mode enabled"
|
|
|
|
set -x
|
|
|
|
debug=1
|
|
|
|
;;
|
|
|
|
-v|--verbose)
|
|
|
|
verbose=$((verbose + 1))
|
|
|
|
;;
|
|
|
|
|
|
|
|
sitinfo| \
|
|
|
|
all| \
|
|
|
|
unpack| \
|
|
|
|
prepare| \
|
|
|
|
configure| \
|
|
|
|
build| \
|
|
|
|
pretest| \
|
|
|
|
install| \
|
|
|
|
posttest| \
|
|
|
|
postinst| \
|
|
|
|
copy_logs| \
|
|
|
|
setperms)
|
|
|
|
sit_action=$1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
sit_classfile=$1
|
|
|
|
;;
|
2016-05-02 09:35:39 +00:00
|
|
|
esac
|
2016-05-03 06:52:25 +00:00
|
|
|
|
2016-05-02 09:35:39 +00:00
|
|
|
shift
|
|
|
|
done
|
2016-05-02 08:55:18 +00:00
|
|
|
|
2016-05-03 06:52:25 +00:00
|
|
|
SIT_PATH=$(cd $(dirname $PWD/$0); pwd)
|
|
|
|
SIT_CONFIG_FILE=$SIT_PATH/etc/sit.conf
|
|
|
|
SIT_USER_CONFIG_FILE=$HOME/.sit
|
2016-05-03 06:52:24 +00:00
|
|
|
|
|
|
|
source "$SIT_PATH/functions.sh"
|
|
|
|
|
|
|
|
# Reading in user configuration file if it exists
|
|
|
|
if [[ -e $SIT_USER_CONFIG_FILE ]] ; then
|
|
|
|
source $SIT_USER_CONFIG_FILE
|
|
|
|
fi
|
2019-09-23 14:58:31 +00:00
|
|
|
# Reading in global configuration file
|
|
|
|
if [[ -e $SIT_CONFIG_FILE ]] ; then
|
|
|
|
source $SIT_CONFIG_FILE
|
|
|
|
fi
|
2011-03-03 08:40:58 +00:00
|
|
|
|
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
|
2016-05-03 06:52:22 +00:00
|
|
|
sit_warn "Unknown platform using default platform '${DEFAULT_PLATFORM}' configuration"
|
2013-01-11 14:43:36 +00:00
|
|
|
PLATFORM="${DEFAULT_PLATFORM}"
|
2011-08-03 12:26:08 +00:00
|
|
|
fi
|
2011-07-06 21:19:40 +00:00
|
|
|
sit_info "Platform: $PLATFORM"
|
2016-05-03 06:52:23 +00:00
|
|
|
sit_info "Action(s) to perform: $sit_action"
|
|
|
|
sit_info "Sit class file(s): $sit_classfile"
|
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}}
|
2016-05-18 14:02:54 +00:00
|
|
|
sit_info_verbose "Compiler: $COMPILER"
|
2011-03-03 08:40:58 +00:00
|
|
|
# use specific compiler version
|
|
|
|
COMPILER_VERSION=${COMPILER_VERSION:=}
|
2016-05-18 14:02:54 +00:00
|
|
|
sit_info_verbose "Compiler version: $COMPILER_VERSION"
|
2011-03-03 08:40:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
2022-11-02 15:44:17 +00:00
|
|
|
sit_info_verbose "COMPILER: $COMPILER"
|
|
|
|
sit_info_verbose "COMPILER version: $COMPILER_VERSION"
|
|
|
|
sit_info_verbose "MPI: $MPI"
|
|
|
|
sit_info_verbose "MPI version: $MPI_VERSION"
|
|
|
|
|
|
|
|
case $PLATFORM in
|
|
|
|
hawk|vulcan)
|
|
|
|
COMPILER_MODULE=${COMPILER}${COMPILER_VERSION:+"/${COMPILER_VERSION}"}
|
|
|
|
MPI_MODULE=${MPI}${MPI_VERSION:+"/${MPI_VERSION}"}
|
|
|
|
MPI_VERSION_NUM=${MPI_VERSION%%-*}
|
|
|
|
sit_info_verbose "MPI version num: $MPI_VERSION_NUM"
|
|
|
|
;;
|
|
|
|
system)
|
|
|
|
echo "Using system default compiler and MPI"
|
|
|
|
COMPILER="" # prevent any compiler specs in the prefix
|
|
|
|
MPI=""
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
sit_fail "Unknown or unsupported system"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo "Loading modules: ${COMPILER_MODULE} ${MPI_MODULE}"
|
|
|
|
|
|
|
|
module load "${COMPILER_MODULE}" "${MPI_MODULE}"
|
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
|
2020-06-25 08:02:43 +00:00
|
|
|
COMPILER_VERSION_FULL=$(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
|
2016-05-03 06:52:24 +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
|
2020-06-25 08:02:43 +00:00
|
|
|
echo "Using compiler: $COMPILER version: $COMPILER_VERSION_FULL"
|
2011-07-27 08:58:17 +00:00
|
|
|
fi
|
2011-03-03 08:40:58 +00:00
|
|
|
|
2019-01-30 15:34:17 +00:00
|
|
|
|
2016-05-03 06:52:24 +00:00
|
|
|
if [ ! -z "$MPI" ] ; then
|
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
|
|
|
|
;;
|
2022-11-02 15:44:17 +00:00
|
|
|
*)
|
2013-06-17 08:36:57 +00:00
|
|
|
MPICC="mpicc"
|
|
|
|
MPICXX="mpicxx"
|
|
|
|
MPIFC="mpif90"
|
|
|
|
;;
|
2013-03-14 12:26:44 +00:00
|
|
|
esac
|
2016-05-18 14:05:00 +00:00
|
|
|
sit_info "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
|
|
|
|
|
|
|
|
|
2016-05-02 08:55:20 +00:00
|
|
|
if [ -f $SCLASS_DIR/$sit_classfile ] ; then
|
|
|
|
source $SCLASS_DIR/$sit_classfile
|
2011-03-03 08:40:58 +00:00
|
|
|
else
|
2016-05-02 08:55:20 +00:00
|
|
|
sit_fail "Could not find file $SCLASS_DIR/$sit_classfile"
|
2011-03-03 08:40:58 +00:00
|
|
|
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
|
2016-05-02 08:55:20 +00:00
|
|
|
PREFIX="${PREFIX_BASE}/${CATEGORY}/${PACKAGE}/${VERSION}"
|
|
|
|
PREFIX_SUFFIX=${MPI:+"-$MPI"}${MPI_VERSION_NUM:+"-$MPI_VERSION_NUM"}
|
|
|
|
PREFIX_SUFFIX=$PREFIX_SUFFIX${COMPILER:+"-$COMPILER"}${COMPILER_VERSION:+"-$COMPILER_VERSION"}
|
|
|
|
PREFIX_SUFFIX=$PREFIX_SUFFIX${PACKAGE_DESCRIPTOR:+-$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
|
|
|
|
|
|
|
|
2016-05-03 06:52:24 +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
|
2011-03-04 15:53:49 +00:00
|
|
|
# the class file like CATEGORY or PACKAGE)
|
2016-05-02 08:55:20 +00:00
|
|
|
source $SCLASS_DIR/$sit_classfile
|
2011-03-04 15:53:49 +00:00
|
|
|
|
2016-05-18 14:05:00 +00:00
|
|
|
sit_info "Package name: $PACKAGENAME"
|
|
|
|
sit_info "Installation PREFIX: $PREFIX"
|
|
|
|
sit_info "Working dir: $WORKDIR"
|
|
|
|
sit_info "Source dir: $SRCDIR"
|
|
|
|
sit_info "Build dir: $BUILDDIR"
|
|
|
|
sit_info "Logfile dir: $LOGDIR"
|
2011-03-03 08:40:58 +00:00
|
|
|
|
2011-07-06 21:19:40 +00:00
|
|
|
sit_countdown 3
|
2011-03-03 08:40:58 +00:00
|
|
|
|
2014-06-16 22:13:33 +00:00
|
|
|
# if working dir already exists and execution option is Default then remove
|
|
|
|
# previous working directory and create new
|
2019-09-01 17:55:21 +00:00
|
|
|
if [[ -d ${WORKDIR} && $sit_action == "all" ]] ; then
|
2012-02-13 13:44:46 +00:00
|
|
|
sit_info "Removing existing working directory ${WORKDIR}"
|
|
|
|
sit_countdown 5
|
|
|
|
rm -rf ${WORKDIR}
|
|
|
|
fi
|
2014-06-16 22:13:33 +00:00
|
|
|
|
|
|
|
if [ ! -d ${WORKDIR} ] ; then
|
2016-05-02 08:55:20 +00:00
|
|
|
mkdir -p ${WORKDIR}
|
|
|
|
mkdir -p ${BUILDDIR}
|
2014-06-16 22:13:33 +00:00
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
2014-06-16 22:13:33 +00:00
|
|
|
|
2016-05-02 08:55:18 +00:00
|
|
|
case $sit_action in
|
2014-06-16 22:13:33 +00:00
|
|
|
"sitinfo")
|
2016-05-02 08:55:18 +00:00
|
|
|
sit_sitinfo >> "$LOGDIR/sit_cmd.log"
|
2014-06-16 22:13:33 +00:00
|
|
|
;;
|
|
|
|
"unpack")
|
2016-05-02 08:55:18 +00:00
|
|
|
sit_unpack 2>&1 | tee "$LOGDIR/unpack.log"; ( exit ${PIPESTATUS[0]} )
|
2014-06-16 22:13:33 +00:00
|
|
|
;;
|
|
|
|
"prepare")
|
2016-05-02 08:55:18 +00:00
|
|
|
sit_prepare 2>&1 | tee "$LOGDIR/prepare.log"; ( exit ${PIPESTATUS[0]} )
|
2014-06-16 22:13:33 +00:00
|
|
|
;;
|
|
|
|
"configure")
|
2016-05-02 08:55:18 +00:00
|
|
|
sit_configure 2>&1 | tee "$LOGDIR/configure.log"; ( exit ${PIPESTATUS[0]} )
|
2014-06-16 22:13:33 +00:00
|
|
|
;;
|
|
|
|
"build")
|
2016-05-02 08:55:18 +00:00
|
|
|
sit_build 2>&1 | tee "$LOGDIR/make.log"; ( exit ${PIPESTATUS[0]} )
|
2014-06-16 22:13:33 +00:00
|
|
|
;;
|
|
|
|
"pretest")
|
2016-05-02 08:55:18 +00:00
|
|
|
sit_pretest 2>&1 | tee "$LOGDIR/pretest.log"; ( exit ${PIPESTATUS[0]} )
|
2014-06-16 22:13:33 +00:00
|
|
|
;;
|
|
|
|
"install")
|
2016-05-02 08:55:18 +00:00
|
|
|
sit_install 2>&1 | tee "$LOGDIR/make_install.log"; ( exit ${PIPESTATUS[0]} )
|
2014-06-16 22:13:33 +00:00
|
|
|
;;
|
|
|
|
"posttest")
|
2016-05-02 08:55:18 +00:00
|
|
|
sit_posttest 2>&1 | tee "$LOGDIR/posttest.log"; ( exit ${PIPESTATUS[0]} )
|
2014-06-16 22:13:33 +00:00
|
|
|
;;
|
|
|
|
"postinst")
|
2016-05-02 08:55:18 +00:00
|
|
|
sit_postinst 2>&1 | tee "$LOGDIR/postinst.log"; ( exit ${PIPESTATUS[0]} )
|
2014-06-16 22:13:33 +00:00
|
|
|
;;
|
|
|
|
"copy_logs")
|
2016-05-02 08:55:18 +00:00
|
|
|
sit_copy_logs
|
2014-06-16 22:13:33 +00:00
|
|
|
;;
|
|
|
|
"setperms")
|
2016-05-02 08:55:18 +00:00
|
|
|
sit_setperms
|
2014-06-16 22:13:33 +00:00
|
|
|
;;
|
2016-05-02 08:55:18 +00:00
|
|
|
"all")
|
|
|
|
sit_sitinfo >> "$LOGDIR/sit_cmd.log"
|
|
|
|
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]} )
|
|
|
|
sit_postinst 2>&1 | tee "$LOGDIR/postinst.log"; ( exit ${PIPESTATUS[0]} )
|
|
|
|
sit_copy_logs
|
|
|
|
sit_setperms
|
2014-06-16 22:13:33 +00:00
|
|
|
;;
|
|
|
|
*)
|
2016-05-02 08:55:18 +00:00
|
|
|
echo "Unknown action $sit_action"
|
2016-05-02 08:55:19 +00:00
|
|
|
usage
|
2014-06-16 22:13:33 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
|
2011-03-03 08:40:58 +00:00
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
##############################################################################
|
|
|
|
# IMPORTANT!
|
|
|
|
##############################################################################
|
|
|
|
# Do not forget to provide a module file!
|
|
|
|
##############################################################################
|
|
|
|
EOF
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|