summaryrefslogtreecommitdiffstats
path: root/Tools/portbuild/scripts/buildfailure
blob: 50e295a7cacf9f8c823cd13c5f9d3c5084444ac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/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}
OpenPOWER on IntegriCloud