Add a timeout when copying build directory
Sometimes, the command copying the contents of the build directory to
the xtrct directory hangs for hours. This can hold up our CI queue. This
change adds a timeout to the copy command, defaulted to 5 minutes.
Change-Id: I0b87a46f32f9f83dab06e779942274d9e4b888fc
Signed-off-by: Charles Paul Hofer <Charles.Hofer@ibm.com>
diff --git a/build-setup.sh b/build-setup.sh
index c9a61dd..7b184a7 100755
--- a/build-setup.sh
+++ b/build-setup.sh
@@ -54,6 +54,9 @@
# xtrct_path Path where the build_dir contents will be copied out to
# when the build completes.
# Default: "${obmc_dir}/build/tmp"
+# xtrct_copy_timeout Timeout (in seconds) for copying the contents of
+# build_dir to xtrct_path.
+# Default: "300"
#
###############################################################################
# Trace bash processing. Set -e so when a step fails, we fail the build
@@ -76,6 +79,7 @@
obmc_dir=${obmc_dir:-${WORKSPACE}/openbmc}
ssc_dir=${ssc_dir:-${HOME}}
xtrct_path=${xtrct_path:-${obmc_dir}/build/tmp}
+xtrct_copy_timeout=${xtrct_copy_timeout:-300}
PROXY=""
@@ -305,7 +309,14 @@
bitbake ${BITBAKE_OPTS} obmc-phosphor-image
# Copy internal build directory into xtrct_path directory
-cp -r ${build_dir}/* ${xtrct_path}
+timeout ${xtrct_copy_timeout} cp -r ${build_dir}/* ${xtrct_path}
+
+
+if [[ 0 -ne $? ]]; then
+ echo "Received a non-zero exit code from timeout"
+ exit 1
+fi
+
EOF_SCRIPT
chmod a+x ${WORKSPACE}/build.sh