Turn of tracing around du invocations

We don't want the output of "du" run on the image spammed into the
logs with "set -x".  Swizzle it off around the sensitive commands.

Change-Id: I687e77275f9a49e7934211835aba8610e88cdca6
This commit is contained in:
Ian Wienand 2016-04-07 08:11:39 +10:00
parent 69c811870c
commit 2f214ff3e8

View File

@ -323,21 +323,24 @@ fi
unmount_image unmount_image
mv $TMP_BUILD_DIR/mnt $TMP_BUILD_DIR/built mv $TMP_BUILD_DIR/mnt $TMP_BUILD_DIR/built
# save xtrace state, as we want to turn it off to avoid spamming the
# logs with du output below.
xtrace=$(set +o | grep xtrace)
if [ -n "$DIB_IMAGE_SIZE" ]; then if [ -n "$DIB_IMAGE_SIZE" ]; then
du_size=$(echo "$DIB_IMAGE_SIZE" | awk '{printf("%d\n",$1 * 1024 *1024)}') du_size=$(echo "$DIB_IMAGE_SIZE" | awk '{printf("%d\n",$1 * 1024 *1024)}')
else else
set +o xtrace
du_output=$(sudo du -a -c -x ${TMP_BUILD_DIR}/built) du_output=$(sudo du -a -c -x ${TMP_BUILD_DIR}/built)
# the last line is the total size from "-c". # the last line is the total size from "-c".
# scale this by 0.6 to create a slightly bigger image # scale this by 0.6 to create a slightly bigger image
du_size=$(echo "$du_output" | tail -n1 | cut -f1 | \ du_size=$(echo "$du_output" | tail -n1 | cut -f1 | \
awk '{print int($1 / 0.6)}') awk '{print int($1 / 0.6)}')
$xtrace
fi fi
if [[ "${DIB_SHOW_IMAGE_USAGE:-0}" != 0 ]]; then if [[ "${DIB_SHOW_IMAGE_USAGE:-0}" != 0 ]]; then
xtrace=$(set +o | grep xtrace)
set +o xtrace set +o xtrace
if [ -z "$du_output" ]; then if [ -z "$du_output" ]; then
du_output=$(sudo du -a -c -x ${TMP_BUILD_DIR}/built) du_output=$(sudo du -a -c -x ${TMP_BUILD_DIR}/built)
fi fi