aboutsummaryrefslogtreecommitdiff
path: root/build.bash
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-12-16 20:16:12 +0100
committerJakob Unterwurzacher2018-12-16 20:16:12 +0100
commitd32c1492664645078801d81fbfd7f8b7a469bcc5 (patch)
treece01ecdc6e1371d4d4dc27a2b54a9be4e7709537 /build.bash
parent9daa205c1083d94215a1d1d6ab4fb5c65421e7bd (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-xbuild.bash10
1 files changed, 9 insertions, 1 deletions
diff --git a/build.bash b/build.bash
index 6f7f7d8..a8a0d60 100755
--- a/build.bash
+++ b/build.bash
@@ -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 "$@")