From f3ba3ca0f1b93482047f6d56d33314cbb4fcdf15 Mon Sep 17 00:00:00 2001 From: Scott Little Date: Fri, 14 Jan 2022 11:32:43 -0500 Subject: [PATCH] build-avoidance: ensure we can write to a copied build environment. A centos build using build avoidance will fail if the upstream reference build is read only. The read only is replicated in the user's build environment, and any packages that need to be updates (since the reference build) will fail with reason 'permission denied' A read only reference build is rare, but can occur to preserve important reference builds, such as a release build or the last build prior tothe introduction of a major feature. Solution is to add a chmod to ensure writability of copied content. Closes-Bug: 1958156 Change-Id: Id7c4d9b90fe4b44cc8b1b351767a5dd74dc30e9a Signed-off-by: Scott Little --- build-tools/build-avoidance-utils.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/build-tools/build-avoidance-utils.sh b/build-tools/build-avoidance-utils.sh index 5c09c3a7..5ac5858d 100644 --- a/build-tools/build-avoidance-utils.sh +++ b/build-tools/build-avoidance-utils.sh @@ -576,12 +576,24 @@ build_avoidance_copy_dir_rsync () { >&2 echo "Error: $FUNCNAME (${LINENO}): BUILD_AVOIDANCE_URL no set" return 1 fi + if [ "$VERBOSE" != "" ]; then FLAGS="$FLAGS -v" echo "rsync $FLAGS '$BUILD_AVOIDANCE_URL/$FROM/' '$TO/'" fi + rsync $FLAGS "$BUILD_AVOIDANCE_URL/$FROM/" "$TO/" - return $? + if [ $? -ne 0 ]; then + >&2 echo "Error: $FUNCNAME (${LINENO}): command failed: rsync $FLAGS '$BUILD_AVOIDANCE_URL/$FROM/' '$TO/'" + return 1 + fi + + chmod -R 'ug+w' "$TO/" + if [ $? -ne 0 ]; then + >&2 echo "Error: $FUNCNAME (${LINENO}): command failed: chmod -R 'ug+w' '$TO/'" + return 1 + fi + return 0 } # @@ -604,7 +616,18 @@ build_avoidance_copy_file_rsync () { FLAGS="$FLAGS -v" echo "rsync $FLAGS '$BUILD_AVOIDANCE_URL/$FROM' '$TO'" fi + rsync $FLAGS "$BUILD_AVOIDANCE_URL/$FROM" "$TO" + if [ $? -ne 0 ]; then + >&2 echo "Error: $FUNCNAME (${LINENO}): command failed: rsync $FLAGS '$BUILD_AVOIDANCE_URL/$FROM' '$TO'" + return 1 + fi + + chmod -R 'ug+w' "$TO" + if [ $? -ne 0 ]; then + >&2 echo "Error: $FUNCNAME (${LINENO}): command failed: chmod -R 'ug+w' '$TO'" + return 1 + fi return $? }