#!/bin/sh # $FreeBSD: ports/Tools/portbuild/scripts/processonelog,v 1.33 2011/03/08 21:53:53 linimon Exp $ # # Read a single errorlogfile and output a line of the format # $filename|$portname|$affected|$logsize|$dir|$maintainer|\ # $reason|$tag|$broken|$datetime # # Originally factored out of: ports/Tools/portbuild/scripts/processlogs filename=$1 indexdir=. errordir=. if [ "$2" != "" ]; then indexdir=$2; fi if [ "$3" != "" ]; then errordir=$3; fi indexdir=$(realpath $indexdir) errordir=$(realpath $errordir) indexfilename=$indexdir/INDEX HEADER_LINES=9 portname=$(basename $filename .log.bz2) if [ "${portname}" = "${filename}" ]; then cat=cat else cat=bzcat fi portname=$(basename $portname .log) affected=$(($(grep -cF $portname < $indexfilename) -1)) logsize=$(/bin/ls -sk $errordir/$filename | awk '{print $1}') dir=$(${cat} $errordir/$filename | head -$HEADER_LINES | grep '^port directory:' | awk '{print $3}' | \ sed -e 's,^/[^/]*/[^/]*/,,') maintainer=$(${cat} $errordir/$filename | head -$HEADER_LINES | grep '^maintained by' | awk '{print $3}') datetime=$(${cat} $errordir/$filename | head -$HEADER_LINES | grep '^build started at' | \ sed -e 's/build started at ...//' | tr ' ' '_' ) # now try to classify the type of error found in the file. # the first case handles failures to even try to build any # port (i.e. HTML file no longer there, pointyhat being unable # to fetch any file, pointyhat being able to build any port, etc.) if [ -z "$dir" -o -z "$datetime" ]; then reason="cluster"; tag="cluster" elif bzgrep -qE "(Error: mtree file ./etc/mtree/BSD.local.dist. is missing|error in pkg_delete|filesystem was touched prior to .make install|list of extra files and directories|list of files present before this port was installed|list of filesystem changes from before and after)" $1; then reason="mtree"; tag="mtree" # note: must run before the configure_error check elif bzgrep -qE "Configuration .* not supported" $1; then reason="arch"; tag="arch" elif bzgrep -qE '(configure: error:|Script.*configure.*failed unexpectedly|script.*failed: here are the contents of)' $1; then if bzgrep -qE "configure: error: cpu .* not supported" $1; then reason="arch"; tag="arch" elif bzgrep -qE "configure: error: [Pp]erl (5.* required|version too old)" $1; then reason="perl"; tag="perl" elif bzgrep -q 'sem_wait: Invalid argument' $1; then reason="sem_wait"; tag="sem_wait" else reason="configure_error"; tag="configure" fi elif bzgrep -q "Couldn't fetch it - please try" $1; then reason="fetch"; tag="fetch" elif bzgrep -q "Error: shared library \".*\" does not exist" $1; then reason="LIB_DEPENDS"; tag="libdepends" elif bzgrep -qE "\.(c|cc|cxx|cpp|h|y)[1-9:]+ .+\.[hH]: No such file" $1; then reason="missing_header"; tag="header" elif bzgrep -qE '(nested function.*declared but never defined|warning: nested extern declaration)' $1; then reason="nested_declaration"; tag="nested_declaration" # note: must be run before compiler_error elif bzgrep -q '#warning "this file includes ' $1; then reason="termios"; tag="termios" # note: must be run before compiler_error elif bzgrep -qE "(#error define UTMP_FILENAME in config.h|error: ._PATH_UTMP. undeclared|error: .struct utmpx. has no member named .ut_name|error: invalid application of .sizeof. to incomplete type .struct utmp|utmp.h> has been replaced by for instructions." $1; then reason="gcc_bug"; tag="gcc-bug" elif bzgrep -qE "(missing separator|mixed implicit and normal rules|recipe commences before first target).*Stop" $1; then reason="gmake"; tag="gmake" elif bzgrep -qE "(Run-time system build failed for some reason|tar: Error opening archive: Failed to open.*No such file or directory)" $1; then reason="install_error"; tag="install" elif bzgrep -qE "(cc: .*libintl.*: No such file or directory|cc: ndbm\.so: No such file or directory|error: linker command failed|error: The X11 shared library could not be loaded|libtool: link: cannot find the library|relocation against dynamic symbol|Shared object.*not found, required by)" $1; then reason="linker_error"; tag="ld" elif bzgrep -q "libtool: finish: invalid argument" $1; then reason="libtool"; tag="libtool" elif bzgrep -q "Could not create Makefile" $1; then reason="makefile"; tag="makefile" elif bzgrep -v "regression-test.continuing" $1 | grep -qE "make.*(cannot open [Mm]akefile|don.t know how to make|fatal errors encountered|No rule to make target|built-in)"; then reason="makefile"; tag="makefile" elif bzgrep -q "/usr/.*/man/.*: No such file or directory" $1; then reason="manpage"; tag="manpage" elif bzgrep -q "out of .* hunks .*--saving rejects to" $1; then reason="patch"; tag="patch" elif bzgrep -qE "((perl|perl5.6.1):.*(not found|No such file or directory)|cp:.*site_perl: No such file or directory|perl(.*): Perl is not installed, try .pkg_add -r perl|Perl .* required--this is only version)" $1; then reason="perl"; tag="perl" elif bzgrep -qE "(Abort trap|Bus error|Error 127|Killed: 9|Signal 1[01])" $1; then reason="process_failed"; tag="process" elif bzgrep -qE "(USER.*PID.*TIME.*COMMAND|pnohang: killing make package)" $1; then reason="runaway_process"; tag="runaway" elif bzgrep -qE "(/usr/bin/ld: cannot find -l(pthread|XThrStub)|cannot find -lc_r|Error: pthreads are required to build this package|Please install/update your POSIX threads (pthreads) library|requires.*thread support|: The -pthread option is deprecated)" $1; then reason="threads"; tag="threads" elif bzgrep -qi 'read-only file system' $1; then reason="WRKDIR"; tag="wrkdir" # Although these can be fairly common, and thus in one sense ought to be # earlier in the evaluation, in practice they are most often secondary # types of errors, and thus need to be evaluated after all the specific # cases. elif bzgrep -qE 'cc1.*warnings being treated as errors' $1; then reason="compiler_error"; tag="cc" elif bzgrep -q 'tar: Error exit delayed from previous errors' $1; then reason="install_error"; tag="install" elif bzgrep -q "Cannot stat: " $1; then reason="configure_error"; tag="configure" elif bzgrep -q "error in dependency .*, exiting" $1; then reason="depend_package"; tag="dependpkg" elif bzgrep -q "/usr/bin/ld: cannot find -l" $1; then reason="linker_error"; tag="ld" elif bzgrep -q "cd: can't cd to" $1; then reason="NFS"; tag="nfs" elif bzgrep -q "pkg_create: make_dist: tar command failed with code" $1; then reason="PLIST"; tag="plist" elif bzgrep -q "Segmentation fault" $1; then reason="segfault"; tag="segfault" # note: searching for string-not-found here (builds that terminated early) elif ! bzgrep -qE "^build of .* ended at" $1; then reason="cluster"; tag="cluster" else reason="???"; tag="unknown" fi # clean up some error cases -- the way .logs works, it expects that # every field in it MUST be nonblank, so we insert a metatoken here. # See below. if [ -z "$dir" ]; then dir="NONE" fi if [ -z "$maintainer" ]; then maintainer="NONE" fi if [ -z "$datetime" ]; then datetime="NONE" fi broken="no" if bzgrep -q "Trying build of .* even though it is marked BROKEN" $1; then broken="broken" fi echo "$filename|$portname|$affected|$logsize|$dir|$maintainer|$reason|$tag|$broken|$datetime|$errordir"