Skip to content

Commit

Permalink
Moved git-hash determination to passed in build variable (RPi-Distro#273
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kevinastone authored and XECDesign committed Aug 11, 2019
1 parent 920e22b commit 18b945f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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
Expand All @@ -73,6 +76,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" \
pi-gen \
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
Expand All @@ -83,6 +87,7 @@ else
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}' SIGINT SIGTERM
time ${DOCKER} run --name "${CONTAINER_NAME}" --privileged \
--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} &&
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,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
Expand Down
3 changes: 0 additions & 3 deletions scripts/common
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ on_chroot() {
export -f on_chroot

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

0 comments on commit 18b945f

Please sign in to comment.