Skip to content

Commit ebd4097

Browse files
committed
functions: Persist SOURCE_DATE_EPOCH for downstream jobs
Write the value into output/SOURCE_DATE_EPOCH on the bootstrap-pr build slave (where core/.git exists) so downstream jobs that consume the artifacts bundle - and no longer have core/.git - can read the same value back instead of leaving the variable unset. Ticket: ENT-14061 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 20d9a56 commit ebd4097

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

build-scripts/functions

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,10 +797,21 @@ log_error() {
797797
}
798798

799799
# Pin embedded build timestamps so two builds of the same source produce identical binaries.
800-
if [ -z "$SOURCE_DATE_EPOCH" ] && [ -d "$BASEDIR/core/.git" ]; then
801-
SOURCE_DATE_EPOCH=$(git -C "$BASEDIR/core" log -1 --format=%ct)
802-
export SOURCE_DATE_EPOCH
803-
log_info "SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH"
800+
# In bootstrap-pr we derive it from core's HEAD commit time and persist it into
801+
# output/ so downstream jobs (which consume the bootstrap artifacts but no
802+
# longer have core/.git) can recover the same value.
803+
if [ -z "$SOURCE_DATE_EPOCH" ]; then
804+
if [ -d "$BASEDIR/core/.git" ]; then
805+
SOURCE_DATE_EPOCH=$(git -C "$BASEDIR/core" log -1 --format=%ct)
806+
mkdir -p "$BASEDIR/output"
807+
echo "$SOURCE_DATE_EPOCH" > "$BASEDIR/output/SOURCE_DATE_EPOCH"
808+
elif [ -f "$BASEDIR/output/SOURCE_DATE_EPOCH" ]; then
809+
SOURCE_DATE_EPOCH=$(cat "$BASEDIR/output/SOURCE_DATE_EPOCH")
810+
fi
811+
if [ -n "$SOURCE_DATE_EPOCH" ]; then
812+
export SOURCE_DATE_EPOCH
813+
log_info "SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH"
814+
fi
804815
fi
805816

806817
_IS_FUNCTIONS_SOURCED=yes

0 commit comments

Comments
 (0)