Browse code

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>

Brian Goff authored on 2019/10/17 09:04:58
Showing 4 changed files
... ...
@@ -17,8 +17,6 @@ autogen/
17 17
 bundles/
18 18
 cmd/dockerd/dockerd
19 19
 contrib/builder/rpm/*/changelog
20
-dockerversion/version_autogen.go
21
-dockerversion/version_autogen_unix.go
22 20
 vendor/pkg/
23 21
 go-test-report.json
24 22
 profile.out
... ...
@@ -4,8 +4,8 @@
4 4
 package dockerversion // import "github.com/docker/docker/dockerversion"
5 5
 
6 6
 // 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 (
9 9
 	GitCommit             = "library-import"
10 10
 	Version               = "library-import"
11 11
 	BuildTime             = "library-import"
... ...
@@ -113,7 +113,7 @@ LDFLAGS_STATIC=''
113 113
 EXTLDFLAGS_STATIC='-static'
114 114
 # ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
115 115
 # 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 )
117 117
 # see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
118 118
 
119 119
 BUILDFLAGS=( ${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}" )
... ...
@@ -6,41 +6,16 @@ source hack/dockerfile/install/runc.installer
6 6
 source hack/dockerfile/install/tini.installer
7 7
 source hack/dockerfile/install/containerd.installer
8 8
 
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
+"
44 19
 
45 20
 # Compile the Windows resources into the sources
46 21
 if [ "$(go env GOOS)" = "windows" ]; then