diff options
author | Jakob Unterwurzacher | 2018-12-16 20:16:12 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2018-12-16 20:16:12 +0100 |
commit | d32c1492664645078801d81fbfd7f8b7a469bcc5 (patch) | |
tree | ce01ecdc6e1371d4d4dc27a2b54a9be4e7709537 /build.bash | |
parent | 9daa205c1083d94215a1d1d6ab4fb5c65421e7bd (diff) |
build.bash: respect SOURCE_DATE_EPOCH
SOURCE_DATE_EPOCH seems to be the standard env variable
for faking a build date for reproducible builds.
Diffstat (limited to 'build.bash')
-rwxr-xr-x | build.bash | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -52,12 +52,20 @@ else cd "$MYDIR" fi -# Build date, something like "2017-09-06" +# Build date, something like "2017-09-06". Don't override BUILDDATE +# if it is already set. This may be done for reproducible builds. if [[ -z ${BUILDDATE:-} ]] ; then BUILDDATE=$(date +%Y-%m-%d) fi +# If SOURCE_DATE_EPOCH is set, it overrides BUILDDATE. This is the +# standard environment variable for faking the date in reproducible builds. +if [[ -n ${SOURCE_DATE_EPOCH:-} ]] ; then + BUILDDATE=$(date --utc --date="@${SOURCE_DATE_EPOCH}" +%Y-%m-%d) +fi + LDFLAGS="-X main.GitVersion=$GITVERSION -X main.GitVersionFuse=$GITVERSIONFUSE -X main.BuildDate=$BUILDDATE" + go build "-ldflags=$LDFLAGS" "$@" (cd gocryptfs-xray; go build "$@") |