Skip to content

Commit

Permalink
build.bash: also try BSD date syntax for converting SOURCE_DATE_EPOCH
Browse files Browse the repository at this point in the history
GNU date syntax does not work on macos.

Fixes #570
  • Loading branch information
rfjakob committed Jul 29, 2021
1 parent e83b79b commit a9627c8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

cd "$(dirname "$0")"

# $0 does not work because we may have been sourced
MYNAME=build.bash

# Make sure we have the go binary
go version > /dev/null

Expand All @@ -32,7 +35,7 @@ if [[ -d .git ]] ; then
elif [[ -f VERSION ]] ; then
GITVERSION=$(cat VERSION)
else
echo "Warning: could not determine gocryptfs version"
echo "$MYNAME: warning: could not determine gocryptfs version"
GITVERSION="[unknown]"
fi

Expand All @@ -46,7 +49,7 @@ else
if [[ $FAIL -eq 0 ]]; then
GITVERSIONFUSE=$OUT
else
echo "Warning: could not determine go-fuse version"
echo "$MYNAME: warning: could not determine go-fuse version"
GITVERSIONFUSE="[unknown]"
fi
fi
Expand All @@ -60,7 +63,10 @@ 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)
if ! BUILDDATE=$(date -u --date="@${SOURCE_DATE_EPOCH}" +%Y-%m-%d) ; then
echo "$MYNAME: info: retrying with BSD date syntax..."
BUILDDATE=$(date -u -r "$SOURCE_DATE_EPOCH" +%Y-%m-%d)
fi
fi

# Only set GOFLAGS if it is not already set by the user
Expand Down

0 comments on commit a9627c8

Please sign in to comment.