Revert "Reland "build_common: use cp instead of pv_cat_cmd in copy_image"" This reverts commit 217ccecb0825d6b028d58ce7e2a09866b2bf175d. Reason for revert: Preserving sparse holes causes GNU tar to emit chromiumos_test_image.bin as OldGNU type 'S' (tar.TypeGNUSparse) instead of '0' (tar.TypeReg). ChromeOS CachingService downloader's /extract/ endpoint only matches tar.TypeReg, returning HTTP 404 and breaking FAFT/AutoQual USB-boot tests. Revert until the downloader fix is deployed. BUG=b:590225883 TEST=None Change-Id: Id50e4231e1613edf5a2756664f029d79f8045b9e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosutils/+/8887359 Reviewed-by: Mike Frysinger <vapier@chromium.org> Tested-by: Satoru Takabayashi <satorux@google.com> Commit-Queue: Satoru Takabayashi <satorux@google.com>
diff --git a/build_library/build_common.sh b/build_library/build_common.sh index 578f922..7a7fd5e 100644 --- a/build_library/build_common.sh +++ b/build_library/build_common.sh
@@ -34,6 +34,23 @@ return 1 } +# Returns the pv command if it's available, otherwise plain-old cat. Note that +# this function echoes the command, rather than running it, so it can be used +# as an argument to other commands (like sudo). +pv_cat_cmd() { + if type -P pv >&/dev/null; then + # Limit pv's output to 80 columns, for readability. + local term_cols=$(stty size 2>/dev/null | cut -d' ' -f2) + if [[ ${term_cols:-0} -gt 80 ]]; then + echo pv -w 80 -B 4m + else + echo pv -B 4m + fi + else + echo cat + fi +} + # Utility function for creating a copy of an image prior to # modification from the BUILD_DIR: # $1: source filename @@ -41,9 +58,9 @@ copy_image() { local src="${BUILD_DIR}/$1" local dst="${BUILD_DIR}/$2" - if should_build_image "$1"; then - echo "Creating $2 from $1... This might take a minute to complete." - cp "${src}" "${dst}" || die "Cannot copy $1 to $2" + if should_build_image $1; then + echo "Creating $2 from $1..." + $(pv_cat_cmd) "${src}" >"${dst}" || die "Cannot copy $1 to $2" else mv "${src}" "${dst}" || die "Cannot move $1 to $2" fi