From 26c4241341748a695aa61e611c3933e047da8f8e Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 17 Oct 2012 18:04:26 -0400 Subject: [PATCH] build_image: only dump debug info when failing If the image happens to be full but didn't run out of space, then don't dump the filesystem debug output. Only do it when we're erroring out. BUG=chromium-os:35083 TEST=`./build_image --board=x86-alex` still worked Change-Id: Ia585b43273cc891aaaebe0fe08aedec78c91055e Reviewed-on: https://gerrit.chromium.org/gerrit/35885 Reviewed-by: David James Reviewed-by: Peter Mayo Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger --- build_library/base_image_util.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/build_library/base_image_util.sh b/build_library/base_image_util.sh index aa0b4fedd7..7039c6af4f 100755 --- a/build_library/base_image_util.sh +++ b/build_library/base_image_util.sh @@ -5,18 +5,22 @@ . "${SRC_ROOT}/platform/dev/toolchain_utils.sh" || exit 1 cleanup_mounts() { + local prev_ret=$? + # Disable die on error. set +e - # See if we ran out of space. - local df=$(df -B 1M "${root_fs_dir}") - if [[ ${df} == *100%* ]]; then - error "Here are the biggest files (by disk usage):" - # Send final output to stderr to match `error` behavior. - sudo find "${root_fs_dir}" -xdev -type f -printf '%b %P\n' | \ - awk '$1 > 16 { $1 = $1 * 512; print }' | sort -n | tail -100 1>&2 - error "Target image has run out of space:" - error "${df}" + # See if we ran out of space. Only show if we errored out via a trap. + if [[ ${prev_ret} -ne 0 ]]; then + local df=$(df -B 1M "${root_fs_dir}") + if [[ ${df} == *100%* ]]; then + error "Here are the biggest files (by disk usage):" + # Send final output to stderr to match `error` behavior. + sudo find "${root_fs_dir}" -xdev -type f -printf '%b %P\n' | \ + awk '$1 > 16 { $1 = $1 * 512; print }' | sort -n | tail -100 1>&2 + error "Target image has run out of space:" + error "${df}" + fi fi echo "Cleaning up mounts"