diff options
author | Kris Kennaway <kris@FreeBSD.org> | 2008-07-26 14:52:05 +0000 |
---|---|---|
committer | Kris Kennaway <kris@FreeBSD.org> | 2008-07-26 14:52:05 +0000 |
commit | 89c8fd897fa7cd9998d51b5a8b5d56122eb7ecba (patch) | |
tree | 76d17e34d1a468de78ba933d79662161af922cc8 | |
parent | * Cleanup (diff) |
* Cleanup
* Catch up to build ID directory changes
* Make it easier to kill a build by not running dopackages in the background
where it is detached from shell job control. Now, sending a termination
signal to this process (e.g. ^C) will also kill off the dopackages script
and in turn the processes created by it. Some background processes
spawned by dopackages, pdispatch, etc, may still remain and need to be
killed by hand.
Notes
Notes:
svn path=/head/; revision=217597
-rwxr-xr-x | Tools/portbuild/scripts/dopackages.wrapper | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/Tools/portbuild/scripts/dopackages.wrapper b/Tools/portbuild/scripts/dopackages.wrapper index a6854efe983a..5517ee671ff5 100755 --- a/Tools/portbuild/scripts/dopackages.wrapper +++ b/Tools/portbuild/scripts/dopackages.wrapper @@ -2,43 +2,38 @@ # configurable variables pb=/var/portbuild + +if [ $# -lt 2 ]; then + echo "usage: $0 <arch> <buildid> [<args> ...]" + exit 1 +fi + arch=$1 +buildid=$2 branch=$(echo $(basename $0) | cut -d'.' -f2) -shift - -. ${pb}/${arch}/portbuild.conf +shift 2 -lock=${pb}/${arch}/${branch}/lock -status=${pb}/${arch}/status -date=$(date '+%Y%m%d%H') -shortdate=$(date '+%Y%m%d') +. ${pb}/scripts/buildenv +if ! validate_env ${arch} ${branch} ; then + echo "Invalid environment: ${arch}/${branch}" + exit 1 +fi -if [ -e ${lock} ]; then - echo "Already locked." - exit 1 +buildid=$(resolve ${pb} ${arch} ${branch} ${buildid}) +if [ -z "${buildid}" ]; then + echo "Invalid build ID ${buildid}" + exit 1 fi -rm -f ${status} -mkdir -p ${pb}/${arch}/archive/buildlogs +# XXX move to per-build +lock=${pb}/${arch}/${branch}/lock -trap "exit 1" 1 2 3 9 10 11 15 +date=$(date '+%Y%m%d%H%M%S') 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} - lockf -t 0 ${lock} ${pb}/scripts/dopackages ${arch} $@ ${branch} ${date} 2>&1 \ - > ${pb}/${arch}/archive/buildlogs/log.${branch}.${date} - if [ -f ${status} ]; then - error=$(cat ${status}) - exit ${error} - fi + lockf -k -t 0 ${lock} ${pb}/scripts/dopackages ${arch} ${branch} ${buildid} ${date} $@ 2>&1 \ + | tee ${pb}/${arch}/archive/buildlogs/log.${branch}.${date} } -dorun ${branch} $@ & -wait - -exit 0 +dorun $@ || (echo "Build failed."; exit 1) |