aboutsummaryrefslogtreecommitdiff
path: root/Tools/portbuild/scripts/dopackagestats
blob: 81473c087dc223c0f0154eeb445f5ce10497253a (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
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
#!/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=packagestats.html
TMPFILE=.${OUTFILE}

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}

for arch in ${SUPPORTED_ARCHS}; do

  # begin table
  echo "<table border='1' cellpadding='4' bgcolor='#F2F2F2'>" >> ${TMPFILE}
  echo "<tr>" >> ${TMPFILE}
  echo "<td align='left' width='80'>&nbsp;</td>" >> ${TMPFILE}
  echo "<th width='60'>as of</th>" >> ${TMPFILE}
  echo "<th>INDEX</th>" >> ${TMPFILE}
  echo "<th>packages</th>" >> ${TMPFILE}
  echo "<th>errors</th>" >> ${TMPFILE}
  echo "<th>skipped</th>" >> ${TMPFILE}
  echo "<th>missing</th>" >> ${TMPFILE}
  echo "<th>done?</th>" >> ${TMPFILE}
  echo "</tr>" >> ${TMPFILE}

  # begin row
  branches=`ls ${ROOT_DIRECTORY}/${arch} | grep '^[1-9]$' | sort`
  for branch in ${branches}; do

    # first, gather data

    directory=${ROOT_DIRECTORY}/${arch}/${branch}
    if [ "$branch" = "4" ]; then
      indexfile=$directory/ports/INDEX
    else
      indexfile=$directory/ports/INDEX-$branch
    fi

    # column: datestamp of latest log
    latest="&nbsp;"
    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="&nbsp;"
      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

    # now write the row
    echo "<tr>" >> ${TMPFILE}
    echo "<th align='left'>$arch-$branch</th>" >> ${TMPFILE}
    echo "<td align='left'>$latest</td>" >> ${TMPFILE}
    echo "<td align='right'>$n_index</td>" >> ${TMPFILE}
    echo "<td align='right'>" >> ${TMPFILE}
    echo "<a href='http://pointyhat.freebsd.org/errorlogs/$arch-$branch-latest-logs'>" >> ${TMPFILE}
    echo "$n_packages</a></td>" >> ${TMPFILE}
    echo "<td align='right'>" >> ${TMPFILE}
    echo "<a href='http://pointyhat.freebsd.org/errorlogs/$arch-$branch-latest'>" >> ${TMPFILE}
    echo "$n_errors</a></td>" >> ${TMPFILE}
    echo "<td align='right'>$n_duds</td>" >> ${TMPFILE}
    echo "<td align='right'>$n_missing</td>" >> ${TMPFILE}
    echo "<td align='center'>$done_flag</td>" >> ${TMPFILE}
    echo "</tr>" >> ${TMPFILE}

  done

  echo "</table>" >> ${TMPFILE}
  echo "<br>" >> ${TMPFILE}

done

echo "<p>explanation of columns:</p>" >> ${TMPFILE}
echo "<ul>" >> ${TMPFILE}
echo "<li><b>as of</b> is the date of the latest logfile.</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 "</body>" >> ${TMPFILE}
echo "</html>" >> ${TMPFILE}

mv -f ${TMPFILE} ${OUTFILE}