sit/functions.sh

169 lines
3.4 KiB
Bash
Raw Normal View History

sit_fail() {
local msg="SIT: Fail: $1"
echo "$msg"
exit 1
}
2016-05-03 06:52:22 +00:00
sit_warn() {
local msg=$1
echo "SIT: Warning: $msg"
2016-05-03 06:52:22 +00:00
}
sit_info() {
local msg=$1
echo "SIT: $msg"
}
2016-05-18 14:02:54 +00:00
sit_info_verbose() {
local msg=$1
if [[ $verbose -gt 0 ]] ; then
echo "SIT verbose: $msg"
fi
}
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() {
2016-05-02 08:55:20 +00:00
if [ ! -e ${SRC_POOL}/${A} ] ; then
sit_fail "${SRC_POOL}/${A} doesn't exist"
fi
case "${A##*.}" in
bz2)
tar xjf ${SRC_POOL}/${A} || sit_fail
;;
gz|tgz)
tar xzf ${SRC_POOL}/${A} || sit_fail
;;
xz)
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() {
2019-09-25 23:03:33 +00:00
if [ -f ${SRCDIR}/CMakeLists.txt ] ; then
#sit_info "Running cmake"
cmake -DCMAKE_INSTALL_PREFIX=$PREFIX $CMAKE_OPTS ${SRCDIR}
elif [ -x ${SRCDIR}/configure ] ; then
#sit_info "Runnning configure"
2016-05-02 08:55:20 +00:00
${SRCDIR}/configure --prefix=$PREFIX $CONFIGURE_OPTS
if [ ! -z $LOGDIR -a -f config.log ] ; then
cp config.log $LOGDIR
fi
fi
}
sit_configure() {
sit_info "Configuring sources ..."
2016-05-02 08:55:20 +00:00
cd ${BUILDDIR}
src_configure || sit_fail "Configure failed"
}
src_build() {
make $MAKEOPTS
}
sit_build() {
sit_info "Building sources ..."
2016-05-02 08:55:20 +00:00
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_install() {
2016-05-02 08:55:20 +00:00
make install
}
sit_install() {
sit_info "Installing package ..."
cd ${BUILDDIR}
src_install || sit_fail "Install failed"
}
src_posttest() {
/bin/true
}
sit_posttest() {
sit_info "Running post installation tests ..."
cd ${BUILDDIR}
src_posttest || sit_fail "Post installation tests failed"
}
src_postinst() {
/bin/true
}
sit_postinst() {
src_postinst || sit_fail "Post installation failed"
}
sit_copy_logs() {
if [ ! -z $LOGDIR ] ; then
cd $LOGDIR
bzip2 -f *.log
cp -f $LOGDIR/*.bz2 $PREFIX
fi
}
src_setperms() {
chmod -R g=u,o=u-w $PREFIX
}
sit_setperms() {
sit_info "Setting proper permissions"
src_setperms || sit_fail "Could not set permissions"
}
sit_sitinfo() {
2016-05-02 08:55:20 +00:00
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 "------------------------------------------------------------------------------"
}