find-build-errors revision 919
cff452c7e974db5053cdbd0d7bbbab2e3b4c91b9Kay Sievers# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
cff452c7e974db5053cdbd0d7bbbab2e3b4c91b9Kay Sievers# Use is subject to license terms.
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers# Permission is hereby granted, free of charge, to any person obtaining a
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers# copy of this software and associated documentation files (the "Software"),
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers# to deal in the Software without restriction, including without limitation
f957632b960a0a42999b38ded7089fa602b41745Kay Sievers# the rights to use, copy, modify, merge, publish, distribute, sublicense,
a40593a0d0d740efa387e35411e1e456a6c5aba7Lennart Poettering# and/or sell copies of the Software, and to permit persons to whom the
20ffc4c4a9226b0e45cc02ad9c0108981626c0bbKay Sievers# Software is furnished to do so, subject to the following conditions:
ea92ae33e0fbbf8a98cd2e08ca5a850d83d57faeMaciej Wereski# The above copyright notice and this permission notice (including the next
ea92ae33e0fbbf8a98cd2e08ca5a850d83d57faeMaciej Wereski# paragraph) shall be included in all copies or substantial portions of the
04ac799283f517672a5424e7c5bf066cfa4ca020Zbigniew Jędrzejewski-Szmek# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
04ac799283f517672a5424e7c5bf066cfa4ca020Zbigniew Jędrzejewski-Szmek# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
f38afcd0c7f558ca5bf0854b42f8c6954f8ad7f3Lennart Poettering# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
7b4da18c1717f811bae67ea3d39290495857c03eLennart Poettering# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
f38afcd0c7f558ca5bf0854b42f8c6954f8ad7f3Lennart Poettering# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
81d112a8f0522a09fcfe317f420363a2b728137cLennart Poettering# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
f38afcd0c7f558ca5bf0854b42f8c6954f8ad7f3Lennart Poettering# DEALINGS IN THE SOFTWARE.
bafb15bab99887d1b6b8a35136531bac6c3876a6Lennart Poetteringrequire 5.005; # minimal Perl version required
eb124a97fb72d076014253b1acde69d428f15ecfLennart Poetteringuse File::Spec; # pathname manipulation routines
154ff088d371bee5651eaa2bc9bde8a34c185656Lennart Poetteringuse File::stat; # Named results from stat() function
f38afcd0c7f558ca5bf0854b42f8c6954f8ad7f3Lennart Poetteringmy $default_logpath = 'log/' . $default_logfile;
f38afcd0c7f558ca5bf0854b42f8c6954f8ad7f3Lennart Poetteringmy $default_pkglogpath = 'proto-packages/logs/package_build';
0bee65f0622c4faa8ac8ae771cc0c8a936dfa284Lennart Poettering $logfile = $ARGV[0] . '/' . $default_logpath;
f38afcd0c7f558ca5bf0854b42f8c6954f8ad7f3Lennart Poettering } elsif ($ARGV[0] =~ m{/package_build$}ms) {
718db96199eb307751264e4163555662c9a389faLennart Poettering File::Spec->rel2abs(File::Spec->curdir()));
718db96199eb307751264e4163555662c9a389faLennart Poettering # climb the tree, removing one parent at a time to find the logfile
718db96199eb307751264e4163555662c9a389faLennart Poettering $logfile = File::Spec->catfile( @dirtree, $default_logpath);
966204e010ed432a1d7a0481d41a326d8ec7b0c8Lennart Poettering# print "$logfile not found\n";
f38afcd0c7f558ca5bf0854b42f8c6954f8ad7f3Lennart Poettering die "$default_logfile not found, please specify path to log\n";
baa89da40a1d42242c9c62603501ada7e9e52613Lennart Poettering or die "Can't open '$logfile': $OS_ERROR";
7f79cd7109a60810140a045cc725291fc5515264Lennart Poettering print "Scanning $logfile for error messages...\n\n";
982e44dbc3e70c97e83464a30354b80973d52b41Lennart Poettering last if $l =~ m{Finished building the X Window System Consolidation}ms;
982e44dbc3e70c97e83464a30354b80973d52b41Lennart Poettering # Clear saved lines for each new module/subdir
fcba531ed4c6e6f8f21d8ca4e3a56e3162b1c578Lennart Poettering if (($l =~ m{^\#\# making \S+ in \S+\.\.\.$}ms) || # open-src pattern
fcba531ed4c6e6f8f21d8ca4e3a56e3162b1c578Lennart Poettering ($l =~ m{^dmake: Warning: Target `subdirs' not remade because of errors}ms) ||
8b8f259170e35b93e6c6d1757cb8b835bbdaa40cZbigniew Jędrzejewski-Szmek ($l =~ m{^\S+ing( \S+)* in \S+\.\.\.$}ms)) { # xc pattern
8b8f259170e35b93e6c6d1757cb8b835bbdaa40cZbigniew Jędrzejewski-Szmek @steplines = ();
e1b7e7ec9b34ae6ae54a4c8084395cbf2bfe9960Lennart Poettering $found_error = 0;
e1b7e7ec9b34ae6ae54a4c8084395cbf2bfe9960Lennart Poettering # If we already hit an error, skip the rest of this module
18d4e7c26e7806ac363d19989df7144d5058ce41Lennart Poettering next if ($found_error != 0);
bdeeb6b543a2a2d0a494f17b85f1498859cdfc2fLennart Poettering # Add this line to the saved output, combine with previous if previous
bdeeb6b543a2a2d0a494f17b85f1498859cdfc2fLennart Poettering # ended with an \
bdeeb6b543a2a2d0a494f17b85f1498859cdfc2fLennart Poettering if (($#steplines >= 0) && ($steplines[$#steplines] =~ m{\\\Z}ms)) {
9444b1f20e311f073864d81e913bd4f32fe95cfdLennart Poettering $steplines[$#steplines] .= $l;
9444b1f20e311f073864d81e913bd4f32fe95cfdLennart Poettering push @steplines, $l;
9444b1f20e311f073864d81e913bd4f32fe95cfdLennart Poettering # Skip ahead to next line if this line ends with \
19aadacf92ad86967ffb678e37b2ff9e83cb9480Jan Engelhardt next if ($l =~ m{\\\Z}ms);
4e09014daf8f98584b3f15e64e93bed232e70a6bLennart Poettering # Found a new error?
4e09014daf8f98584b3f15e64e93bed232e70a6bLennart Poettering if (($l =~ m{\*\*\* }ms) || ($l =~ m{^make: Fatal error}ms)) {
4e09014daf8f98584b3f15e64e93bed232e70a6bLennart Poettering $found_error = 1;
eb01ba5de14859d7a94835ab9299de40132d549aLennart Poettering # Print section header
86312ab8de59c1066d6d2b456f3a9106ce3e0991Lennart Poettering print $steplines[0], "\n";
f38afcd0c7f558ca5bf0854b42f8c6954f8ad7f3Lennart Poettering my $lastcommand = 1;
bee7e928990fd8a0c5909c2022a2b9eede557c81Lennart Poettering my $lastplus = 0;
80caea6cc72ebd311a311b1527cc6b87201c13bfLennart Poettering # scan back to figure out how far back to print
0a825b5cd4adb4d9dadfb2e237cdceae09399804Lennart Poettering for my $ln (1..($#steplines - 1)) {
0a825b5cd4adb4d9dadfb2e237cdceae09399804Lennart Poettering my $sl = $steplines[$ln];
452de75e5b8b1cff207243848f4e5de68620554cLennart Poettering # print "lastmake: $lastmake, lastcom: $lastcommand, lastplus: $lastplus, line #$ln: $sl\n";
df98a87ba389bdfc0359beedf47557411f3af434Lennart Poettering if ($sl =~ m{\b(make|dmake|gmake)\b}ms) {
df98a87ba389bdfc0359beedf47557411f3af434Lennart Poettering $lastmake = $ln;
bee7e928990fd8a0c5909c2022a2b9eede557c81Lennart Poettering if ($sl =~ m{\breturned\b}ms) {
0058679911db806b6db2fa445a1ce879a436c9d6Lennart Poettering } elsif ($sl =~ m{\b(cc|gcc|CC|g\+\+|ld|gpatch|libtool|GEN|CCLD)\s+}ms) {
154ff088d371bee5651eaa2bc9bde8a34c185656Lennart Poettering # print from start of shell's set -x output, not end
e8a7a315391a6a07897122725cd707f4e9ce63d7Lennart Poettering # print "lastmake: $lastmake, lastcommand: $lastcommand\n";
461bd8e47cafacfcd38389e7558330bfb6e902adLennart Poettering if ($lastmake && ($lastmake < $lastcommand)) {
3df82d5a8cdc510f518fd5e234ccb3233b748719Lennart Poettering if ($l =~ m{^result log is in (.*/package_build)$}ms) {
b5c03638d48c07aa0eaf13b5f54000c7133e1883Lennart Poettering } elsif ($l =~ m{^Packages failed:\s+(\d+)}ms) {
b5c03638d48c07aa0eaf13b5f54000c7133e1883Lennart Poettering # print lines where messages about COPYING file errors appear
eece8c6fb5f4d354dcef6fd369e876c4f3a3f163Lennart Poettering # between "Copying package descriptions" & "Building packages"
eece8c6fb5f4d354dcef6fd369e876c4f3a3f163Lennart Poettering elsif ($l =~ m{Copying package descriptions}) {
0be8342c04bbf129b4a21e5073eacccbbce4e896Lennart Poettering # Haven't rebuilt packages since last build, so no point reporting errors
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering# No packaging log found in build log, try to guess where it is
3679d1126bae52e02f6cd60fca196f616b9e660dLennart Poettering $path_to_check =~ s{$default_logpath}{$default_pkglogpath}ms;
f8aeee1f1fe432924b355f48f01f09c9a552ed97Lennart Poettering $path_to_check =~ s{($default_logpath).*$}{$default_pkglogpath}ms;
490b7e47093d491a2bdb1084fe92b796f4e07eefLennart Poetteringif ((!defined($pkgfailed) || ($pkgfailed > 0)) && defined($pkglog)) {
490b7e47093d491a2bdb1084fe92b796f4e07eefLennart Poettering or die "Can't open '$pkglog': $OS_ERROR";
e41814846c19a48f4490169d82e359e005c4db45Lennart Poettering if ($l =~ m{^[*]+ Making the \S+ package [*]+$}ms) {
b44be3ecf6326c27aa2c6c6d1fe34e22e22592a0Lennart Poettering next if $l =~ m{^WARNING: parameter \<PSTAMP\> set}ms;
b44be3ecf6326c27aa2c6c6d1fe34e22e22592a0Lennart Poettering next if $l =~ m{^WARNING: parameter \<CLASSES\> set to "none"}ms;
b44be3ecf6326c27aa2c6c6d1fe34e22e22592a0Lennart Poettering if (($l =~ m{(Packaging was not successful.|was not found ; skipping)}ms)