All pastes #37485 Raw Edit

Something

public text v1 · immutable
#37485 ·published 2006-01-19 23:46 UTC
rendered paste body
#!/bin/bash

## ------------------------------------------------------------- ##
## global variables                                              ##
## ------------------------------------------------------------- ##
export BASEDIR=/home/repobuilder
export PATH=${BASEDIR}/bin:${BASEDIR}/local/bin:/usr/local/bin:/usr/X11R6/bin:/usr/bin:/bin:/usr/sbin:/sbin
export REPOSITORY=${1}
export REVISION=${2}

SENDER_EMAIL="auto-builder"
REPO_MAINTAINER_EMAIL="someone@somewhere.com"
DEVELOPERS_EMAIL="someone@somewhere.com"
NOW=`date +"%F__%H_%M_%S"`
BUILD_LOCATION=${BASEDIR}/${NOW}
LOGFILE=${BASEDIR}/log-${NOW}
SVN_PROTOCOL="file://"
SVN_LOCATION="/home/svn"

## ------------------------------------------------------------- ##
## common functions                                              ##
## ------------------------------------------------------------- ##
cleanup () {
	cd ${BASEDIR}
	rm -fr ${BUILD_LOCATION} ${LOGFILE}
}

# send error email to all developers
# mail_error_maintainer
mail_error_developers () {
sendmail -i -f ${SENDER_EMAIL} $DEVELOPERS_EMAIL << END_OF_EMAIL
From: ${SENDER_EMAIL}
Subject: build error

Commit of revision '${REVISION}' to repository '${REPOSITORY}' has caused
the build to break. The build log is as follows...

`cat ${LOGFILE}`
END_OF_EMAIL
exit 1
}

# send error email to the repository maintainer
mail_error_maintainer () {
sendmail -i -f ${SENDER_EMAIL} ${REPO_MAINTAINER_EMAIL} << END_OF_EMAIL
From: ${SENDER_EMAIL}
Subject: build error

Something went wrong trying to build the latest commit.
Revision: '${REVISION}'
Repository: '${REPOSITORY}'

`cat ${LOGFILE}`
END_OF_EMAIL
exit 1
}

# send success email to all developers
mail_good () {
sendmail -i -f ${SENDER_EMAIL} ${DEVELOPERS_EMAIL} << END_OF_EMAIL
From: ${SENDER_EMAIL}
Subject: build success

Latest commit successful:
Revision: '${REVISION}'
Repository: '${REPOSITORY}'
END_OF_EMAIL
}


## ------------------------------------------------------------- ##
## start of "main()"                                             ##
## ------------------------------------------------------------- ##
## handle interrupts
trap cleanup EXIT

## make log file
touch ${LOGFILE}
[ $? -ne 0 ] && mail_error_maintainer

## make temp dir
echo -n "-> Making temp directory '${BUILD_LOCATION}'..." >> ${LOGFILE}
mkdir -p ${BUILD_LOCATION} >> ${LOGFILE} 2>&1
[ $? -ne 0 ] && mail_error_maintainer
echo "done." >> ${LOGFILE}

echo -n "-> 'cd' into ${BUILD_LOCATION}'..." >> ${LOGFILE}
cd ${BUILD_LOCATION} >> ${LOGFILE} 2>&1
[ $? -ne 0 ] && mail_error_maintainer
echo "done." >> ${LOGFILE}

## export PKG_CONFIG_PATH
echo -n "-> Exporting PKG_CONFIG_PATH..." >> ${LOGFILE}
export PKG_CONFIG_PATH=${BUILD_LOCATION}/local/lib/pkgconfig:/usr/local/lib/pkgconfig
[ $? -ne 0 ] && mail_error_maintainer
echo "done = $PKG_CONFIG_PATH" >> ${LOGFILE}

## co, configure, check: checked-in repository
echo -e "\n\n-> Checking out committed module ${REPOSITORY} version ${REVISION}..." >> ${LOGFILE}
svn co ${SVN_PROTOCOL}${REPOSITORY}/trunk -r ${REVISION} code >> ${LOGFILE} 2>&1
[ $? -ne 0 ] && mail_error_maintainer

mkdir -p code >> ${LOGFILE} 2>&1
[ $? -ne 0 ] && mail_error_maintainer

pushd code >> ${LOGFILE} 2>&1
[ $? -ne 0 ] && mail_error_maintainer

echo -e "\n-> autoreconf'ing..." >> ${LOGFILE}
autoreconf -i >> ${LOGFILE} 2>&1
[ $? -ne 0 ] && mail_error_maintainer

echo -e "\n-> configuring..." >> ${LOGFILE}
./configure --prefix=${BUILD_LOCATION}/local >> ${LOGFILE} 2>&1
[ $? -ne 0 ] && mail_error_maintainer

echo -e "\n-> make check..." >> ${LOGFILE}
make check >> ${LOGFILE} 2>&1
[ $? -ne 0 ] && mail_error_developers

echo -e "\n-> make distcheck..." >> ${LOGFILE}
make distcheck >> ${LOGFILE} 2>&1
[ $? -ne 0 ] && mail_error_developers

popd >> ${LOGFILE} 2>&1
[ $? -ne 0 ] && mail_error_maintainer

## done
mail_good