From f72c5d25093ca6a82729ca2b5ab3da06dd928266 Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 14 Sep 2015 13:37:18 +0000 Subject: [PATCH] improved status logging svn path=/branches/test/; revision=31863 --- build/build_main.sh | 2 ++ build/buildrun.sh | 6 +++++- build/misc.sh | 1 + build/status.html.sh | 19 +++++++++++++------ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/build/build_main.sh b/build/build_main.sh index 0dcb205e8a..422853976f 100755 --- a/build/build_main.sh +++ b/build/build_main.sh @@ -2,6 +2,7 @@ basedir="$(dirname "$0")/.." [ -z "$inc_misc" ] && . "$basedir/build/misc.sh" +readonly start_time="$(date +%s)" . "$basedir/build/arguments.sh" @@ -23,6 +24,7 @@ if [ $command = "build_into" -o $command = "svn_build_into" ] && [ "$buildpids" debug "build script is already running" exit 0 fi +[ -n "$statusdir" ] && cp "$basedir/build/status.html.sh" "$statusdir/index.cgi" [ -z "$inc_filenames" ] && . "$basedir/build/filenames.sh" [ -z "$inc_buildrun" ] && . "$basedir/build/buildrun.sh" diff --git a/build/buildrun.sh b/build/buildrun.sh index 1244041cb4..5edeff2d02 100755 --- a/build/buildrun.sh +++ b/build/buildrun.sh @@ -9,6 +9,7 @@ inc_buildrun=true build_into(){ ncpu="$(grep -c ^processor /proc/cpuinfo)" + printf %s "$start_time" |logstatus start_time [ -s "$(logname debug)" ] && truncate -s 0 "$(logname debug)" forcelog Makefile @@ -32,6 +33,8 @@ build_into(){ [ "$stagedir" != "$target" ] && \ rsync -av --del "$stagedir/" "$target/" \ | logstatus stagesync + + date +%s |logstatus end_time } svn_build_into(){ @@ -39,8 +42,9 @@ svn_build_into(){ forcelog SVNerrors; SVNerrors="$(logname SVNerrors)" svn --non-interactive update "$basedir" >"$SVNchanges" 2>"$SVNerrors" + svnterm="$?" - if [ -s "$SVNerrors" ]; then + if [ "$svnterm" -ne 0 ]; then die "SVN reported the following problem:\n" \ "$(cat "$SVNerrors")" elif egrep '^(C...|.C..|...C) .+' "$SVNchanges"; then diff --git a/build/misc.sh b/build/misc.sh index b36d5f9ded..39f08a484a 100755 --- a/build/misc.sh +++ b/build/misc.sh @@ -26,5 +26,6 @@ print_error(){ die(){ echo "$(date '+%F %T'): Fatal - $@" |logappend lasterror >&2 + date +%s |logstatus end_time exit 1 } diff --git a/build/status.html.sh b/build/status.html.sh index 5dc0f5b609..1d326a98c1 100755 --- a/build/status.html.sh +++ b/build/status.html.sh @@ -23,7 +23,7 @@ htmlcat(){ s;'\'';\&apos\;;g;' $@ } -start_time=$(stat -c %Y "SVNchanges" ||echo 0) +start_time=$(cat "start_time" || stat -c %Y "$0" || echo 0) t_svnupdate=$(stat -c %Y "SVNlatest" ||echo 0) t_premake=$(stat -c %Y "premake" ||echo 0) t_makefile=$(stat -c %Y "Makefile" ||echo 0) @@ -37,9 +37,13 @@ t_makerun=$(stat -c %Y "buildlog" ||echo 0) t_errors=$(stat -c %Y "lasterror" ||echo 0) t_removed=$(stat -c %Y "removed" ||echo 0) t_stagesync=$(stat -c %Y "stagesync" ||echo 0) -end_time=$(stat -c %Y stagesync removed lasterror buildlog |sort -n |tail -n1) +end_time=$(cat "end_time" || echo 0) duration=$(($end_time - $start_time)) -term_status=$([ "$duration" -gt 0 -a lasterror -nt buildlog ] && echo Error || [ "$duration" -gt 0 ] && echo Success) +term_status=$(if [ "$duration" -gt 0 -a lasterror -nt start_time ]; then + echo Error + elif [ "$duration" -gt 0 ]; then + echo Success + fi) printf %s\\n\\n "Content-Type: text/html;charset=utf-8" cat <File Manifest$(web_tab Manifesttab "Number of files: $(wc -l manifest |cut -d\ -f1), view" "") -

Makerun

$( if [ $start_time -lt $t_makerun ]; then web_tab Makeruntab "Build time: $(duration $(($t_makerun - $t_makefile)) )" "
$(tail buildlog |htmlcat)
" @@ -183,9 +186,13 @@ label { web_tab Errortab "none" "" fi) +

File Manifest

$(web_tab Manifesttab "Number of files: $(wc -l manifest |cut -d\ -f1)" "
$(tail manifest |htmlcat)
view full") +

Files removed

$( - if [ $start_time -lt $t_removed ]; then + if [ $start_time -lt $t_removed -a -s "removed" ]; then web_tab Removedtab "$(wc -l removed |cut -f1 -d\ )" "
$(htmlcat removed)
" + elif [ $start_time -lt $t_removed ]; then + web_tab Removedtab "none" "" elif [ -z ${term_status} ]; then web_tab Removedtab "waiting..." "" else