diff --git a/etc/sit.conf b/etc/sit.conf new file mode 100644 index 0000000..8428723 --- /dev/null +++ b/etc/sit.conf @@ -0,0 +1,15 @@ +# Global sit configuration file +# +# Directory holding all the source tarballs +SRC_POOL=${SRC_POOL:="$HOME/src"} + +# Working directory base path +WORKDIR_BASE=${WORKDIR_BASE:="$HOME/work"} + +# Build class directory holing the sitclass +SCLASS_DIR=${SCLASS_DIR:="$SIT_PATH/packages"} + +# basic installation directory +PREFIX_BASE=${PREFIX_BASE:="$HOME/bin"} + +MAKEOPTS="-j2" diff --git a/functions.sh b/functions.sh new file mode 100644 index 0000000..7322c90 --- /dev/null +++ b/functions.sh @@ -0,0 +1,115 @@ +sit_fail() { + msg=$0 + echo "$msg" + exit 1 +} +sit_info() { + msg=$0 + echo $msg +} + + +sit_countdown() { + local tt=$1 + for i in $(seq $tt); do + echo -n "$i " + sleep 1 + done + echo +} + + +unpack() { + if [ ! -e ${SRC_POOL}/${A} ] ; then + sit_fail "${SRC_POOL}/${A} doesn't exist" + fi + case "${A##*.}" in + bz2) + tar xfjv ${SRC_POOL}/${A} || sit_fail + ;; + gz|tgz) + tar xfzv ${SRC_POOL}/${A} || sit_fail + ;; + xz) + tar xfJv ${SRC_POOL}/${A} || sit_fail + ;; + *) + sit_fail "Archive format not recogized" + ;; + esac +} +src_unpack() { + unpack +} +sit_unpack() { + sit_info "Unpacking sources ..." + cd ${WORKDIR} + src_unpack || sit_fail "Unpacking failed" +} + +src_configure() { + ${SRCDIR}/configure --prefix=$PREFIX $CONFIGURE_OPTS + cp config.log $LOGDIR +} +sit_configure() { + sit_info "Configuring sources ..." + cd ${BUILDDIR} + src_configure || sit_fail "Configure failed" +} + + +src_build() { + make $MAKEOPTS +} +sit_build() { + sit_info "Building sources ..." + cd ${BUILDDIR} + src_build || sit_fail "Build failed" +} + + +src_pretest() { + /bin/true +} +sit_pretest() { + sit_info "Running pre installation tests ..." + cd ${BUILDDIR} + src_pretest || sit_fail "Pre installation tests failed" +} + + +src_posttest() { + /bin/true +} +sit_posttest() { + sit_info "Running post installation tests ..." + cd ${BUILDDIR} + src_posttest || sit_fail "Post installation tests failed" +} + + +src_install() { + make install +} +sit_install() { + sit_info "Installing package ..." + cd ${BUILDDIR} + src_install || sit_fail "Install failed" +} + +sit_copy_logs() { + cd $LOGDIR + bzip2 *.log + cp $LOGDIR/*.bz2 $PREFIX +} + +src_setperms() { + chmod -R g+rwX $PREFIX + chmod -R o+rX $PREFIX +} +sit_setperms() { + sit_info "Setting proper permissions" + src_setperms || sit_fail "Could not set permissions" +} + + diff --git a/packages/mpi/openmpi-1.5.1 b/packages/mpi/openmpi-1.5.1 new file mode 100755 index 0000000..5f3e721 --- /dev/null +++ b/packages/mpi/openmpi-1.5.1 @@ -0,0 +1,27 @@ +#!/bin/sh +# Open MPI sit class file +# +# Christoph Niethammer (C) 2011 +# + +CATEGORY="mpi" +PACKAGE="openmpi" +VERSION="1.5.1" +URL="http://www.open-mpi.org" +INSTALLER="Christoph Niethammer " + +# Archive A and package name P +A=${PACKAGE}-${VERSION}.tar.bz2 +P=${PACKAGE}-${VERSION} + +CONFIGURE_OPTS="--with-devel-headers \ + --enable-debug \ + --enable-contrib-no-build=vt + --enable-shared \ + --enable-static \ + " +# Other interesting configure options: +# --enable-mpi-threads +# --enable-progress-threads +# --with-fca=DIR + diff --git a/sit b/sit new file mode 100755 index 0000000..cdf26b5 --- /dev/null +++ b/sit @@ -0,0 +1,144 @@ +#!/bin/sh +# +# Install script inspired by the ebuild system of Gentoo Linux +# +# Christoph Niethammer (C) 2011 +# + +# exit on any error! +set -e + +SIT_PATH=$(dirname $(realpath $PWD/$0)) +SIT_CONFIG_FILE=$SIT_PATH/etc/sit.conf + +# Reading in global configuration file +if [[ -e $SIT_CONFIG_FILE ]] ; then + source $SIT_CONFIG_FILE +fi +source "$SIT_PATH/functions.sh" + +# compiler to use +# (gnu|intel|pgi) +COMPILER=${COMPILER:=gnu} +# 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 + +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} + +case ${COMPILER} in + gnu) + COMPILER_OPTS="CC=gcc CXX=g++ FC=gfortran F77=gfortran" + if [ "x${COMPILER_VERSION}" == "x" ] ; then + COMPILER_VERSION=$(gcc -dumpversion) + fi + ;; + intel) + COMPILER_OPTS="CC=icc CXX=icpc FC=ifort F77=ifort" + if [ "x${COMPILER_VERSION}" == "x" ] ; then + COMPILER_VERSION=$(icc -dumpversion) + fi + ;; + pgi) + COMPILER_OPTS="CC=pgcc CXX=pgCC FC=pgf95 F77=pgf77" + if [ "x${COMPILER_VERSION}" == "x" ] ; then + COMPILER_VERSION=$(pgcc -V | awk '/pgcc/{print $2}') + fi + ;; + *) + echo "Unknown compiler ${COMPILER}." + ;; +esac +# make the compiler variables CC, CXX, FC and F77 available +export ${COMPILER_OPTS} + +if [ ! -z "$MPI" ] ; then + MPI_MODULE="mpi/$MPI" + if [ ! -z "$MPI_VERSION" ] ; then + MPI_MODULE=${MPI_MODULE}${MPI_VERSION:+"/${MPI_VERSION%%-*}-$COMPILER-$COMPILER_VERSION"} + fi + echo "Loading MPI module ${MPI_MODULE}" + module load $MPI_MODULE + MPI_DIR=${MPI_DIR:=$(dirname $(dirname $(which mpicc)))} +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 + + +# construct the final installation directory path +PREFIX="${PREFIX_BASE}/${CATEGORY}/${PACKAGE}/${VERSION}" +PREFIX_SUFFIX=${MPI:+"-$MPI"}${MPI_VERSION:+"-$MPI_VERSION"} +PREFIX_SUFFIX=$PREFIX_SUFFIX${COMPILER:+"-$COMPILER"}${COMPILER_VERSION:+"-$COMPILER_VERSION"} +PREFIX_SUFFIX=$PREFIX_SUFFIX${PACKAGE_DESCRIPTOR} + + +PREFIX=$PREFIX${PREFIX_SUFFIX:+"$PREFIX_SUFFIX"} +echo "Installation PREFIX: $PREFIX" + +# final working directory path +WORKDIR=${WORKDIR_BASE}/${CATEGORY}/${PACKAGE}/${VERSION}$PREFIX_SUFFIX +echo "Working dir: $WORKDIR" + +# path to the source code directory +SRCDIR=${WORKDIR}/${P} +echo "Source dir: $SRCDIR" + +# build directory (should be different from source directory): +BUILDDIR=${SRCDIR}/build +echo "Build dir: $BUILDDIR" + +# logfile directory +LOGDIR=${WORKDIR} +echo "Logfile dir: $LOGDIR" + + +if [ -d ${WORKDIR} ] ; then + sit_info "Removing existing working directory ${WORKDIR}" + sit_countdown 5 + rm -rf ${WORKDIR} +fi +mkdir -p ${WORKDIR} +mkdir -p ${BUILDDIR} +mkdir -p ${LOGDIR} +sit_unpack 2>&1 | tee "$LOGDIR/unpack.log" +sit_configure 2>&1 | tee "$LOGDIR/configure.log" +sit_build 2>&1 | tee "$LOGDIR/make.log" +sit_pretest 2>&1 | tee "$LOGDIR/pretest.log" +sit_install 2>&1 | tee "$LOGDIR/make_install.log" +sit_posttest 2>&1 | tee "$LOGDIR/posttest.log" +sit_copy_logs +sit_setperms + + +cat <