#!/usr/local/bin/perl # # Copyright (c) 2002-2004 Eric Wallengren # This file is part of the Continuous Automated Build and Integration # Environment (CABIE) # # CABIE is distributed under the terms of the GNU General Public # License version 2 or any later version. See the file COPYING for copying # permission or http://www.gnu.org. # # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR # IMPLIED, without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. ANY USE IS AT YOUR OWN RISK. # # Permission to modify the code and to distribute modified code is granted, # provided the above notices are retained, and a notice that the code was # modified is included with the above copyright notice. # BEGIN { push @INC, "lib"; push @INC, "../lib"; push @INC, "../../lib"; } use Getopt::Long; use English; use File::Basename; use Sys::Hostname; my $hostname = hostname(); $hostname =~ s/\.[a-zA-Z0-9\n]+//g; require "$hostname.pm"; my $config = new $hostname; my $logo = $config->LOGOICON; use vars qw( $opt_infile $opt_outfile $opt_errorfile $opt_help); ParseArgs(); my $lines; my @errorarray = ReadFile($opt_errorfile); my @document = ProcessFile($opt_infile, $opt_outfile); open (OUT, ">$opt_outfile") || die "open: $?"; foreach $line (reverse @document) { print OUT "$line"; } close(OUT) || die "close: $?"; #------------------------------------------------------------------------- sub Usage { my ( $program ) = basename( $PROGRAM_NAME ); print << "EOF" Usage: $program --infile infile --outfile outfile --errorfile errorfile Required args: --infile | -i = input file (build log) --outfile | -o = output file (html file) --errorfile | -e = error file (list file) Optional args: --help | -h = help EOF } sub ParseArgs { $Getopt::Long::ignorecase = 0; if ( ! GetOptions( "infile|i=s", "outfile|o=s", "errorfile|e=s", "help|h", ) ) { Usage; exit 1; } if ( $opt_help ) { Usage; exit 0; } if (!$opt_infile) { Usage; exit 1; } if (!$opt_outfile) { Usage; exit 1; } if (!$opt_errorfile) { Usage; exit 1; } } sub ReadFile { my $File = shift; my @contents; if (! -f $File) { print "no file: $File\n"; exit -1; } else { open (EF, "<$File") || die "open: $?"; @contents = ; close(EF) || die "close: $?"; } return @contents; } sub ProcessFile { my $in = shift; my $out = shift; my $entry; my $search; my $i; my @inarray; my @reversearray; my $errors = 0; my $warnings = 0; if (! -f $in) { print "no file: $in\n"; exit -1; } else { open(IN, "<$in") || die "open: $?"; @inarray = ; close(IN) || die "close: $?"; } push @reversearray, "\n"; foreach $search (reverse @inarray) { $Error = 0; chomp $search; foreach $entry (@errorarray) { chomp $entry; my $x = index($search, $entry); if ($x > -1) { $Error = 1; $errors++; } } my $w = index($search, "warning"); if ($Error) { push @reversearray, "
\n";
            push @reversearray, "$search\n";
            push @reversearray, "

\n";
        } else {
            if ($w != -1) {
                $warnings++;
                push @reversearray, "

\n";
                push @reversearray, "$search\n";
                push @reversearray, "

\n";
            } else {
                push @reversearray, "$search\n";
            }
        }

    }

    push @reversearray, "
\n";
    push @reversearray, "
\n"; push @reversearray, ""; for ($i = $warnings; $i > 0; $i--) { push @reversearray, "
  • Warning $i\n"; } for ($i = $errors; $i > 0; $i--) { push @reversearray, "
  • Error $i\n"; } push @reversearray, "
      "; push @reversearray, "\n"; push @reversearray, "\n"; push @reversearray, "\n"; push @reversearray, "\n"; push @reversearray, "

      A-BIMS - Build Log 

      \n"; push @reversearray, "\n"; push @reversearray, "\n"; push @reversearray, "\n"; push @reversearray, "\"LOGO\"\n"; push @reversearray, "\n"; push @reversearray, "\n"; push @reversearray, "\n"; push @reversearray, "\n"; push @reversearray, "\n"; push @reversearray, "\n"; push @reversearray, "\n"; return @reversearray; }