freebsd-ports/Tools/portbuild/scripts/buildfailure
Mark Linimon ae733423e0 Generalize the packge building scripts to be able to be run on more than
one 'head' node, rather than just pointyhat itself.

Constants are factored out into installation-specific files known as
portbuild/conf/server.conf and portbuild/conf/client.conf.  There is
only one server.conf file.  Individual <arch> directories may have
their own client.conf files, or may symlink to ../conf/client.conf.

This first set of files only gets the *.conf files and some cleanup.

Feature safe:	yes
2010-06-25 22:49:56 +00:00

63 lines
1.4 KiB
Bash
Executable file

#!/bin/sh
#
# buildfailure <arch> <branch> <buildid> <pkgname>
cleanup() {
echo "Problem writing new failure file!"
rm -f failure.new
exit 1
}
# configurable variables
pb=/var/portbuild
usage () {
echo "usage: buildfailure arch branch buildid pkgname"
exit 1
}
if [ $# -ne 4 ]; then
usage
fi
arch=$1
branch=$2
buildid=$3
pkgname=$4
shift 4
builddir=${pb}/${arch}/${branch}/builds/${buildid}
. ${pb}/conf/server.conf
. ${pb}/${arch}/portbuild.conf
. ${pb}/scripts/buildenv
buildenv ${pb} ${arch} ${branch} ${builddir}
# Don't pick up installed packages from the host
export LOCALBASE=/nonexistentlocal
index=${PORTSDIR}/${INDEXFILE}
portloc=$(grep "^$pkgname|" ${index} | cut -f 2 -d \| | sed s,/usr/ports/,,)
pkgbase=$(cd ${PORTSDIR}/${portloc}/ && make -V PKGBASE)
cd ${pb}/${arch}/${branch}
entry=$(grep "^${portloc}|" failure)
date=$(date +%s)
IFS='|'
if [ ! -z "$entry" ]; then
count=$(echo $entry | cut -f 6 -d \ )
olddate=$(echo $entry | cut -f 4 -d \ )
(grep -v "^${portloc}|" failure > failure.new) || cleanup
(echo "${portloc}|${pkgbase}|${pkgname}|${olddate}|${date}|$((${count}+1))" >> failure.new) || cleanup
mv failure.new failure
else
(echo "${portloc}|${pkgbase}|${pkgname}|${date}|${date}|1" >> failure) || cleanup
fi
link=${pb}/${arch}/${branch}/latest/${portloc}
mkdir -p $(dirname ${link})
errorloc=$(realpath ${builddir}/errors/${pkgname}.log)
ln -sf ${errorloc} ${link}