sit/functions.sh

151 lines
3 KiB
Bash
Raw Normal View History

sit_fail() {
2012-07-17 14:47:36 +00:00
msg="SIT: Fail: $1"
echo "$msg"
exit 1
}
sit_info() {
msg=$1
2012-07-17 14:47:36 +00:00
echo "SIT: " $msg
}
sit_countdown() {
local tt=$1
2011-03-04 15:53:49 +00:00
for i in $(seq $tt -1 1); 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)
2011-09-20 16:25:10 +00:00
tar xjf ${SRC_POOL}/${A} || sit_fail
;;
gz|tgz)
2011-09-20 16:25:10 +00:00
tar xzf ${SRC_POOL}/${A} || sit_fail
;;
xz)
2011-09-20 16:25:10 +00:00
tar xJf ${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
}
src_prepare() {
/bin/true
}
sit_prepare() {
sit_info "Preparing sources"
cd ${SRCDIR}
src_prepare || sit_fail "Preparing sources failed"
}
src_configure() {
if [ -x ${SRCDIR}/configure ] ; then
#sit_info "Runnning configure"
${SRCDIR}/configure --prefix=$PREFIX $CONFIGURE_OPTS
if [ ! -z $LOGDIR -a -f config.log ] ; then
cp config.log $LOGDIR
fi
elif [ -f ${SRCDIR}/CMakeLists.txt ] ; then
2012-02-13 13:44:48 +00:00
#sit_info "Running cmake"
cmake -DCMAKE_INSTALL_PREFIX=$PREFIX $CMAKE_OPTS ${SRCDIR}
2012-02-13 13:44:48 +00:00
fi
}
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() {
if [ ! -z $LOGDIR ] ; then
cd $LOGDIR
bzip2 *.log
cp $LOGDIR/*.bz2 $PREFIX
fi
}
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"
}
sit_sitinfo() {
local SIT_VERSION="unknown"
if svnversion $SIT_PATH >/dev/null 2>/dev/null && test "$(svnversion $SIT_PATH)" != "exported" ; then
SIT_VERSION="svn-r$(svnversion $SIT_PATH)"
elif cd $SIT_PATH; git svn find-rev r1 >/dev/null 2>&1 ; then
SIT_VERSION="svn-r$(cd $SIT_PATH; git svn find-rev HEAD)";
fi
echo "Invocation: $(ps --pid $$ -o cmd | tail -n 1)"
echo "Started: $(date)"
echo "Version: $SIT_VERSION"
echo "Environment:"
echo "------------------------------------------------------------------------------"
env
echo "------------------------------------------------------------------------------"
}