freebsd-ports/Tools/portbuild/scripts/dopackages.wrapper
Joe Marcus Clarke fdbc9fa2c2 Add dopackages.wrapper, a wrapper script around dopackages that sets up
build locking, log files, and cleans things up if a build fails.

This script is the primary starting point for a package build.  Symlinks
should be created in the form of dopackages.${branch} -> dopackages.wrapper
where ${branch} is currently one of 4, 4-exp, or 5.  This script takes the
place of the unofficial (i.e. uncommitted) dopackages.steveX scripts.

Ok'd by:	kris
Tested by:	4.10-RELEASE package build
2004-06-03 05:03:58 +00:00

53 lines
956 B
Bash
Executable file

#!/bin/sh
cleanup() {
lock=$1
error=$2
rm -f ${lock}
exit ${error}
}
# configurable variables
pb=/var/portbuild
arch=$1
branch=$(echo $(basename $0) | cut -d'.' -f2)
shift
. ${pb}/${arch}/portbuild.conf
lock=${pb}/${arch}/lock
status=${pb}/${arch}/status
date=$(date '+%Y%m%d%H')
shortdate=$(date '+%Y%m%d')
if [ -e ${lock} ]; then
exit 1
fi
touch ${lock}
rm -f ${status}
mkdir -p ${pb}/${arch}/archive/buildlogs
trap "cleanup ${lock} 1" 1 2 3 9 10 11 15
dorun() {
branch=$1
shift 1
ln -sf ${pb}/${arch}/archive/buildlogs/log.${branch}.${date} ${pb}/${arch}/${branch}/build.log
ln -sf log.${branch}.${date} ${pb}/${arch}/archive/buildlogs/log.${branch}.${shortdate}
${pb}/scripts/dopackages ${arch} $@ ${branch} ${date} 2>&1 \
> ${pb}/${arch}/archive/buildlogs/log.${branch}.${date}
if [ -f ${status} ]; then
error=$(cat ${status})
cleanup ${lock} ${error}
fi
}
dorun ${branch} $@ &
wait
cleanup ${lock} 0