From 830cbb7218d61467c011fd5e9d4751e1529677e4 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 6 Sep 2017 21:41:22 +0200 Subject: 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 --- build.bash | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'build.bash') 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 $@) -- cgit v1.2.3