Skip to content

Commit bac9f5a

Browse files
kevinastonefuji246
authored andcommitted
Moved git-hash determination to passed in build variable (RPi-Distro#273)
1 parent deaeb27 commit bac9f5a

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

build-docker.sh

+5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ if [ -z "${IMG_NAME}" ]; then
5252
exit 1
5353
fi
5454

55+
# Ensure the Git Hash is recorded before entering the docker container
56+
GIT_HASH=${GIT_HASH:-"$(git rev-parse HEAD)"}
57+
5558
CONTAINER_EXISTS=$(${DOCKER} ps -a --filter name="${CONTAINER_NAME}" -q)
5659
CONTAINER_RUNNING=$(${DOCKER} ps --filter name="${CONTAINER_NAME}" -q)
5760
if [ "${CONTAINER_RUNNING}" != "" ]; then
@@ -73,6 +76,7 @@ if [ "${CONTAINER_EXISTS}" != "" ]; then
7376
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM
7477
time ${DOCKER} run --rm --privileged \
7578
--volume "${CONFIG_FILE}":/config:ro \
79+
-e "GIT_HASH=${GIT_HASH}" \
7680
--volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \
7781
pi-gen \
7882
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
@@ -83,6 +87,7 @@ else
8387
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}' SIGINT SIGTERM
8488
time ${DOCKER} run --name "${CONTAINER_NAME}" --privileged \
8589
--volume "${CONFIG_FILE}":/config:ro \
90+
-e "GIT_HASH=${GIT_HASH}" \
8691
pi-gen \
8792
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
8893
cd /pi-gen; ./build.sh ${BUILD_OPTS} &&

build.sh

+2
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ export WPA_PASSWORD
168168
export WPA_COUNTRY
169169
export ENABLE_SSH="${ENABLE_SSH:-0}"
170170

171+
export GIT_HASH=${GIT_HASH:-"$(git rev-parse HEAD)"}
172+
171173
export BASE_DIR
172174

173175
export CLEAN

scripts/common

-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ on_chroot() {
9494
export -f on_chroot
9595

9696
update_issue() {
97-
local GIT_HASH
98-
GIT_HASH=$(git rev-parse HEAD)
9997
echo -e "Raspberry Pi reference ${IMG_DATE}\nGenerated using ${PI_GEN}, ${PI_GEN_REPO}, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue"
10098
}
10199
export -f update_issue
102-

0 commit comments

Comments
 (0)