summaryrefslogtreecommitdiff
path: root/build.bash
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-09-06 21:41:22 +0200
committerJakob Unterwurzacher2017-09-06 21:41:22 +0200
commit830cbb7218d61467c011fd5e9d4751e1529677e4 (patch)
tree72bd7cfc2a3c9ab4ddb0554006f666b0caaa7a8e /build.bash
parent512be8f081d2cc2afc778a2dcf5447647de2bbea (diff)
build.bash: make reproduceable builds easier
* Reduce the build time precision from seconds to days * Allow to specify an arbitrary build date through an env variable
Diffstat (limited to 'build.bash')
-rwxr-xr-xbuild.bash15
1 files changed, 12 insertions, 3 deletions
diff --git a/build.bash b/build.bash
index 5c13536..237e274 100755
--- a/build.bash
+++ b/build.bash
@@ -1,4 +1,11 @@
#!/bin/bash
+#
+# Compile gocryptfs and bake the git version string of itself and the go-fuse
+# library into the binary.
+#
+# If you want to fake a build date to reproduce a specific build,
+# you can use:
+# BUILDDATE=2017-02-03 ./build.bash
set -eu
@@ -24,13 +31,15 @@ fi
GITVERSIONFUSE=$OUT
cd "$MYDIR"
-# Build Unix timestamp, something like 1467554204.
-BUILDTIME=$(date +%s)
+# Build date, something like "2017-09-06"
+if [[ -z ${BUILDDATE:-} ]] ; then
+ BUILDDATE=$(date +%Y-%m-%d)
+fi
# Make sure we have the go binary
go version > /dev/null
-LDFLAGS="-X main.GitVersion=$GITVERSION -X main.GitVersionFuse=$GITVERSIONFUSE -X main.BuildTime=$BUILDTIME"
+LDFLAGS="-X main.GitVersion=$GITVERSION -X main.GitVersionFuse=$GITVERSIONFUSE -X main.BuildDate=$BUILDDATE"
go build "-ldflags=$LDFLAGS" $@
(cd gocryptfs-xray; go build $@)