Skip to content

Commit

Permalink
Fetch particular git hash remotely in pi-gen releases
Browse files Browse the repository at this point in the history
  • Loading branch information
mahsank committed Sep 29, 2020
1 parent d6207a6 commit 7bd72ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion build-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ do
esac
done

PI_GEN_REPO=${PI_GEN_REPO:-https://github.com/RPi-Distro/pi-gen}

# Ensure that the configuration file is an absolute path
if test -x /usr/bin/realpath; then
CONFIG_FILE=$(realpath -s "$CONFIG_FILE" || realpath "$CONFIG_FILE")
Expand All @@ -55,7 +57,11 @@ exit 1
fi

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

CONTAINER_EXISTS=$(${DOCKER} ps -a --filter name="${CONTAINER_NAME}" -q)
CONTAINER_RUNNING=$(${DOCKER} ps --filter name="${CONTAINER_NAME}" -q)
Expand Down
8 changes: 7 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,13 @@ export KEYBOARD_LAYOUT="${KEYBOARD_LAYOUT:-English (UK)}"

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

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

export CLEAN
export IMG_NAME
Expand Down

0 comments on commit 7bd72ef

Please sign in to comment.