find-build-errors revision 810
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# to whom the Software is furnished to do so, provided that the above
# copyright notice(s) and this permission notice appear in all copies of
# the Software and that both the above copyright notice(s) and this
# permission notice appear in supporting documentation.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Except as contained in this notice, the name of a copyright holder
# shall not be used in advertising or otherwise to promote the sale, use
# or other dealings in this Software without prior written authorization
# of the copyright holder.
#
# ident "@(#)find-build-errors 1.4 09/10/13 SMI"
#
require 5.005; # minimal Perl version required
use strict; #
use diagnostics; #
my $default_logfile = 'buildit-XW';
my $logfile;
my $pkglog;
my $pkgfailed;
} else {
}
} else {
# climb the tree, removing one parent at a time to find the logfile
# print "$logfile not found\n";
}
}
}
my @steplines;
my $found_error = 0;
# Finished if we see the end line
($l =~ m{^\S+ing( \S+)* in \S+\.\.\.$}ms)) { # xc pattern
@steplines = ();
$found_error = 0;
}
# If we already hit an error, skip the rest of this module
next if ($found_error != 0);
# Add this line to the saved output, combine with previous if previous
# ended with an \
if (($#steplines >= 0) && ($steplines[$#steplines] =~ m{\\\Z}ms)) {
$steplines[$#steplines] .= $l;
} else {
push @steplines, $l;
}
# Skip ahead to next line if this line ends with \
next if ($l =~ m{\\\Z}ms);
# Found a new error?
if (($l =~ m{\*\*\* }ms) || ($l =~ m{^make: Fatal error}ms)) {
$found_error = 1;
# Print section header
print $steplines[0], "\n";
my $lastmake;
my $lastcommand = 1;
my $lastplus = 0;
# scan back to figure out how far back to print
for my $ln (1..($#steplines - 1)) {
my $sl = $steplines[$ln];
# print "lastmake: $lastmake, lastcom: $lastcommand, lastplus: $lastplus, line #$ln: $sl\n";
if ($sl =~ m{\b(make|dmake|gmake)\b}ms) {
$lastmake = $ln;
}
if ($sl =~ m{\breturned\b}ms) {
$lastcommand = $ln;
}
# print from start of shell's set -x output, not end
$lastcommand = $ln;
}
$lastcommand = $ln;
}
}
# print "lastmake: $lastmake, lastcommand: $lastcommand\n";
print $steplines[$lastmake];
}
print $steplines[$ln];
}
}
}
my $printme = 0;
# end of file stuff
print $l;
next;
}
# Look for package build results
$pkglog = $1;
print $l;
$pkgfailed = $1;
print $l;
}
# print lines where messages about COPYING file errors appear
# between "Copying package descriptions" & "Building packages"
$printme = 1;
$printme = 0;
}
print $l;
}
}
}
sub check_pkglog {
# Haven't rebuilt packages since last build, so no point reporting errors
}
} else {
}
return $pl;
}
# No packaging log found in build log, try to guess where it is
my $path_to_check = $logfile;
}
}
my @pkglines;
# Clear saved lines for each new package
}
# Warnings we can ignore
}
}
}