Add build info to post-build.sh

This commit is contained in:
2026-04-09 18:15:58 -03:00
parent 6d90c7ebca
commit a7f0cbea9c

View File

@@ -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