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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
#!/bin/sh
# $FreeBSD$
#
# create HTML showing numbers of packages vs errors. Run this in a directory
# accessible to the web server.
#
# alpha is obsolete
SUPPORTED_ARCHS="amd64 i386 ia64 sparc64"
ROOT_DIRECTORY=/var/portbuild
OUTFILE=`basename $0 | sed -e "s/^do//"`".html"
TMPFILE=.${OUTFILE}
# stylesheet seems like overkill for something this simple
TABLEBGCOLOR="#F0F0F0"
THCOLOR="#E0E0FF"
TDCOLOR_DONE="lightgreen"
TDCOLOR_NOT_DONE="lightyellow"
# subroutines
write_header () {
echo "<html>" > ${TMPFILE}
echo "<head>" >> ${TMPFILE}
echo "<title>FreeBSD package building statistics</title>" >> ${TMPFILE}
echo "</head>" >> ${TMPFILE}
echo "<body>" >> ${TMPFILE}
echo "<h1>FreeBSD package building statistics</h1>" >> ${TMPFILE}
echo "<p>as of `date`</p>" >> ${TMPFILE}
}
write_table_begin () {
echo "<table border='1' cellpadding='4' cellspacing='1' bgcolor='$TABLEBGCOLOR'>" >> ${TMPFILE}
echo "<tr>" >> ${TMPFILE}
echo "<td align='left' width='80' bgcolor='$TABLEBGCOLOR'> </td>" >> ${TMPFILE}
echo "<th width='60' bgcolor='$THCOLOR'>cvs date</th>" >> ${TMPFILE}
echo "<th width='60' bgcolor='$THCOLOR'>latest log</th>" >> ${TMPFILE}
echo "<th bgcolor='$THCOLOR'>INDEX</th>" >> ${TMPFILE}
echo "<th bgcolor='$THCOLOR'>packages</th>" >> ${TMPFILE}
echo "<th bgcolor='$THCOLOR'>errors</th>" >> ${TMPFILE}
echo "<th bgcolor='$THCOLOR'>skipped</th>" >> ${TMPFILE}
echo "<th bgcolor='$THCOLOR'>missing</th>" >> ${TMPFILE}
echo "<th bgcolor='$THCOLOR'>done?</th>" >> ${TMPFILE}
echo "</tr>" >> ${TMPFILE}
}
write_row () {
# first, gather data
arch=$1
build=$2
directory=${ROOT_DIRECTORY}/${arch}/${build}
branch=`echo $build | sed -e "s/-exp//"`
if [ "$branch" = "4" ]; then
indexfile=$directory/ports/INDEX
else
indexfile=$directory/ports/INDEX-$branch
fi
# column: date of CVS checkout
cvsdone=" "
if [ -f $directory/cvsdone ]; then
cvsdone="$(cat $directory/cvsdone | awk '{printf("%s %s\n",$2,$3)}')"
if [ -z "$cvsdone" ]; then
cvsdone=" "
fi
fi
# column: datestamp of latest log
latest=" "
if [ -d $directory/logs ]; then
#latest="$(cd $directory/logs; ls -rtTl | grep '\.log' | tail -1 | awk '{printf("%s %s %s %s\n",$6,$7,$8,$9)}')"
latest="$(cd $directory/logs; ls -rtTl | grep '\.log' | tail -1 | awk '{printf("%s %s\n",$6,$7)}')"
if [ "$latest" ]; then
#latest="$latest `date '+%Z'`"
else
latest=" "
fi
fi
# column: INDEX count
n_index=0
if [ -f $indexfile ]; then
n_index=`cat $indexfile | wc -l`
fi
# column: package count
n_packages=0
if [ -d $directory/packages/All ]; then
n_packages=`find $directory/packages/All -name \*.tbz -o -name \*.tgz |wc -l`
fi
# column: error count
n_errors=0
if [ -d $directory/errors ]; then
# XXX MCL why doesn't this work???
#n_errors=`find $directory/errors -name \*.log -o -name \*.log.bz2 |wc -l`
n_errors=`ls $directory/errors | grep '.log' | wc -l`
fi
# column: duds count
n_duds=0
if [ -f $directory/duds ]; then
n_duds=`cat $directory/duds | wc -l`
fi
# column: missing count
if [ $n_index -ne 0 ]; then
n_missing=`expr $n_index - $n_packages - $n_errors - $n_duds`
else # index currently being rebuilt
n_missing=0
fi
# column: done flag
done_flag="N"
if [ -f $directory/build.log ]; then
if [ ! -z "`grep 'all done at ' $directory/build.log`" ]; then
done_flag="Y"
fi
fi
# decorate the row to make everything less "gray"
if [ "$done_flag" = "Y" ]; then
cellcolor=$TDCOLOR_DONE
else
cellcolor=$TDCOLOR_NOT_DONE
fi
# now write the row
echo "<tr>" >> ${TMPFILE}
echo "<th align='left' bgcolor='$THCOLOR'>$arch-$build</th>" >> ${TMPFILE}
echo "<td align='left' bgcolor='$cellcolor'>$cvsdone</td>" >> ${TMPFILE}
echo "<td align='left' bgcolor='$cellcolor'>$latest</td>" >> ${TMPFILE}
echo "<td align='right' bgcolor='$cellcolor'>$n_index</td>" >> ${TMPFILE}
echo "<td align='right' bgcolor='$cellcolor'>" >> ${TMPFILE}
echo "<a href='http://pointyhat.freebsd.org/errorlogs/$arch-$build-latest-logs'>" >> ${TMPFILE}
echo "$n_packages</a></td>" >> ${TMPFILE}
echo "<td align='right' bgcolor='$cellcolor'>" >> ${TMPFILE}
echo "<a href='http://pointyhat.freebsd.org/errorlogs/$arch-$build-latest'>" >> ${TMPFILE}
echo "$n_errors</a></td>" >> ${TMPFILE}
echo "<td align='right' bgcolor='$cellcolor'>$n_duds</td>" >> ${TMPFILE}
echo "<td align='right' bgcolor='$cellcolor'>$n_missing</td>" >> ${TMPFILE}
echo "<td align='center' bgcolor='$cellcolor'>$done_flag</td>" >> ${TMPFILE}
echo "</tr>" >> ${TMPFILE}
}
write_table_end () {
echo "</table>" >> ${TMPFILE}
echo "<br>" >> ${TMPFILE}
}
write_footer () {
echo "<p>explanation of columns:</p>" >> ${TMPFILE}
echo "<ul>" >> ${TMPFILE}
echo "<li><b>latest log</b> is the date of the latest logfile.</li>" >> ${TMPFILE}
echo "<li><b>cvs date</b> is the date of the latest CVS checkout done by the script. It may be inaccurate if a manual checkout was done later.</li>" >> ${TMPFILE}
echo "<li><b>INDEX</b> is number of ports in the INDEX file built from the latest cvs checkout.</li>" >> ${TMPFILE}
echo "<li><b>packages</b> is number of packages successfully built.</li>" >> ${TMPFILE}
echo "<li><b>errors</b> is number of packages that failed.</li>" >> ${TMPFILE}
echo "<li><b>skipped</b> is number of packages that were skipped due to NO_PACKAGE, IGNORE, BROKEN, FORBIDDEN, and so forth (\"duds\" file).</li>" >> ${TMPFILE}
echo "<li><b>missing</b> is the INDEX column minus the others. These are packages that have not been built for one reason or another.</li>" >> ${TMPFILE}
echo "<li><b>done</b> is whether that run terminated normally or not.</li>" >> ${TMPFILE}
echo "</ul>" >> ${TMPFILE}
echo "<p>notes:</p>" >> ${TMPFILE}
echo "<ul>" >> ${TMPFILE}
echo "<li>on the -exp builds, editors/openoffice.org* are skipped to save time.</li>" >> ${TMPFILE}
echo "</ul>" >> ${TMPFILE}
echo "</body>" >> ${TMPFILE}
echo "</html>" >> ${TMPFILE}
}
# main
write_header
# display all the mainstream builds first
for arch in ${SUPPORTED_ARCHS}; do
builds=`ls ${ROOT_DIRECTORY}/${arch} | grep '^[1-9]$' | sort`
if [ ! -z "$builds" ]; then
write_table_begin
for build in ${builds}; do
write_row ${arch} ${build}
done
write_table_end
fi
done
# then display all -exp builds (probably only of interest to portmgr;
# would break up the logical flow of the above)
for arch in ${SUPPORTED_ARCHS}; do
builds=`ls ${ROOT_DIRECTORY}/${arch} | grep '^[1-9]-exp$' | sort`
if [ ! -z "$builds" ]; then
write_table_begin
for build in ${builds}; do
write_row ${arch} ${build}
done
write_table_end
fi
done
write_footer
mv -f ${TMPFILE} ${OUTFILE}
|