summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 "$@")