diff --git a/build-scripts/functions b/build-scripts/functions index 769b8f55c..325b1c9b0 100644 --- a/build-scripts/functions +++ b/build-scripts/functions @@ -796,4 +796,22 @@ log_error() { echo "$(basename "$0"): error:" "$@" >&2 } +# Pin embedded build timestamps so two builds of the same source produce identical binaries. +# In bootstrap-pr we derive it from core's HEAD commit time and persist it into +# output/ so downstream jobs (which consume the bootstrap artifacts but no +# longer have core/.git) can recover the same value. +if [ -z "$SOURCE_DATE_EPOCH" ]; then + if [ -d "$BASEDIR/core/.git" ]; then + SOURCE_DATE_EPOCH=$(git -C "$BASEDIR/core" log -1 --format=%ct) + mkdir -p "$BASEDIR/output" + echo "$SOURCE_DATE_EPOCH" > "$BASEDIR/output/SOURCE_DATE_EPOCH" + elif [ -f "$BASEDIR/output/SOURCE_DATE_EPOCH" ]; then + SOURCE_DATE_EPOCH=$(cat "$BASEDIR/output/SOURCE_DATE_EPOCH") + fi + if [ -n "$SOURCE_DATE_EPOCH" ]; then + export SOURCE_DATE_EPOCH + log_info "SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH" + fi +fi + _IS_FUNCTIONS_SOURCED=yes