OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Michael Schloh
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-web                      Date:   24-Sep-2004 16:08:11
  Branch: HEAD                             Handle: 2004092415081000

  Added files:
    openpkg-web             badstatus.cgi

  Log:
    track source badstatus.cgi as derived from status.cgi by Thomas
    LOTTERER

  Summary:
    Revision    Changes     Path
    1.1         +219 -0     openpkg-web/badstatus.cgi
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-web/badstatus.cgi
  ============================================================================
  $ cvs diff -u -r0 -r1.1 badstatus.cgi
  --- /dev/null 2004-09-24 16:08:11 +0200
  +++ badstatus.cgi     2004-09-24 16:08:11 +0200
  @@ -0,0 +1,219 @@
  +#!/usr/opkg/bin/perl
  +##
  +##  status.cgi -- Package Build Farm Status Report
  +##
  +
  +use POSIX qw(strftime);
  +require 5;
  +use IO;
  +$|++;
  +
  +my $O = '';
  +
  +my $bgcolors = {
  +    "CORE" => [qw(#fffff0 #f5f5e5)],
  +    "BASE" => [qw(#f0f0f0 #e5e5e5)],
  +    "PLUS" => [qw(#eae0d0 #dfd5c5)],
  +    "EVAL" => [qw(#f0f0ff #e5e5f5)],
  +    "JUNK" => [qw(#fff0f0 #f0e0e0)],
  +};
  +
  +my $mtime = (stat("status.txt"))[9];
  +my $updated = strftime("%a %d-%b-%Y %H:%M", localtime($mtime));
  +
  +my %id2host = (
  +    'ixFB4' => { -host => 'dv1',  -important => 1 },
  +    'ixFB5' => { -host => 'dv2',  -important => 1 },
  +    'alFB5' => { -host => 'dv12', -important => 0 },
  +    'usNB1' => { -host => 'dv3',  -important => 0 },
  +    'ixNB1' => { -host => 'dv20', -important => 0 },
  +    'ixMLX' => { -host => 'dv5',  -important => 0 },
  +    'ixDL3' => { -host => 'dv6',  -important => 1 },
  +    'ixDLT' => { -host => 'dv19', -important => 0 },
  +    'ixRL9' => { -host => 'dv4',  -important => 0 },
  +    'ixFC2' => { -host => 'dv22', -important => 1 },
  +    'ixRE3' => { -host => 'dv23', -important => 1 },
  +    'ixS90' => { -host => 'dv14', -important => 0 },
  +    'ixS91' => { -host => 'dv17', -important => 1 },
  +    'ixGL1' => { -host => 'dv18', -important => 0 },
  +    'ixSO9' => { -host => 'dv7',  -important => 1 },
  +    'usSF9' => { -host => 'dv9',  -important => 1 },
  +    'usSO8' => { -host => 'dv8',  -important => 1 },
  +    'ivSOX' => { -host => 'vm10', -important => 0 },
  +    'usSOX' => { -host => 'dv21', -important => 0 },
  +    'usSO6' => { -host => 'dv13', -important => 0 },
  +    'paH11' => { -host => 'dv28', -important => 0 },
  +);
  +
  +my $io = new IO::File "<status.txt" || die;
  +my $odd = 0;
  +$O .= "<table cellspacing=1 cellpadding=2 border=0 width=\"90%\">\n";
  +my $ishead = 1;
  +my @hostlist = ();
  +my @idlist = ();
  +my @arch = ();
  +my $class_last = "";
  +my %doing = ();
  +while ($line = <$io>) {
  +    # a2ps            4.13b           20020609   REL yes  OK   OK ...
  +    if ($line =~ m|^===|) {
  +        next;
  +    }
  +    my @line = split(/\s+/, $line);
  +    my ($name, $version, $release, $class, $rel) = @line[0..4];
  +    if ($ishead) {
  +        my @ids = @line[5..$#line];
  +        @idlist = @ids;
  +        $ishead = 0;
  +        $O .= "<tr bgcolor=\"#000000\">\n";
  +        $O .= "<td align=center><font color=\"#ffffff\">Ok</font></td>";
  +        $O .= "<td><font color=\"#ffffff\">$name</font></td>";
  +        $O .= "<td><font color=\"#ffffff\">$version</font></td>";
  +        $O .= "<td><font color=\"#ffffff\">$release</font></td>";
  +        $O .= "<td><font color=\"#ffffff\">$class</font></td>";
  +        $O .= "<td><font color=\"#ffffff\">$rel</font></td>";
  +        foreach my $id (@ids) {
  +            $O .= "<td width=30><font color=\"#ffffff\" 
size=\"-1\">$id</font></td>";
  +            push(@hostlist, $id2host{$id}->{-host});
  +        }
  +        $O .= "</tr>\n";
  +        foreach my $id (@ids) {
  +            my $host = $id2host{$id}->{-host};
  +            my $fn = (glob("status.log/processing.$host.*"))[0] || next;
  +            my $mtime = (stat($fn[0]))[9];
  +            #if ($mtime > time()-(10*60)) {
  +                my $io = new IO::File "<$fn" or next;
  +                $doing{$host} = <$io>;
  +                $doing{$host} =~ s|^\s*(\S+).*$|$1|s;
  +                $io->close;
  +            #}
  +        }
  +    }
  +    else {
  +        my @hosts = @line[5..$#line];
  +        my $img = "icon-x.gif";
  +        my $ok = 1;
  +        my $n  = 0;
  +        next unless ($class =~ m/(CORE|BASE|PLUS)/);
  +        $L = "";
  +        foreach my $host (@hosts) {
  +            my @log;
  +            my $log;
  +            unless (defined $arch[$n]) {
  +                @log = 
glob("status.log/$name-$version-$release.log.".$hostlist[$n].".*"); 
  +                $log = $log[0];
  +                ($arch[$n]) = ($log =~ /\Q.log.$hostlist[$n].\E(.*)$/);
  +            } else {
  +                $log = 
"status.log/$name-$version-$release.log.$hostlist[$n].$arch[$n]";
  +                @log = ($log) if (-f $log);
  +            }
  +            $log =~ s|^status.log/||s;
  +
  +            #if ( $host eq "--" &&
  +            #     $#log >= 0 &&
  +            #     `tail -1 $log[0]` =~ /^Build End:/) {
  +            #    $host = "OK";
  +            #}
  +
  +            my $important = ($class eq "CORE" or 
$id2host{$idlist[$n]}->{-important});
  +            if ($host eq "OK") {
  +                if (defined($doing{$hostlist[$n]}) and $doing{$hostlist[$n]} eq 
"$name-$version-$release") {
  +                    $L .= "<td bgcolor=\"#".($important ? "f0f099" : "999933")."\" 
align=center>";
  +                    $L .= "<a href=\"status-log.cgi/".$log."\">" if ($#log >= 0);
  +                    $L .= "<img src=\"status.img/icon-dia.gif\" width=9 height=9 
alt=\"OK\" border=0>";
  +                    $L .= "</a>" if ($#log >= 0);
  +                }
  +                else {
  +                    $L .= "<td bgcolor=\"#".($important ? "99cc99" : "336633")."\" 
align=center>";
  +                    $L .= "<a href=\"status-log.cgi/".$log."\">" if ($#log >= 0);
  +                    $L .= "<img src=\"status.img/icon-ok.gif\" width=9 height=9 
alt=\"OK\" border=0>";
  +                    $L .= "</a>" if ($#log >= 0);
  +                }
  +            }
  +            elsif ($host eq "FAIL") {
  +                $ok = 0 if ($important);
  +                if (defined($doing{$hostlist[$n]}) and $doing{$hostlist[$n]} eq 
"$name-$version-$release") {
  +                    $L .= "<td width=30 bgcolor=\"#".($important ? "f0f099" : 
"999933")."\" align=center>";
  +                    $L .= "<a href=\"status-log.cgi/".$log."\">" if ($#log >= 0);
  +                    $mtime_srpm = 
(stat("/e/openpkg/ftp/current/SRC/$name-$version-$release.src.rpm"))[9];
  +                    $mtime_logf = (stat($log[0]))[9];
  +                    my $img = "icon-dia.gif";
  +                    $L .= "<img src=\"status.img/$img\" width=9 height=9 
alt=\"FAIL\" border=0>";
  +                    $L .= "</a>";
  +                }
  +                else {
  +                    $L .= "<td width=30 bgcolor=\"#".($important ? "ff9999" : 
"993333")."\" align=center>";
  +                    $L .= "<a href=\"status-log.cgi/".$log."\">" if ($#log >= 0);
  +                    $mtime_srpm = 
(stat("/e/openpkg/ftp/current/SRC/$name-$version-$release.src.rpm"))[9];
  +                    $mtime_logf = (stat($log[0]))[9];
  +                    my $img = "icon-x.gif";
  +                    $img = "icon-star.gif" if ($mtime_logf < $mtime_srpm);
  +                    $L .= "<img src=\"status.img/$img\" width=9 height=9 
alt=\"FAIL\" border=0>";
  +                    $L .= "</a>";
  +                }
  +            }
  +            elsif ($host eq "--") {
  +                $ok = 0 if ($important);
  +                if (defined($doing{$hostlist[$n]}) and $doing{$hostlist[$n]} eq 
"$name-$version-$release") {
  +                    $L .= "<td width=30 bgcolor=\"#".($important ? "f0f099" : 
"999933")."\" align=center>";
  +                    my $img = "icon-dia.gif";
  +                    $L .= "<img src=\"status.img/$img\" width=9 height=9 alt=\"--\" 
border=0>";
  +                }
  +                else {
  +                    $L .= "<td width=30 bgcolor=\"#".($important ? "9999ff" : 
"000066")."\" align=center>";
  +                    $L .= "<img src=\"status.img/icon-dot.gif\" width=9 height=9 
alt=\"--\" border=0>";
  +                }
  +            }
  +            $L .= "</td>";
  +            $n++;
  +        }
  +        $L .= "</tr>\n";
  +
  +        if ($ok) {
  +            $img = "icon-ok.gif";
  +        }
  +        #if ($class_last ne '' and $class_last ne $class) {
  +        #    $O .= "</table>";
  +        #    $O .= "<br>";
  +        #    $O .= "<table cellspacing=1 cellpadding=2 border=0 width=\"90%\">\n";
  +        #}
  +        #$class_last = $class;
  +        if (not $ok) {
  +            $O .= "<tr bgcolor=\"".$bgcolors->{$class}->[$odd]."\">\n";
  +            $O .= "<td align=center><img src=\"status.img/$img\" width=9 height=9 
alt=\"\"></td>";
  +            $O .= "<td><a 
href=\"ftp://ftp.openpkg.org/current/SRC/$name-$version-$release.src.rpm\";><font 
color=\"#000000\">$name</font></a></td>";
  +            $O .= "<td>$version</td>";
  +            $O .= "<td>$release</td>";
  +            $O .= "<td>$class</td>";
  +            $O .= "<td>$rel</td>";
  +            $O .= $L;
  +        }
  +
  +    }
  +    $odd = ($odd + 1) % 2;
  +}
  +$O .= "</table>\n";
  +$io->close();
  +
  +$O .= "<p>(last update: $updated)<p>\n";
  +
  +######################################################
  +
  +my $head = '';
  +$io = new IO::File "<status.head.html" || die;
  +$head .= $_ while (<$io>);
  +$io->close();
  +
  +my $foot = '';
  +$io = new IO::File "<status.foot.html" || die;
  +$foot .= $_ while (<$io>);
  +$io->close();
  +
  +$O = $head . $O . $foot;
  +
  +$O = "Content-type: text/html\r\n" .
  +     sprintf("Content-length: %d\r\n", length($O)) .
  +     "\r\n" . $O;
  +print STDOUT $O;
  +exit(0);
  +
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to