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 <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff 2019-10-16 17:04:58 -07:00
parent ccb0b0a7cc
commit 675b414f56
4 changed files with 13 additions and 40 deletions

2
.gitignore vendored
View file

@ -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

View file

@ -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"

View file

@ -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[@]}" )

View file

@ -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 <<DVEOF
// +build autogen
// Package dockerversion is auto-generated at build-time
package dockerversion
// Default build-time variable for library-import.
// This file is overridden on build with build-time information.
const (
GitCommit string = "$GITCOMMIT"
Version string = "$VERSION"
BuildTime string = "$BUILDTIME"
IAmStatic string = "${IAMSTATIC:-true}"
PlatformName string = "${PLATFORM}"
ProductName string = "${PRODUCT}"
DefaultProductLicense string = "${DEFAULT_PRODUCT_LICENSE}"
)
// Code generated by hack/make/.go-autogen. DO NOT EDIT.
DVEOF
cat > dockerversion/version_autogen_unix.go <<DVEOF
// +build autogen,!windows
// Package dockerversion is auto-generated at build-time
package dockerversion
// Default build-time variable for library-import.
// This file is overridden on build with build-time information.
const (
InitCommitID string = "${TINI_COMMIT}"
)
// Code generated by hack/make/.go-autogen. DO NOT EDIT.
DVEOF
LDFLAGS="${LDFALGS} \
-X github.com/docker/docker/dockerversion.Version=${VERSION} \
-X github.com/docker/docker/dockerversion.GitCommit=${GITCOMMIT} \
-X github.com/docker/docker/dockerversion.BuildTime=${BUILDTIME} \
-X github.com/docker/docker/dockerversion.IAmStatic=${IAMSTATIC:-true} \
-X github.com/docker/docker/dockerversion.PlatformName=${PLATFORM} \
-X github.com/docker/docker/dockerversion.ProductName=${PRODUCT} \
-X github.com/docker/docker/dockerversion.DefaultProductLicense=${DEFAULT_PRODUCT_LICENSE} \
-X github.com/docker/docker/dockerversion.InitCommitID=${TINI_COMMIT} \
"
# Compile the Windows resources into the sources
if [ "$(go env GOOS)" = "windows" ]; then