find-build-errors revision 810
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# Use is subject to license terms.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# Permission is hereby granted, free of charge, to any person obtaining a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# copy of this software and associated documentation files (the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# "Software"), to deal in the Software without restriction, including
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# without limitation the rights to use, copy, modify, merge, publish,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# distribute, and/or sell copies of the Software, and to permit persons
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# to whom the Software is furnished to do so, provided that the above
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# copyright notice(s) and this permission notice appear in all copies of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# the Software and that both the above copyright notice(s) and this
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# permission notice appear in supporting documentation.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington# Except as contained in this notice, the name of a copyright holder
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# shall not be used in advertising or otherwise to promote the sale, use
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# or other dealings in this Software without prior written authorization
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster# of the copyright holder.
88f608b8855a99b19653376900fc5f234b7e771cDavid Luna# ident "@(#)find-build-errors 1.4 09/10/13 SMI"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosteruse File::stat; # Named results from stat() function
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fostermy $default_pkglogpath = 'proto-packages/logs/package_build';
88f608b8855a99b19653376900fc5f234b7e771cDavid Luna # climb the tree, removing one parent at a time to find the logfile
88f608b8855a99b19653376900fc5f234b7e771cDavid Luna $logfile = File::Spec->catfile( @dirtree, $default_logpath);
88f608b8855a99b19653376900fc5f234b7e771cDavid Luna# print "$logfile not found\n";
7b8fd79c6177846da551bb2cd5e1579b7c650a3cDavid Luna die "$default_logfile not found, please specify path to log\n";
fb3b3a01405c222ae1fdbbe6f5c1d4aa696195bbDavid Luna print "Scanning $logfile for error messages...\n\n";
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna last if $l =~ m{Finished building the X Window System Consolidation}ms;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (($l =~ m{^\#\# making \S+ in \S+\.\.\.$}ms) || # open-src pattern
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ($l =~ m{^dmake: Warning: Target `subdirs' not remade because of errors}ms) ||
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ($l =~ m{^\S+ing( \S+)* in \S+\.\.\.$}ms)) { # xc pattern
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster @steplines = ();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $found_error = 0;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # If we already hit an error, skip the rest of this module
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster next if ($found_error != 0);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # Add this line to the saved output, combine with previous if previous
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # ended with an \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (($#steplines >= 0) && ($steplines[$#steplines] =~ m{\\\Z}ms)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $steplines[$#steplines] .= $l;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster push @steplines, $l;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # Skip ahead to next line if this line ends with \
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster next if ($l =~ m{\\\Z}ms);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # Found a new error?
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (($l =~ m{\*\*\* }ms) || ($l =~ m{^make: Fatal error}ms)) {
7b8fd79c6177846da551bb2cd5e1579b7c650a3cDavid Luna $found_error = 1;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # Print section header
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster print $steplines[0], "\n";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster my $lastmake;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster my $lastcommand = 1;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster my $lastplus = 0;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # scan back to figure out how far back to print
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster for my $ln (1..($#steplines - 1)) {
88f608b8855a99b19653376900fc5f234b7e771cDavid Luna my $sl = $steplines[$ln];
fb3b3a01405c222ae1fdbbe6f5c1d4aa696195bbDavid Luna # print "lastmake: $lastmake, lastcom: $lastcommand, lastplus: $lastplus, line #$ln: $sl\n";
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna if ($sl =~ m{\b(make|dmake|gmake)\b}ms) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $lastmake = $ln;
fb3b3a01405c222ae1fdbbe6f5c1d4aa696195bbDavid Luna if ($sl =~ m{\breturned\b}ms) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } elsif ($sl =~ m{\b(cc|gcc|CC|g\+\+|ld|gpatch|libtool|GEN|CCLD)\s+}ms) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # print from start of shell's set -x output, not end
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # print "lastmake: $lastmake, lastcommand: $lastcommand\n";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ($l =~ m{^result log is in (.*/package_build)$}ms) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # print lines where messages about COPYING file errors appear
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster # between "Copying package descriptions" & "Building packages"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster elsif ($l =~ m{Copying package descriptions}) {
88f608b8855a99b19653376900fc5f234b7e771cDavid Luna # Haven't rebuilt packages since last build, so no point reporting errors
fb3b3a01405c222ae1fdbbe6f5c1d4aa696195bbDavid Luna# No packaging log found in build log, try to guess where it is
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna $path_to_check =~ s{$default_logpath}{$default_pkglogpath}ms;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster $path_to_check =~ s{($default_logpath).*$}{$default_pkglogpath}ms;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterif ((!defined($pkgfailed) || ($pkgfailed > 0)) && defined($pkglog)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ($l =~ m{^[*]+ Making the \S+ package [*]+$}ms) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster next if $l =~ m{^WARNING: parameter \<PSTAMP\> set}ms;
7b8fd79c6177846da551bb2cd5e1579b7c650a3cDavid Luna next if $l =~ m{^WARNING: parameter \<CLASSES\> set to "none"}ms;
7b8fd79c6177846da551bb2cd5e1579b7c650a3cDavid Luna if (($l =~ m{(Packaging was not successful.|was not found ; skipping)}ms)