From 75cb1fc91007c8adccc057710c50694f1d4dc79d Mon Sep 17 00:00:00 2001 From: Kevin Stone Date: Sun, 11 Aug 2019 10:44:00 -0500 Subject: [PATCH] Moved git-hash determination to passed in build variable (#273) --- build-docker.sh | 5 +++++ build.sh | 2 ++ scripts/common | 3 --- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index 6844b1a864..435aa0a620 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -65,6 +65,9 @@ if [ -z "${IMG_NAME}" ]; then exit 1 fi +# Ensure the Git Hash is recorded before entering the docker container +GIT_HASH=${GIT_HASH:-"$(git rev-parse HEAD)"} + CONTAINER_EXISTS=$(${DOCKER} ps -a --filter name="${CONTAINER_NAME}" -q) CONTAINER_RUNNING=$(${DOCKER} ps --filter name="${CONTAINER_NAME}" -q) if [ "${CONTAINER_RUNNING}" != "" ]; then @@ -86,6 +89,7 @@ if [ "${CONTAINER_EXISTS}" != "" ]; then trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM time ${DOCKER} run --rm --privileged \ --volume "${CONFIG_FILE}":/config:ro \ + -e "GIT_HASH=${GIT_HASH}" \ --volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \ -e IMG_NAME="${IMG_NAME}"\ -e IMG_VERSION="${IMG_VERSION}"\ @@ -100,6 +104,7 @@ else -e IMG_NAME="${IMG_NAME}"\ -e IMG_VERSION="${IMG_VERSION}"\ --volume "${CONFIG_FILE}":/config:ro \ + -e "GIT_HASH=${GIT_HASH}" \ pi-gen \ bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && cd /pi-gen; ./build.sh ${BUILD_OPTS} && diff --git a/build.sh b/build.sh index b945d5d8e8..a13813e69a 100755 --- a/build.sh +++ b/build.sh @@ -171,6 +171,8 @@ export WPA_PASSWORD export WPA_COUNTRY export ENABLE_SSH="${ENABLE_SSH:-0}" +export GIT_HASH=${GIT_HASH:-"$(git rev-parse HEAD)"} + export BASE_DIR export CLEAN diff --git a/scripts/common b/scripts/common index d17f83b0e0..84cdc553fc 100644 --- a/scripts/common +++ b/scripts/common @@ -94,9 +94,6 @@ on_chroot() { export -f on_chroot update_issue() { - local GIT_HASH - GIT_HASH=$(git rev-parse HEAD) echo -e "${IMG_NAME} ${IMG_VERSION} built on ${IMG_DATE}\nGenerated using ${PI_GEN}, ${PI_GEN_REPO}, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue" } export -f update_issue -