Skip to content

Commit

Permalink
Allow to override build date with SOURCE_DATE_EPOCH
Browse files Browse the repository at this point in the history
to make builds reproducible.
See https://reproducible-builds.org/ for why this is good
and https://reproducible-builds.org/specs/source-date-epoch/
for the definition of this variable.

This date call works with different variants of date (GNU, FreeBSD, ...).

Also use UTC to be independent of timezone.

This patch was done while working on reproducible builds for openSUSE.
  • Loading branch information
bmwiedemann committed Apr 23, 2024
1 parent 77fd4df commit 0e1c488
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion proj_mgmt/DATE_cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ if [ $osType = "Darwin" ]; then
fi
fi

$my_cmd "$arg"
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$($my_cmd +%s)}"
$my_cmd -u -d "@$SOURCE_DATE_EPOCH" "$arg" 2>/dev/null ||
$my_cmd -u -r "$SOURCE_DATE_EPOCH" "$arg" 2>/dev/null ||
$my_cmd "$arg"

0 comments on commit 0e1c488

Please sign in to comment.