From 675b414f56063826457cbc8f0c165af67198bfa8 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Wed, 16 Oct 2019 17:04:58 -0700 Subject: [PATCH] Use -X ldflags to set dockerversion package vars This eliminates the need to lay down an auto-generated file. IIRC this was originally hadded for gccgo which we no longer support. Signed-off-by: Brian Goff --- .gitignore | 2 -- dockerversion/version_lib.go | 4 ++-- hack/make.sh | 2 +- hack/make/.go-autogen | 45 ++++++++---------------------------- 4 files changed, 13 insertions(+), 40 deletions(-) diff --git a/.gitignore b/.gitignore index abad293ee0..1605fa8930 100644 --- a/.gitignore +++ b/.gitignore @@ -17,8 +17,6 @@ autogen/ bundles/ cmd/dockerd/dockerd contrib/builder/rpm/*/changelog -dockerversion/version_autogen.go -dockerversion/version_autogen_unix.go vendor/pkg/ go-test-report.json profile.out diff --git a/dockerversion/version_lib.go b/dockerversion/version_lib.go index b7d4650444..e383aca843 100644 --- a/dockerversion/version_lib.go +++ b/dockerversion/version_lib.go @@ -4,8 +4,8 @@ package dockerversion // import "github.com/docker/docker/dockerversion" // Default build-time variable for library-import. -// This file is overridden on build with build-time information. -const ( +// These variables are overridden on build with build-time information. +var ( GitCommit = "library-import" Version = "library-import" BuildTime = "library-import" diff --git a/hack/make.sh b/hack/make.sh index 1bd37b02cd..4791211334 100755 --- a/hack/make.sh +++ b/hack/make.sh @@ -113,7 +113,7 @@ LDFLAGS_STATIC='' EXTLDFLAGS_STATIC='-static' # ORIG_BUILDFLAGS is necessary for the cross target which cannot always build # with options like -race. -ORIG_BUILDFLAGS=( -tags "autogen netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo ) +ORIG_BUILDFLAGS=( -tags "netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo ) # see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here BUILDFLAGS=( ${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}" ) diff --git a/hack/make/.go-autogen b/hack/make/.go-autogen index a56add8934..3340448541 100644 --- a/hack/make/.go-autogen +++ b/hack/make/.go-autogen @@ -6,41 +6,16 @@ source hack/dockerfile/install/runc.installer source hack/dockerfile/install/tini.installer source hack/dockerfile/install/containerd.installer -cat > dockerversion/version_autogen.go < dockerversion/version_autogen_unix.go <