#!/bin/sh # # buildfailure cleanup() { echo "Problem writing new failure file!" rm -f failure.new exit 1 } # configurable variables pbc=${PORTBUILD_CHECKOUT:-/a/portbuild} pbd=${PORTBUILD_DATA:-/a/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=${pbd}/${arch}/${branch}/builds/${buildid} . ${pbc}/conf/server.conf . ${pbc}/conf/common.conf . ${pbd}/${arch}/portbuild.conf if [ -f ${pbd}/${arch}/${branch}/builds/${buildid}/portbuild.conf ]; then . ${pbd}/${arch}/${branch}/builds/${buildid}/portbuild.conf fi . ${pbc}/scripts/buildenv buildenv ${pbd} ${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 ${pbd}/${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=${pbd}/${arch}/${branch}/latest/${portloc} mkdir -p $(dirname ${link}) errorloc=$(realpath ${builddir}/errors/${pkgname}.log) ln -sf ${errorloc} ${link}