Skip to content

Commit 675b414

Browse files
committed
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 <[email protected]>
1 parent ccb0b0a commit 675b414

4 files changed

Lines changed: 13 additions & 40 deletions

File tree

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ autogen/
1717
bundles/
1818
cmd/dockerd/dockerd
1919
contrib/builder/rpm/*/changelog
20-
dockerversion/version_autogen.go
21-
dockerversion/version_autogen_unix.go
2220
vendor/pkg/
2321
go-test-report.json
2422
profile.out

dockerversion/version_lib.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
package dockerversion // import "github.com/docker/docker/dockerversion"
55

66
// Default build-time variable for library-import.
7-
// This file is overridden on build with build-time information.
8-
const (
7+
// These variables are overridden on build with build-time information.
8+
var (
99
GitCommit = "library-import"
1010
Version = "library-import"
1111
BuildTime = "library-import"

hack/make.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ LDFLAGS_STATIC=''
113113
EXTLDFLAGS_STATIC='-static'
114114
# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
115115
# with options like -race.
116-
ORIG_BUILDFLAGS=( -tags "autogen netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
116+
ORIG_BUILDFLAGS=( -tags "netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
117117
# see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
118118

119119
BUILDFLAGS=( ${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}" )

hack/make/.go-autogen

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,16 @@ source hack/dockerfile/install/runc.installer
66
source hack/dockerfile/install/tini.installer
77
source hack/dockerfile/install/containerd.installer
88

9-
cat > dockerversion/version_autogen.go <<DVEOF
10-
// +build autogen
11-
12-
// Package dockerversion is auto-generated at build-time
13-
package dockerversion
14-
15-
// Default build-time variable for library-import.
16-
// This file is overridden on build with build-time information.
17-
const (
18-
GitCommit string = "$GITCOMMIT"
19-
Version string = "$VERSION"
20-
BuildTime string = "$BUILDTIME"
21-
IAmStatic string = "${IAMSTATIC:-true}"
22-
PlatformName string = "${PLATFORM}"
23-
ProductName string = "${PRODUCT}"
24-
DefaultProductLicense string = "${DEFAULT_PRODUCT_LICENSE}"
25-
)
26-
27-
// Code generated by hack/make/.go-autogen. DO NOT EDIT.
28-
DVEOF
29-
30-
cat > dockerversion/version_autogen_unix.go <<DVEOF
31-
// +build autogen,!windows
32-
33-
// Package dockerversion is auto-generated at build-time
34-
package dockerversion
35-
36-
// Default build-time variable for library-import.
37-
// This file is overridden on build with build-time information.
38-
const (
39-
InitCommitID string = "${TINI_COMMIT}"
40-
)
41-
42-
// Code generated by hack/make/.go-autogen. DO NOT EDIT.
43-
DVEOF
9+
LDFLAGS="${LDFALGS} \
10+
-X github.com/docker/docker/dockerversion.Version=${VERSION} \
11+
-X github.com/docker/docker/dockerversion.GitCommit=${GITCOMMIT} \
12+
-X github.com/docker/docker/dockerversion.BuildTime=${BUILDTIME} \
13+
-X github.com/docker/docker/dockerversion.IAmStatic=${IAMSTATIC:-true} \
14+
-X github.com/docker/docker/dockerversion.PlatformName=${PLATFORM} \
15+
-X github.com/docker/docker/dockerversion.ProductName=${PRODUCT} \
16+
-X github.com/docker/docker/dockerversion.DefaultProductLicense=${DEFAULT_PRODUCT_LICENSE} \
17+
-X github.com/docker/docker/dockerversion.InitCommitID=${TINI_COMMIT} \
18+
"
4419

4520
# Compile the Windows resources into the sources
4621
if [ "$(go env GOOS)" = "windows" ]; then

0 commit comments

Comments
 (0)