-
Notifications
You must be signed in to change notification settings - Fork 58
/
fate-recv.sh
executable file
·110 lines (91 loc) · 2.85 KB
/
fate-recv.sh
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#! /bin/sh
#
# Copyright (c) 2011 Mans Rullgard <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
set -e
export LC_ALL=C
die(){
echo "$@"
exit 1
}
test -n "$FATEDIR" || die "FATEDIR not set"
test -n "$FATE_USER" || die "FATE_USER not set"
reptmp=$(mktemp -d)
trap 'rm -r $reptmp' EXIT
cd $reptmp
tar xzk
header=$(head -n1 report)
# Can't use expr on this one because $version might be 0
version=$(echo "$header" | sed "s/^fate:\([0-9]*\):.*/\1/")
date=$(expr "$header" : "fate:$version:\([0-9]*\):")
slot=$(expr "$header" : "fate:$version:$date:\([A-Za-z0-9_.-]*\):")
rev=$(expr "$header" : "fate:$version:$date:$slot:\([A-Za-z0-9_.-]*\):")
branch=master
if [ $version -eq 1 ]; then
branch=$(expr "$header" : "fate:$version:$date:$slot:$rev:[0-9]*:[ A-Za-z0-9_.-]*:\([A-Za-z0-9_.-\/]*\):")
branch=$(echo "$branch" | sed 's,^release/,v,')
fi
test -n "$date" && test -n "$slot" || die "Invalid report header"
slotdir=$FATEDIR/$slot
if [ -d "$slotdir" ]; then
echo "$FATE_USER" >"$slotdir/owner"
owner=$(cat "$slotdir/owner")
test "$owner" = "$FATE_USER" || die "Slot $slot owned by somebody else"
else
mkdir "$slotdir"
echo "$FATE_USER" >"$slotdir/owner"
fi
exec <report
head -n2 >summary
ntest=0
npass=0
IFS=:
exec >pass
while read name status rest; do
if [ "$status" = 0 ]; then
echo "$name:$date:$rev"
npass=$(($npass+1))
fi
ntest=$(($ntest+1))
done
exec <&- >&-
upass(){
read pname pdate prev || return 0
while read lname ldate lrev; do
test "$lname" != "$pname" && echo "$pname:$pdate:$prev"
pname=$lname
pdate=$ldate
prev=$lrev
done
echo "$pname:$pdate:$prev"
}
lastpass=$slotdir/lastpass
if [ -r $lastpass ]; then
sort pass $lastpass | upass >lastpass
else
sort -o lastpass pass
fi
unset IFS
nwarn=$(grep -Eci '\<warning\>' compile.log) || true
echo "stats:$ntest:$npass:$nwarn" >>summary
repdir=$slotdir/$date
mkdir $repdir
gzip -9 *.log
xz -8 report
cp -p summary report.xz *.log.gz $repdir
chmod 644 $repdir/*
rm -f $slotdir/previous
test -e $slotdir/latest && mv $slotdir/latest $slotdir/previous
ln -s $date $slotdir/latest
cp lastpass ${lastpass}.new && mv ${lastpass}.new $lastpass