From a7f0cbea9c9b9de46bb5c4413f38b314fc427ba5 Mon Sep 17 00:00:00 2001 From: Gabriel Lima Date: Thu, 9 Apr 2026 18:15:58 -0300 Subject: [PATCH] Add build info to post-build.sh --- board/raspberrypi/post-build.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/board/raspberrypi/post-build.sh b/board/raspberrypi/post-build.sh index fdc260b..cefdafc 100755 --- a/board/raspberrypi/post-build.sh +++ b/board/raspberrypi/post-build.sh @@ -34,4 +34,36 @@ auto wlan0 iface wlan0 inet dhcp pre-up ip link set wlan0 up pre-up wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf +EOF + +# Generate /etc/build-info with details about this build +build_user="$(id -un)" +build_host="$(hostname)" +build_date="$(date '+%Y-%m-%d %H:%M:%S %z')" + +# Determine the git revision the same way the Linux kernel does: +# prefer a tag (git describe), fall back to the short hash, and append +# "-dirty" if tracked files are modified or there are untracked files. +build_rev="unknown" +if [ -n "$BR2_EXTERNAL_RPI_COMMON_PATH" ] && \ + git -C "$BR2_EXTERNAL_RPI_COMMON_PATH" rev-parse --is-inside-work-tree >/dev/null 2>&1; then + git_dir="$BR2_EXTERNAL_RPI_COMMON_PATH" + build_rev="$(git -C "$git_dir" describe --always --tags 2>/dev/null || \ + git -C "$git_dir" rev-parse --short HEAD 2>/dev/null || \ + echo unknown)" + # Refresh the index so diff-index doesn't report stale stat info + git -C "$git_dir" update-index --refresh >/dev/null 2>&1 || : + dirty="" + if ! git -C "$git_dir" diff-index --quiet HEAD -- 2>/dev/null; then + dirty="-dirty" + elif [ -n "$(git -C "$git_dir" ls-files --others --exclude-standard 2>/dev/null)" ]; then + dirty="-dirty" + fi + build_rev="${build_rev}${dirty}" +fi + +cat > "$TARGET_DIR/etc/build-info" << EOF +Built by: ${build_user}@${build_host} +Build date: ${build_date} +Revision: ${build_rev} EOF \ No newline at end of file