Skip to content

Commit 7bd72ef

Browse files
committed
Fetch particular git hash remotely in pi-gen releases
1 parent d6207a6 commit 7bd72ef

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

build-docker.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ do
3030
esac
3131
done
3232

33+
PI_GEN_REPO=${PI_GEN_REPO:-https://github.com/RPi-Distro/pi-gen}
34+
3335
# Ensure that the configuration file is an absolute path
3436
if test -x /usr/bin/realpath; then
3537
CONFIG_FILE=$(realpath -s "$CONFIG_FILE" || realpath "$CONFIG_FILE")
@@ -55,7 +57,11 @@ exit 1
5557
fi
5658

5759
# Ensure the Git Hash is recorded before entering the docker container
58-
GIT_HASH=${GIT_HASH:-"$(git rev-parse HEAD)"}
60+
if [ -d "${DIR}"/.git ]; then
61+
GIT_HASH=${GIT_HASH:-$(git rev-parse HEAD)}
62+
else
63+
GIT_HASH=$(git ls-remote --tags "${PI_GEN_REPO}" | grep $(basename "${DIR}" | cut -d'-' -f3-) | awk '{print $1}')
64+
fi
5965

6066
CONTAINER_EXISTS=$(${DOCKER} ps -a --filter name="${CONTAINER_NAME}" -q)
6167
CONTAINER_RUNNING=$(${DOCKER} ps --filter name="${CONTAINER_NAME}" -q)

build.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,13 @@ export KEYBOARD_LAYOUT="${KEYBOARD_LAYOUT:-English (UK)}"
179179

180180
export TIMEZONE_DEFAULT="${TIMEZONE_DEFAULT:-Europe/London}"
181181

182-
export GIT_HASH=${GIT_HASH:-"$(git rev-parse HEAD)"}
182+
if [ -z "${GIT_HASH}" ]; then
183+
if [ -d "${BASE_DIR}"/.git ]; then
184+
export GIT_HASH=${GIT_HASH:-$(git rev-parse HEAD)}
185+
else
186+
export GIT_HASH=$(git ls-remote --tags "${PI_GEN_REPO}" | grep $(basename "${BASE_DIR}" | cut -d'-' -f3-) | awk '{print $1}')
187+
fi
188+
fi
183189

184190
export CLEAN
185191
export IMG_NAME

0 commit comments

Comments
 (0)