From 97b26d13edec9d7e08ebedd8a3e9297bf5ed598d Mon Sep 17 00:00:00 2001 From: Scott Little Date: Mon, 20 Aug 2018 11:00:58 -0400 Subject: [PATCH] Make sure we are in the correct group to run build-guest. Problem: build-guest fails for hard to determine reason. Root cause, user was not running the command under the correct group. They need to be in the mock group to run mock successfully. Solution: Verify that the command is being run under the correct group id. Note: 'cgts' is our current alias for the 'mock' group. Should probably be renamed as stx-build in a future update. Story: 2002835 Task: 24519 Change-Id: I658800cbae001f5cb0fc81bff1ed1ab159f6f6a3 Signed-off-by: Scott Little --- build-tools/build-guest | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build-tools/build-guest b/build-tools/build-guest index 2d507e85..8eac1c7a 100755 --- a/build-tools/build-guest +++ b/build-tools/build-guest @@ -13,6 +13,21 @@ BUILD_GUEST_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )" source "${BUILD_GUEST_DIR}/image-utils.sh" +# Remind folks then need to be in the correct group to run mock commands +# Note: cgts is our current alias for the mock group. Should probably be +# renamed as stx-build in a future update +NEED_GROUP=cgts +CURRENT_GID=$(id -g) +NEED_GID=$(getent group $NEED_GROUP | cut -d: -f3) +if [ $CURRENT_GID != $NEED_GID ]; then + echo "This command must be run using group '$NEED_GROUP'." + echo "Please run:" + echo " newgrp $NEED_GROUP" + echo "" + echo "Then try again." + exit 1 +fi + # NOTE: TMP_DIR must end in '/' # NOTE: /tmp/ is now tmpfs like. Can't be trusted across multiple mock commands # TMP_DIR=/tmp/