From 3495c9a5b41336637dbe3d606236d990fd142ac2 Mon Sep 17 00:00:00 2001 From: Job Evers-Meltzer Date: Fri, 15 Jul 2016 19:13:53 -0500 Subject: [PATCH] output log file when lbrycrd build fails --- reproducible_build.sh | 47 ++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/reproducible_build.sh b/reproducible_build.sh index 3faa177d7..d333875ac 100755 --- a/reproducible_build.sh +++ b/reproducible_build.sh @@ -30,6 +30,7 @@ CLEAN=false BUILD_DEPENDENCIES=true BUILD_LBRYCRD=true TIMEOUT=false +THREE_MB=3145728 while getopts :crldoth:w:d: FLAG; do case $FLAG in @@ -151,14 +152,19 @@ function wait_and_echo() { # and wait until it completed function background() { $1 >> "$2" 2>&1 & - wait_and_echo $! "$3" + BACKGROUND_PID=$! + wait_and_echo $BACKGROUND_PID "$3" } function cleanup() { rv=$? # cat the log file if it exists if [ -f "$2" ]; then - cat "$2" + echo + echo "Output of log file $2" + echo + tail -c $THREE_MB "$1" + echo fi # delete the build directory rm -rf "$1" @@ -166,6 +172,22 @@ function cleanup() { exit $rv } +function cat_and_exit() { + rv=$? + # cat the log file if it exists + if [ -f "$1" ]; then + echo + echo "Output of log file $1" + echo + # log size is limited to 4MB on travis + # so hopefully the last 3MB is enough + # to debug whatever went wrong + tail -c $THREE_MB "$1" + echo + fi + exit $rv +} + function brew_if_not_installed() { if ! brew ls | grep $1 --quiet; then brew install $1 @@ -298,20 +320,19 @@ function build_lbrycrd() { else cd "${SOURCE_DIR}" fi - ./autogen.sh + ./autogen.sh > "${LBRYCRD_LOG}" 2>&1 LDFLAGS="-L${OPENSSL_PREFIX}/lib/ -L${BDB_PREFIX}/lib/ -L${LIBEVENT_PREFIX}/lib/ -static-libstdc++" CPPFLAGS="-I${OPENSSL_PREFIX}/include -I${BDB_PREFIX}/include -I${LIBEVENT_PREFIX}/include/" if [ "${OS_NAME}" = "osx" ]; then - ./configure --without-gui --enable-cxx --enable-static --disable-shared --with-pic \ - --with-boost="${BOOST_PREFIX}" \ - LDFLAGS="${LDFLAGS}" \ - CPPFLAGS="${CPPFLAGS}" + OPTIONS="--enable-cxx --enable-static --disable-shared --with-pic" else - ./configure --without-gui --with-boost="${BOOST_PREFIX}" \ - LDFLAGS="${LDFLAGS}" \ - CPPFLAGS="${CPPFLAGS}" + OPTIONS="" fi - make + ./configure --without-gui ${OPTIONS} \ + --with-boost="${BOOST_PREFIX}" \ + LDFLAGS="${LDFLAGS}" \ + CPPFLAGS="${CPPFLAGS}" >> "${LBRYCRD_LOG}" 2>&1 + background make "${LBRYCRD_LOG}" "Waiting for lbrycrd to finish building" # tests don't work on OSX. Should definitely figure out why # that is but, for now, not letting that stop the rest # of the build @@ -344,5 +365,7 @@ set -u if [ "${BUILD_LBRYCRD}" = true ]; then LBRYCRD_LOG="${LOG_DIR}/lbrycrd_build.log" echo "Building lbrycrd. tail -f ${LBRYCRD_LOG} to see the details and monitor progress" - background build_lbrycrd "${LBRYCRD_LOG}" "Waiting for lbrycrd to finish building" + trap 'cat_and_exit "${LBRYCRD_LOG}"' INT TERM EXIT + build_lbrycrd + trap - INT TERM EXIT fi