Add option to direct build log to both stdout and the log file for the build target

Includes various minor cleanups.

r62835
suites/ascii
Frans Pop 15 years ago
parent 968aece4f4
commit 2b91e72a21
  1. 44
      build/daily-build

@ -1,6 +1,11 @@
#!/bin/sh #!/bin/bash
set -e set -e
# Ensure all output is in English and consistent.
# Also needed because the output of some commands is tested.
export LANG=C
unset LC_ALL LANGUAGE
# Overridable environment variables for uploading. # Overridable environment variables for uploading.
# Setting RESTRICTED_SSH makes the upload be done by sending a # Setting RESTRICTED_SSH makes the upload be done by sending a
@ -26,7 +31,7 @@ fi
if [ -z "$DIR" ]; then if [ -z "$DIR" ]; then
DIR=$(date -u '+%Y%m%d-%H:%M') DIR=$(date -u '+%Y%m%d-%H:%M')
fi fi
if [ "$HOST" = "local" ]; then if [ "$HOST" = local ]; then
SYNC="rsync" SYNC="rsync"
SYNC_BASEDIR="$BASEDIR" SYNC_BASEDIR="$BASEDIR"
else else
@ -55,8 +60,10 @@ if [ "$ROOTCMD" = fakeroot ]; then
ROOTCMDOPTS="-i $FRSAVE -s $FRSAVE" ROOTCMDOPTS="-i $FRSAVE -s $FRSAVE"
fi fi
LOG_TO_STDOUT=${LOG_TO_STDOUT:-0}
overview () { overview () {
LANG=C echo "$(dpkg --print-architecture) ($(date)) $(whoami)@$(hostname | cut -d . -f 1) $1" >> dest/overview.log echo "$(dpkg --print-architecture) ($(date)) $(whoami)@$(hostname | cut -d . -f 1) $1" >> dest/overview.log
} }
header () { header () {
@ -65,9 +72,29 @@ header () {
echo echo
} }
build () { do_build () {
unset LANG LC_ALL LANGUAGE || true local t=$1
local err=0
# Commands in these two branches should be the same.
if [ "$LOG_TO_STDOUT" = 1 ]; then
set -o pipefail
(
header BUILDING IMAGE FOR $t
$ROOTCMD $ROOTCMDOPTS make $t 2>&1
) | tee -a dest/$t.log || err=$?
set +o pipefail
else
(
header BUILDING IMAGE FOR $t
$ROOTCMD $ROOTCMDOPTS make $t 2>&1
) >> dest/$t.log || err=$?
fi
return $err
}
build () {
# Override $TARGETS with custom makefile targets. # Override $TARGETS with custom makefile targets.
if [ -z "$TARGETS" ]; then if [ -z "$TARGETS" ]; then
TARGETS="$($ROOTCMD make all_list | grep '^build')" TARGETS="$($ROOTCMD make all_list | grep '^build')"
@ -79,8 +106,7 @@ build () {
# Save file attributes within this loop if fakeroot is used # Save file attributes within this loop if fakeroot is used
for t in $TARGETS; do for t in $TARGETS; do
header BUILDING IMAGE FOR $t > dest/$t.log if do_build $t; then
if $ROOTCMD $ROOTCMDOPTS make $t >> dest/$t.log 2>&1; then
overview "$t success" overview "$t success"
else else
overview "$t failed" overview "$t failed"
@ -137,8 +163,8 @@ update () {
} }
deps () { deps () {
temp=`LANG=C dpkg-checkbuilddeps -B ../debian/control 2>&1 || true` temp=$(dpkg-checkbuilddeps -B ../debian/control 2>&1 || true)
packages=`echo $temp | sed -e 's%dpkg-checkbuilddeps: Unmet build dependencies: %%'` packages=$(echo $temp | sed -e 's%dpkg-checkbuilddeps: Unmet build dependencies: %%')
apt-get update apt-get update
if [ "$packages" ]; then if [ "$packages" ]; then
DEBIAN_PRIORITY=critical apt-get -y install $packages DEBIAN_PRIORITY=critical apt-get -y install $packages

Loading…
Cancel
Save