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 <scott.little@windriver.com>
This commit is contained in:
Scott Little 2018-08-20 11:00:58 -04:00
parent b7e024664d
commit 97b26d13ed

View File

@ -13,6 +13,21 @@
BUILD_GUEST_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )" BUILD_GUEST_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )"
source "${BUILD_GUEST_DIR}/image-utils.sh" 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_DIR must end in '/'
# NOTE: /tmp/ is now tmpfs like. Can't be trusted across multiple mock commands # NOTE: /tmp/ is now tmpfs like. Can't be trusted across multiple mock commands
# TMP_DIR=/tmp/ # TMP_DIR=/tmp/