From 107615f1fe96007f0e7c5d123aa62dfaa4025863 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 8 Jan 2012 03:30:51 -0500 Subject: [PATCH] Some more improvements and fixes. --- collects/meta/build/build | 26 +++++++++++--------- collects/meta/build/current-build-status.cgi | 19 +++++++++----- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/collects/meta/build/build b/collects/meta/build/build index a7872086ca..4b3dd0c05a 100755 --- a/collects/meta/build/build +++ b/collects/meta/build/build @@ -372,7 +372,7 @@ if [[ "$XAUTHORITY" = "" ]]; then export XAUTHORITY="$HOME/.Xauthority"; fi no_exit_on_error="no" exit_error() { echo "" - echo "<<>> (Working on ${machine}(${platform}))" 1>&2 + echo "<<>> (Working on $machine($platform))" 1>&2 echo "$@" 1>&2 if [[ "$no_exit_on_error" = "yes" ]]; then echo "" @@ -730,7 +730,7 @@ write_status() { header() { local suffix="" if [[ "${machine:-$workmachine}" != "$workmachine" ]]; then - suffix=" [${machine}(${platform})]" + suffix=" [$machine($platform)]" fi local status="" case "x$1" in @@ -760,7 +760,7 @@ build_step() { # inputs: name, command show "Running \"$*\"" start_timer "$@" || exit_error "\"$jobname\" part of build process failed" - show_time "--==> $jobname on ${machine}(${platform}) done," + show_time "--==> $jobname on $machine($platform) done," } cur_secs() { @@ -923,7 +923,7 @@ html_begin() { # inputs: title [output-name] local htmltitle="$1"; shift htmloutput="$index" if [[ "$1" != "" ]]; then htmloutput="$1"; shift; fi - if [[ "$htmloutput" != /* ]]; then htmloutput="$(pwd)/htmloutput"; fi + if [[ "$htmloutput" != /* ]]; then htmloutput="$(pwd)/$htmloutput"; fi show "Creating \"$htmloutput\" for \"$htmltitle\"" # the *.title. file marks this for later patching through the web templates, # so it should be created even if it won't get used later. @@ -1163,7 +1163,7 @@ DO_COPY_BUILD() { # inputs -- machine-name (for ssh) run_part -bg "$machine" "DO_BUILD" "$releasing" "$@" \ &> "$bglogfile-$machine" else - header "{{{ Doing ${machine}(${platform}) locally }}}" + header "{{{ Doing $machine($platform) locally }}}" run_part "$machine" "DO_BUILD" "$releasing" "$@" fi @@ -1419,7 +1419,7 @@ win_build_step() { # inputs: type, name, [args...] ;; ( * ) exit_error "Unknown type for win_build_step: \"$btype\"" ;; esac - show_time "--==> $bname on ${machine}(${platform}) done," + show_time "--==> $bname on $machine($platform) done," } DO_WINDOWS_BUILD() { @@ -2182,6 +2182,8 @@ BUILD_PRE_WEB() { # Make the status script available for use if [[ "$prewebdir" = "$prewebdir_default" ]]; then + _cd "$maindir/$prewebdir" + local target="$maindir/$prewebdir/$(basename "$statusscript")" { echo "#!/bin/bash" local v @@ -2190,8 +2192,8 @@ BUILD_PRE_WEB() { done echo "" cat "$PLTHOME/$statusscript" - } > "${prewebdir}/$(basename "$statusscript")" - chmod +x "${prewebdir}/$(basename "$statusscript")" + } > "$target" + chmod +x "$target" fi } @@ -2206,12 +2208,12 @@ if [[ "$1" = "--dispatch" ]]; then machine="$1"; go="$2"; shift 2 init_repo_vars # set the repository variables according to the env vars machineget platform # set the global platform for dependable script pieces - show "Working on $machine($hostname)" + show "Working on $machine($platform)" show "Dispatching to $go($*)" "$go" "$@" - show "Done working on $machine($hostname)" + show "Done working on $machine($platform)" elif [[ "$scriptlog" = "yes" ]]; then - show "Working on $machine($hostname)" + show "Working on $machine($platform)" rm -f "$maindir/$scriptlogfile" { echo "This is the build log, generated by $buildscript"; echo "" echo "Search for \"BOOM\" for any errors."; echo "" @@ -2225,7 +2227,7 @@ elif [[ "$scriptlog" = "yes" ]]; then MAIN "$@" 2>&1 | tee -a "$maindir/$scriptlogfile" fi else - show "Working on $machine($hostname)" + show "Working on $machine($platform)" MAIN "$@" fi diff --git a/collects/meta/build/current-build-status.cgi b/collects/meta/build/current-build-status.cgi index b1f0537d8a..c11adcc9de 100644 --- a/collects/meta/build/current-build-status.cgi +++ b/collects/meta/build/current-build-status.cgi @@ -7,7 +7,8 @@ printf 'Content-type: text/plain\r\n\r\n' # cache status reports (avoids excessive work during builds) # use a lockfile as a cheap hack to time cache refreshing -if ! lockfile -r 0 -l 5 -s 0 "$cachelock" && [[ -e "$cache" ]]; then +if ! lockfile -r 0 -l 5 -s 0 "$cachelock" >& /dev/null \ + && [[ -e "$cache" ]]; then cat "$cache"; exit fi @@ -21,21 +22,27 @@ if [[ -e "$statusfile_last" ]]; then S1="Y"; else S1="N"; fi if [[ "$L$S" = "NY" ]]; then printf 'Last build crashed abnormally.\n' elif [[ "$S" = "Y" ]]; then - printf 'Running: '; cat "$statusfile" time_for_file() { local t="$(($(date +"%s") - $(stat -c "%Z" "$1")))" printf "%d:%02d:%02d" "$((t/3600))" "$(((t%3600)/60))" "$((t%60))" } - printf "The build has been running for %s, current step for %s\n" \ - "$(time_for_file "$lockfile")" "$(time_for_file "$statusfile")" + printf 'A build is running (%s)\n' "$(time_for_file "$lockfile")" + printf 'Status: %s (%s)\n' "$(cat "$statusfile")" \ + "$(time_for_file "$statusfile")" shopt -s nullglob if [[ "x$(echo "$bglogfile"*)" != "x" ]]; then printf '\n%s build jobs running:\n' "$(ls "$bglogfile"* | wc -l)" for bg in "$bglogfile"*; do - printf ' %s: ' "${bg#$bglogfile-}" s="$(grep "^### <<< .* >>>" "$bg" | tail -1 \ | sed -e 's/^### <<< \(.*\) >>>/\1/')" - if [[ "x$s" = "x" ]]; then echo "(just starting)"; else echo "$s"; fi + if [[ "x$s" = "x" ]]; then + printf ' %s: (just starting)\n' "${bg#$bglogfile-}" + else + s="${bg#$bglogfile-}: $s" + s="$(echo "$s" \ + | sed -e 's/^\(.*\): \(.*\) \[\1(\(.*\))\]$/\3(\1): \2/')" + echo " $s" + fi done fi else