Browse code

Removing -X flag option and autogenerated code to create Dockerversion.go functionality Addresses #9207

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>

Srini Brahmaroutu authored on 2015/02/05 06:22:38
Showing 19 changed files
... ...
@@ -29,3 +29,4 @@ docs/GIT_BRANCH
29 29
 docs/VERSION
30 30
 docs/GITCOMMIT
31 31
 docs/changed-files
32
+autogen/
... ...
@@ -27,7 +27,7 @@ import (
27 27
 	log "github.com/Sirupsen/logrus"
28 28
 	"github.com/docker/docker/api"
29 29
 	"github.com/docker/docker/api/stats"
30
-	"github.com/docker/docker/dockerversion"
30
+	"github.com/docker/docker/autogen/dockerversion"
31 31
 	"github.com/docker/docker/engine"
32 32
 	"github.com/docker/docker/graph"
33 33
 	"github.com/docker/docker/nat"
... ...
@@ -15,7 +15,7 @@ import (
15 15
 
16 16
 	log "github.com/Sirupsen/logrus"
17 17
 	"github.com/docker/docker/api"
18
-	"github.com/docker/docker/dockerversion"
18
+	"github.com/docker/docker/autogen/dockerversion"
19 19
 	"github.com/docker/docker/pkg/promise"
20 20
 	"github.com/docker/docker/pkg/stdcopy"
21 21
 	"github.com/docker/docker/pkg/term"
... ...
@@ -17,7 +17,7 @@ import (
17 17
 
18 18
 	log "github.com/Sirupsen/logrus"
19 19
 	"github.com/docker/docker/api"
20
-	"github.com/docker/docker/dockerversion"
20
+	"github.com/docker/docker/autogen/dockerversion"
21 21
 	"github.com/docker/docker/engine"
22 22
 	"github.com/docker/docker/pkg/signal"
23 23
 	"github.com/docker/docker/pkg/stdcopy"
... ...
@@ -5,8 +5,8 @@ import (
5 5
 
6 6
 	"github.com/docker/docker/api"
7 7
 	apiserver "github.com/docker/docker/api/server"
8
+	"github.com/docker/docker/autogen/dockerversion"
8 9
 	"github.com/docker/docker/daemon/networkdriver/bridge"
9
-	"github.com/docker/docker/dockerversion"
10 10
 	"github.com/docker/docker/engine"
11 11
 	"github.com/docker/docker/events"
12 12
 	"github.com/docker/docker/pkg/parsers/kernel"
... ...
@@ -18,6 +18,7 @@ import (
18 18
 
19 19
 	log "github.com/Sirupsen/logrus"
20 20
 	"github.com/docker/docker/api"
21
+	"github.com/docker/docker/autogen/dockerversion"
21 22
 	"github.com/docker/docker/daemon/execdriver"
22 23
 	"github.com/docker/docker/daemon/execdriver/execdrivers"
23 24
 	"github.com/docker/docker/daemon/execdriver/lxc"
... ...
@@ -25,7 +26,6 @@ import (
25 25
 	_ "github.com/docker/docker/daemon/graphdriver/vfs"
26 26
 	_ "github.com/docker/docker/daemon/networkdriver/bridge"
27 27
 	"github.com/docker/docker/daemon/networkdriver/portallocator"
28
-	"github.com/docker/docker/dockerversion"
29 28
 	"github.com/docker/docker/engine"
30 29
 	"github.com/docker/docker/graph"
31 30
 	"github.com/docker/docker/image"
... ...
@@ -5,7 +5,7 @@ import (
5 5
 	"runtime"
6 6
 
7 7
 	log "github.com/Sirupsen/logrus"
8
-	"github.com/docker/docker/dockerversion"
8
+	"github.com/docker/docker/autogen/dockerversion"
9 9
 	"github.com/docker/docker/engine"
10 10
 	"github.com/docker/docker/pkg/parsers/kernel"
11 11
 	"github.com/docker/docker/pkg/parsers/operatingsystem"
... ...
@@ -9,12 +9,12 @@ import (
9 9
 	"path/filepath"
10 10
 
11 11
 	log "github.com/Sirupsen/logrus"
12
+	"github.com/docker/docker/autogen/dockerversion"
12 13
 	"github.com/docker/docker/builder"
13 14
 	"github.com/docker/docker/builtins"
14 15
 	"github.com/docker/docker/daemon"
15 16
 	_ "github.com/docker/docker/daemon/execdriver/lxc"
16 17
 	_ "github.com/docker/docker/daemon/execdriver/native"
17
-	"github.com/docker/docker/dockerversion"
18 18
 	"github.com/docker/docker/engine"
19 19
 	"github.com/docker/docker/pkg/homedir"
20 20
 	flag "github.com/docker/docker/pkg/mflag"
... ...
@@ -11,7 +11,7 @@ import (
11 11
 	log "github.com/Sirupsen/logrus"
12 12
 	"github.com/docker/docker/api"
13 13
 	"github.com/docker/docker/api/client"
14
-	"github.com/docker/docker/dockerversion"
14
+	"github.com/docker/docker/autogen/dockerversion"
15 15
 	flag "github.com/docker/docker/pkg/mflag"
16 16
 	"github.com/docker/docker/pkg/reexec"
17 17
 	"github.com/docker/docker/utils"
18 18
deleted file mode 100644
... ...
@@ -1,15 +0,0 @@
1
-package dockerversion
2
-
3
-// FIXME: this should be embedded in the docker/docker.go,
4
-// but we can't because distro policy requires us to
5
-// package a separate dockerinit binary, and that binary needs
6
-// to know its version too.
7
-
8
-var (
9
-	GITCOMMIT string
10
-	VERSION   string
11
-
12
-	IAMSTATIC string // whether or not Docker itself was compiled statically via ./hack/make.sh binary ("true" or not "true")
13
-	INITSHA1  string // sha1sum of separate static dockerinit, if Docker itself was compiled dynamically via ./hack/make.sh dynbinary
14
-	INITPATH  string // custom location to search for a valid dockerinit binary (available for packagers as a last resort escape hatch)
15
-)
... ...
@@ -13,8 +13,8 @@ import (
13 13
 	"time"
14 14
 
15 15
 	log "github.com/Sirupsen/logrus"
16
+	"github.com/docker/docker/autogen/dockerversion"
16 17
 	"github.com/docker/docker/daemon/graphdriver"
17
-	"github.com/docker/docker/dockerversion"
18 18
 	"github.com/docker/docker/image"
19 19
 	"github.com/docker/docker/pkg/archive"
20 20
 	"github.com/docker/docker/pkg/truncindex"
... ...
@@ -2,8 +2,8 @@ package docker
2 2
 
3 3
 import (
4 4
 	"errors"
5
+	"github.com/docker/docker/autogen/dockerversion"
5 6
 	"github.com/docker/docker/daemon/graphdriver"
6
-	"github.com/docker/docker/dockerversion"
7 7
 	"github.com/docker/docker/graph"
8 8
 	"github.com/docker/docker/image"
9 9
 	"github.com/docker/docker/pkg/archive"
... ...
@@ -99,14 +99,10 @@ if [ "$DOCKER_EXECDRIVER" = 'lxc' ]; then
99 99
 fi
100 100
 
101 101
 # Use these flags when compiling the tests and final binary
102
-LDFLAGS='
103
-	-X '$DOCKER_PKG'/dockerversion.GITCOMMIT "'$GITCOMMIT'"
104
-	-X '$DOCKER_PKG'/dockerversion.VERSION "'$VERSION'"
105
-'
106 102
 
107
-if [ -z "$DEBUG" ]; then
108
-	LDFLAGS="-w $LDFLAGS"
109
-fi
103
+IAMSTATIC='true'
104
+source "$(dirname "$BASH_SOURCE")/make/.dockerversion"
105
+LDFLAGS='-w'
110 106
 
111 107
 LDFLAGS_STATIC='-linkmode external'
112 108
 # Cgo -H windows is incompatible with -linkmode external.
... ...
@@ -128,7 +124,6 @@ TESTFLAGS+=" -test.timeout=${TIMEOUT}"
128 128
 EXTLDFLAGS_STATIC_DOCKER="$EXTLDFLAGS_STATIC -lpthread -Wl,--unresolved-symbols=ignore-in-object-files"
129 129
 LDFLAGS_STATIC_DOCKER="
130 130
 	$LDFLAGS_STATIC
131
-	-X $DOCKER_PKG/dockerversion.IAMSTATIC true
132 131
 	-extldflags \"$EXTLDFLAGS_STATIC_DOCKER\"
133 132
 "
134 133
 
... ...
@@ -1,6 +1,9 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
+IAMSTATIC="true"
5
+source "$(dirname "$BASH_SOURCE")/.dockerversion"
6
+
4 7
 # dockerinit still needs to be a static binary, even if docker is dynamic
5 8
 go build \
6 9
 	-o "$DEST/dockerinit-$VERSION" \
7 10
new file mode 100644
... ...
@@ -0,0 +1,24 @@
0
+#!/bin/bash
1
+
2
+rm -rf autogen
3
+mkdir -p autogen/dockerversion
4
+cat > autogen/dockerversion/dockerversion.go <<EOF
5
+// AUTOGENERATED FILE; see $BASH_SOURCE
6
+package dockerversion
7
+
8
+var (
9
+	GITCOMMIT string = "$GITCOMMIT"
10
+	VERSION   string = "$VERSION"
11
+)
12
+EOF
13
+
14
+cat > autogen/dockerversion/static.go <<EOF
15
+// AUTOGENERATED FILE; see $BASH_SOURCE
16
+package dockerversion
17
+
18
+var (
19
+	IAMSTATIC string = "${IAMSTATIC:-true}"
20
+	INITSHA1  string = "$DOCKER_INITSHA1"
21
+	INITPATH  string = "$DOCKER_INITPATH"
22
+)
23
+EOF
... ...
@@ -11,6 +11,8 @@ if [[ "$(uname -s)" == CYGWIN* ]]; then
11 11
 	DEST=$(cygpath -mw $DEST)
12 12
 fi
13 13
 
14
+source "$(dirname "$BASH_SOURCE")/.dockerversion"
15
+
14 16
 go build \
15 17
 	-o "$DEST/$BINARY_FULLNAME" \
16 18
 	"${BUILDFLAGS[@]}" \
... ...
@@ -14,7 +14,7 @@ fi
14 14
 # DOCKER_INITSHA1 is exported so that other bundlescripts can easily access it later without recalculating it
15 15
 
16 16
 (
17
-	export LDFLAGS_STATIC_DOCKER="-X $DOCKER_PKG/dockerversion.INITSHA1 \"$DOCKER_INITSHA1\" -X $DOCKER_PKG/dockerversion.INITPATH \"$DOCKER_INITPATH\""
17
+	export IAMSTATIC="false"
18 18
 	export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
19 19
 	export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here
20 20
 	source "$(dirname "$BASH_SOURCE")/binary"
... ...
@@ -3,7 +3,7 @@ package registry
3 3
 import (
4 4
 	"runtime"
5 5
 
6
-	"github.com/docker/docker/dockerversion"
6
+	"github.com/docker/docker/autogen/dockerversion"
7 7
 	"github.com/docker/docker/pkg/parsers/kernel"
8 8
 	"github.com/docker/docker/utils"
9 9
 )
... ...
@@ -21,7 +21,7 @@ import (
21 21
 	"sync"
22 22
 
23 23
 	log "github.com/Sirupsen/logrus"
24
-	"github.com/docker/docker/dockerversion"
24
+	"github.com/docker/docker/autogen/dockerversion"
25 25
 	"github.com/docker/docker/pkg/archive"
26 26
 	"github.com/docker/docker/pkg/fileutils"
27 27
 	"github.com/docker/docker/pkg/ioutils"