#!/usr/bin/perl -Tw #- # Copyright (c) 2003-2013 Dag-Erling Smørgrav # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # use v5.10.1; use strict; use POSIX qw(strftime); use Sys::Hostname; my %BRANCHES; my %ARCHES; my $DIR = "."; sub success($) { my ($log) = @_; local *FILE; my $result; if (open(FILE, "<", $log)) { $result = grep { m/tinderbox run completed/ } ; close(FILE); } return $result; } sub branch_rank($) { my ($branch) = @_; my $rank; if ($branch =~ m/\b(HEAD|CURRENT)$/i) { $rank = "9999"; } elsif ($branch =~ m/\bRELENG_(\d{1,2})$/i) { $rank = sprintf("%02d99", $1); } elsif ($branch =~ m/\bRELENG_(\d{1,2})_(\d{1,2})$/i) { $rank = sprintf("%02d%02d", $1, $2); } else { $rank = $branch; } return $rank; } sub branch_sort($$) { my ($a, $b) = @_; return branch_rank($a) cmp branch_rank($b); } sub inverse_branch_sort($$) { my ($a, $b) = @_; return branch_rank($b) cmp branch_rank($a); } sub do_branch($) { my ($branch) = @_; my $prettybranch = $branch; $prettybranch =~ s@^HEAD$@head@; $prettybranch =~ s@^RELENG_(\d+)_(\d+)$@releng/$1.$2@; $prettybranch =~ s@^RELENG_(\d+)$@stable/$1@; print "   "; foreach my $arch (sort(keys(%ARCHES))) { foreach my $machine (sort(keys(%{$ARCHES{$arch}}))) { if ($arch eq $machine) { print " $arch\n"; } else { print " $arch
$machine\n"; } } } print " \n"; my $now = time(); foreach my $config (sort(keys(%{$BRANCHES{$branch}}))) { $config =~ m/^(\w+)((?:-\w+)*?)(-build)?$/; my $variant = $2 =~ s/^-//r; print " $prettybranch" . ($variant ? "
($variant)" : "") . " "; foreach my $arch (sort(keys(%ARCHES))) { foreach my $machine (sort(keys(%{$ARCHES{$arch}}))) { my $log = "tinderbox-$config-$branch-$arch-$machine"; if (-f "$DIR/$log.brief") { print " "; my @stat = stat(_); my $class = success("$DIR/$log.brief") ? "ok" : "fail"; my $age = int(($now - $stat[9]) / 1800); $age = ($age < 0) ? 0 : ($age > 9) ? 9 : $age; $class .= "-$age"; print "" . strftime("%Y-%m-%d
%H:%M UTC", gmtime($stat[9])) . "

"; print "" . "summary"; if (-f "$DIR/$log.full") { print " | full log"; } print ""; print "\n"; } else { print " n/a\n"; } } } print " \n"; } } MAIN:{ my $date = strftime("%Y-%m-%d %H:%M:%S UTC", gmtime()); my $realthing; # is this the authentic tinderbox site my $greeting; $| = 1; if ($ENV{'GATEWAY_INTERFACE'}) { print "Content-Type: text/html; charset=utf-8\n\n"; $realthing = ($ENV{'SERVER_NAME'} eq 'tinderbox.freebsd.org'); } else { my $host = hostname(); $realthing = ($host eq 'dma.des.no'); } if ($realthing) { $greeting = "tinderbox.freebsd.org"; } else { $greeting = "For official Tinderbox logs, see here"; } local *DIR; opendir(DIR, $DIR) or die("$DIR: $!\n"); foreach (readdir(DIR)) { next unless m/^tinderbox-([\w-]+)-(\w+)-(\w+)-(\w+)\.(brief|full)$/; $BRANCHES{$2}->{$1} = $ARCHES{$3}->{$4} = 1; } closedir(DIR); print " FreeBSD tinderbox logs "; # Count columns my $columns = 1; print " \n"; foreach my $arch (sort(keys(%ARCHES))) { foreach my $machine (sort(keys(%{$ARCHES{$arch}}))) { print " \n"; $columns++; } } # Generate rows foreach my $branch (sort(inverse_branch_sort keys(%BRANCHES))) { do_branch($branch); } print "
"; exit(0); }