aboutsummaryrefslogtreecommitdiffstats
path: root/Tools/portbuild/scripts/processfail
blob: 1f97479d2689f4e467cfe7f18f52156c79df6747 (plain) (blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
#
# processfail <arch> <branch>

arch=$1
branch=$2

scriptdir=$(dirname $0)
errorscript=${scriptdir}/processonelog

pb=/var/portbuild

of=/usr/local/www/data/errorlogs/.${arch}-${branch}-failure.html

cd ${pb}/${arch}/${branch}

find $of .failure.html.lock -mmin +60 -delete 2>/dev/null

if [ -f $of -o -f .failure.html.lock ]; then exit; fi

if [ -e .newfailure.stamp -a $(echo $(find . -maxdepth 1 -newer .newfailure.stamp -name newfailure 2>&1 /dev/null | wc -l)) = "0" ]; then exit; fi

touch .newfailure.stamp
touch .failure.html.lock

newfailure=${pb}/${arch}/${branch}/newfailure
num=$(wc -l ${newfailure} | awk '{print $1}')

header() {
  echo "<html><head><title>New package building errors</title>" >$of
  echo "</head><body><h1>New package building errors</h1>" >>$of

  if [ "$num" -eq "0" ]; then
    echo "No errors (yet)" >>$of
  else
    echo "<table border=1>" >>$of
    echo "<tr>$1</tr>" >>$of
  fi
}

footer() {
  echo "</table>" >>$of
  echo "</body>" >>$of
  echo "</html>" >>$of
}

geterrortype() {
  set $(echo `${errorscript} $logfile ./ports` | tr \| " ")
  reason=$(echo $7 | tr '_' ' ')
  echo "<a href=\"http://bento.freebsd.org/#$8\">$reason</a>"
}

#
# Create "default" output, sorted on portname
#
header "<th>Port</th><th>Package</th><th>Error</th><th>Broken</th><th>Last</th><th>#</th>"

sort -r -n -k 4 -t \| failure > newfailure
IFS='|'
while read dir name ver date last count; do
    echo "<tr>" >> $of
    echo "<td><a href=\"http://cvsweb.freebsd.org/ports/$dir\">$dir</a></td>" >> $of
    echo "<td><a href=\"${arch}-${branch}-latest/$ver.log\">$ver</a></td>" >> $of

#    echo "<td align=\"right\">$affby</td><td align=\"right\">$4 Kb</td>" >> $of
#    echo "<td><a href=\"http://www.FreeBSD.org/cgi/cvsweb.cgi/ports/$5\">$5</a></td>" >> $of
#    echo "<td><a href=\"mailto:$6\">$6</a></td>" >> $of
#    echo "<td>" >> $of

    logfile=${ver}.log
    errortype=`geterrortype`
    echo "<td>$errortype</td>" >> $of

    alphadate=$(date -jf %s ${date} "+%F %T")
    alphalast=$(date -jf %s ${last} "+%F %T")
    echo "<td>${alphadate}</td>" >> $of
    echo "<td>${alphalast}</td>" >> $of
    echo "<td>$count</td>" >> $of

    echo "</tr>" >> $of
done < newfailure
footer ""
rm .failure.html.lock
mv -f $of /usr/local/www/data/errorlogs/${arch}-${branch}-failure.html