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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
#!/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='100' 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'>build logs</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'>running?</th>" >> ${TMPFILE}
echo "<th bgcolor='$THCOLOR'>completed?</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
# work around the fact that 5-exp is really 6-exp-prime
if [ ! -f $indexfile ]; then
if [ -d $directory/ports ]; then
indexfile=$directory/ports/`cd $directory/ports&&ls INDEX* | head -1`
else
# work around the fact that 4 is EOL and thus has no ports/ directory
indexfile=$directory/logs/`cd $directory/logs&&ls INDEX* | head -1`
fi
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 and URL of latest log
latest=" "
if [ -d $directory/logs ]; then
latest_suffix="$(cd $directory/logs; ls -rtTl | grep '\.log' | tail -1 | awk '{printf("%s\">%s %s</a>\n",$10,$6,$7)}')"
if [ "$latest_suffix" ]; then
latest="<a href=\"http://pointyhat.freebsd.org/errorlogs/$arch-$build-latest-logs/$latest_suffix"
else
latest=" "
fi
fi
# column: INDEX count
n_index=0
if [ -f $indexfile ]; then
n_index=`cat $indexfile | wc -l`
fi
# column: buildlog count
n_logs=0
if [ -d $directory/logs ]; then
n_logs=`ls $directory/logs | grep '\.log' | wc -l`
fi
# column: package count
n_packages=0
if [ -d $directory/packages/All ]; then
n_packages=`find $directory/packages/All -name \*.tbz -or -name \*.tgz |wc -l`
fi
# column: error count
n_errors=0
if [ -d $directory/errors ]; then
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_logs - $n_errors - $n_duds`
else # index currently being rebuilt
n_missing=0
fi
# column: running flag
running_flag="N"
# the last grep eliminates false positive of i386-6-exp for i386-6
running_processes_for_build=`ps axww | \
grep "pdispatch $arch $build " | \
grep -v grep | \
sed -e "s@.*pdispatch @@;s@ /var/portbuild/scripts/.*@@;s@ @-@g" | \
grep "^$arch-$build\$"`
if [ ! -z "$running_processes_for_build" ]; then
running_flag="Y"
fi
# column: completed flag
completed_flag="N"
if [ -f $directory/build.log ]; then
if [ ! -z "`grep 'all done at ' $directory/build.log`" ]; then
completed_flag="Y"
fi
fi
# decorate the row to make everything less "gray"
if [ "$running_flag" = "N" -a "$completed_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'>" >> ${TMPFILE}
echo "<a href='http://pointyhat.freebsd.org/errorlogs/$arch-$build-latest/cvsdone'>" >> ${TMPFILE}
echo "$cvsdone</a></td>" >> ${TMPFILE}
echo "<td align='left' bgcolor='$cellcolor'>$latest</td>" >> ${TMPFILE}
# note: ports/INDEX-n is copied to a file called errorlogs/INDEX
echo "<td align='left' bgcolor='$cellcolor'>" >> ${TMPFILE}
echo "<a href='http://pointyhat.freebsd.org/errorlogs/$arch-$build-latest/INDEX'>" >> ${TMPFILE}
echo "$n_index</a></td>" >> ${TMPFILE}
echo "<td align='right' bgcolor='$cellcolor'>" >> ${TMPFILE}
echo "<a href='http://pointyhat.freebsd.org/errorlogs/$arch-$build-latest-logs'>" >> ${TMPFILE}
echo "$n_logs</a></td>" >> ${TMPFILE}
echo "<td align='right' bgcolor='$cellcolor'>" >> ${TMPFILE}
echo "<a href='http://pointyhat.freebsd.org/errorlogs/$arch-$build-packages-latest'>" >> ${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'>$running_flag</td>" >> ${TMPFILE}
echo "<td align='center' bgcolor='$cellcolor'>$completed_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>build logs</b> is number of packages attempted. Note: if a run was restarted, you may see duplicates here.</li>" >> ${TMPFILE}
echo "<li><b>packages</b> is number of packages successfully built. Note: if a run was restarted, you may see duplicates here.</li>" >> ${TMPFILE}
echo "<li><b>errors</b> is number of packages that failed. Note: if a run was restarted, you may see duplicates here.</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 build logs plus the errors plus the skipped. These are packages that have not been built for one reason or another. Note: interrupted and/or restarted builds can make this number inaccurate because of the duplicates, above.</li>" >> ${TMPFILE}
echo "<li><b>running</b> is whether there are still processes running.</li>" >> ${TMPFILE}
echo "<li><b>completed</b> is whether that build terminated normally or not, as seen from the logfile.</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}
|