mirror of https://github.com/docker/cli.git
scripts/build: make sure build-time is in UTC
Before this: SOURCE_DATE_EPOCH=1606660000 DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary ... + go build -o build/docker-darwin-amd64 -tags ' osusergo pkcs11' -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=090dd58dc" -X "github.com/docker/cli/cli/version.BuildTime=2020-11-29T15:26:40Z" -X "github.com/docker/cli/cli/version.Version=20.10.2-590-g090dd58dc"' -buildmode=pie github.com/docker/cli/cmd/docker ... make -f docker.Makefile shell SOURCE_DATE_EPOCH=1606660000 make binary ... + go build -o build/docker-linux-amd64 -tags -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=090dd58dc" -X "github.com/docker/cli/cli/version.BuildTime=2020-11-29T14:26:40Z" -X "github.com/docker/cli/cli/version.Version=20.10.0-dev"' github.com/docker/cli/cmd/docker ... Notice that `version.BuildTime` is `2020-11-29T15:26:40Z` outside the container, and `2020-11-29T14:26:40Z` inside. After this: SOURCE_DATE_EPOCH=1606660000 DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary ... + go build -o build/docker-darwin-amd64 -tags ' osusergo pkcs11' -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=090dd58dc" -X "github.com/docker/cli/cli/version.BuildTime=2020-11-29T14:26:40Z" -X "github.com/docker/cli/cli/version.Version=20.10.2-590-g090dd58dc.m"' -buildmode=pie github.com/docker/cli/cmd/docker ... make -f docker.Makefile shell SOURCE_DATE_EPOCH=1606660000 make binary ... + go build -o build/docker-linux-amd64 -tags -ldflags ' -w -X "github.com/docker/cli/cli/version.GitCommit=090dd58dc" -X "github.com/docker/cli/cli/version.BuildTime=2020-11-29T14:26:40Z" -X "github.com/docker/cli/cli/version.Version=20.10.0-dev"' github.com/docker/cli/cmd/docker ... Notice that `version.BuildTime` is `2020-11-29T14:26:40Z` both outside and inside the container. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
72ed7bd3e9
commit
8fd92f1866
|
@ -16,10 +16,10 @@ GITCOMMIT=${GITCOMMIT:-$(git rev-parse --short HEAD 2> /dev/null || true)}
|
|||
if [ "$(uname)" = "Darwin" ]; then
|
||||
# Using BSD date (macOS), which doesn't suppoort the --date option
|
||||
# date -jf "<input format>" "<input value>" +"<output format>" (https://unix.stackexchange.com/a/86510)
|
||||
BUILDTIME=${BUILDTIME:-$(date -jf "%s" "${SOURCE_DATE_EPOCH:-$(date +%s)}" +"%Y-%m-%dT%H:%M:%SZ")}
|
||||
BUILDTIME=${BUILDTIME:-$(TZ=UTC date -jf "%s" "${SOURCE_DATE_EPOCH:-$(date +%s)}" +"%Y-%m-%dT%H:%M:%SZ")}
|
||||
else
|
||||
# Using GNU date (Linux)
|
||||
BUILDTIME=${BUILDTIME:-$(date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +"%Y-%m-%dT%H:%M:%SZ")}
|
||||
BUILDTIME=${BUILDTIME:-$(TZ=UTC date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +"%Y-%m-%dT%H:%M:%SZ")}
|
||||
fi
|
||||
|
||||
GOOS="$(go env GOOS)"
|
||||
|
|
Loading…
Reference in New Issue