Selaa lähdekoodia

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 10 vuotta sitten
vanhempi
commit
6871b9b16a

+ 1 - 0
.gitignore

@@ -29,3 +29,4 @@ docs/GIT_BRANCH
 docs/VERSION
 docs/VERSION
 docs/GITCOMMIT
 docs/GITCOMMIT
 docs/changed-files
 docs/changed-files
+autogen/

+ 1 - 1
api/client/commands.go

@@ -27,7 +27,7 @@ import (
 	log "github.com/Sirupsen/logrus"
 	log "github.com/Sirupsen/logrus"
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api/stats"
 	"github.com/docker/docker/api/stats"
-	"github.com/docker/docker/dockerversion"
+	"github.com/docker/docker/autogen/dockerversion"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/nat"
 	"github.com/docker/docker/nat"

+ 1 - 1
api/client/hijack.go

@@ -15,7 +15,7 @@ import (
 
 
 	log "github.com/Sirupsen/logrus"
 	log "github.com/Sirupsen/logrus"
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api"
-	"github.com/docker/docker/dockerversion"
+	"github.com/docker/docker/autogen/dockerversion"
 	"github.com/docker/docker/pkg/promise"
 	"github.com/docker/docker/pkg/promise"
 	"github.com/docker/docker/pkg/stdcopy"
 	"github.com/docker/docker/pkg/stdcopy"
 	"github.com/docker/docker/pkg/term"
 	"github.com/docker/docker/pkg/term"

+ 1 - 1
api/client/utils.go

@@ -17,7 +17,7 @@ import (
 
 
 	log "github.com/Sirupsen/logrus"
 	log "github.com/Sirupsen/logrus"
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api"
-	"github.com/docker/docker/dockerversion"
+	"github.com/docker/docker/autogen/dockerversion"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/pkg/signal"
 	"github.com/docker/docker/pkg/signal"
 	"github.com/docker/docker/pkg/stdcopy"
 	"github.com/docker/docker/pkg/stdcopy"

+ 1 - 1
builtins/builtins.go

@@ -5,8 +5,8 @@ import (
 
 
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api"
 	apiserver "github.com/docker/docker/api/server"
 	apiserver "github.com/docker/docker/api/server"
+	"github.com/docker/docker/autogen/dockerversion"
 	"github.com/docker/docker/daemon/networkdriver/bridge"
 	"github.com/docker/docker/daemon/networkdriver/bridge"
-	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/events"
 	"github.com/docker/docker/events"
 	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/parsers/kernel"

+ 1 - 1
daemon/daemon.go

@@ -18,6 +18,7 @@ import (
 
 
 	log "github.com/Sirupsen/logrus"
 	log "github.com/Sirupsen/logrus"
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api"
+	"github.com/docker/docker/autogen/dockerversion"
 	"github.com/docker/docker/daemon/execdriver"
 	"github.com/docker/docker/daemon/execdriver"
 	"github.com/docker/docker/daemon/execdriver/execdrivers"
 	"github.com/docker/docker/daemon/execdriver/execdrivers"
 	"github.com/docker/docker/daemon/execdriver/lxc"
 	"github.com/docker/docker/daemon/execdriver/lxc"
@@ -25,7 +26,6 @@ import (
 	_ "github.com/docker/docker/daemon/graphdriver/vfs"
 	_ "github.com/docker/docker/daemon/graphdriver/vfs"
 	_ "github.com/docker/docker/daemon/networkdriver/bridge"
 	_ "github.com/docker/docker/daemon/networkdriver/bridge"
 	"github.com/docker/docker/daemon/networkdriver/portallocator"
 	"github.com/docker/docker/daemon/networkdriver/portallocator"
-	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/image"

+ 1 - 1
daemon/info.go

@@ -5,7 +5,7 @@ import (
 	"runtime"
 	"runtime"
 
 
 	log "github.com/Sirupsen/logrus"
 	log "github.com/Sirupsen/logrus"
-	"github.com/docker/docker/dockerversion"
+	"github.com/docker/docker/autogen/dockerversion"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/parsers/operatingsystem"
 	"github.com/docker/docker/pkg/parsers/operatingsystem"

+ 1 - 1
docker/daemon.go

@@ -9,12 +9,12 @@ import (
 	"path/filepath"
 	"path/filepath"
 
 
 	log "github.com/Sirupsen/logrus"
 	log "github.com/Sirupsen/logrus"
+	"github.com/docker/docker/autogen/dockerversion"
 	"github.com/docker/docker/builder"
 	"github.com/docker/docker/builder"
 	"github.com/docker/docker/builtins"
 	"github.com/docker/docker/builtins"
 	"github.com/docker/docker/daemon"
 	"github.com/docker/docker/daemon"
 	_ "github.com/docker/docker/daemon/execdriver/lxc"
 	_ "github.com/docker/docker/daemon/execdriver/lxc"
 	_ "github.com/docker/docker/daemon/execdriver/native"
 	_ "github.com/docker/docker/daemon/execdriver/native"
-	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/engine"
 	"github.com/docker/docker/pkg/homedir"
 	"github.com/docker/docker/pkg/homedir"
 	flag "github.com/docker/docker/pkg/mflag"
 	flag "github.com/docker/docker/pkg/mflag"

+ 1 - 1
docker/docker.go

@@ -11,7 +11,7 @@ import (
 	log "github.com/Sirupsen/logrus"
 	log "github.com/Sirupsen/logrus"
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/api/client"
 	"github.com/docker/docker/api/client"
-	"github.com/docker/docker/dockerversion"
+	"github.com/docker/docker/autogen/dockerversion"
 	flag "github.com/docker/docker/pkg/mflag"
 	flag "github.com/docker/docker/pkg/mflag"
 	"github.com/docker/docker/pkg/reexec"
 	"github.com/docker/docker/pkg/reexec"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"

+ 0 - 15
dockerversion/dockerversion.go

@@ -1,15 +0,0 @@
-package dockerversion
-
-// FIXME: this should be embedded in the docker/docker.go,
-// but we can't because distro policy requires us to
-// package a separate dockerinit binary, and that binary needs
-// to know its version too.
-
-var (
-	GITCOMMIT string
-	VERSION   string
-
-	IAMSTATIC string // whether or not Docker itself was compiled statically via ./hack/make.sh binary ("true" or not "true")
-	INITSHA1  string // sha1sum of separate static dockerinit, if Docker itself was compiled dynamically via ./hack/make.sh dynbinary
-	INITPATH  string // custom location to search for a valid dockerinit binary (available for packagers as a last resort escape hatch)
-)

+ 1 - 1
graph/graph.go

@@ -13,8 +13,8 @@ import (
 	"time"
 	"time"
 
 
 	log "github.com/Sirupsen/logrus"
 	log "github.com/Sirupsen/logrus"
+	"github.com/docker/docker/autogen/dockerversion"
 	"github.com/docker/docker/daemon/graphdriver"
 	"github.com/docker/docker/daemon/graphdriver"
-	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/truncindex"
 	"github.com/docker/docker/pkg/truncindex"

+ 1 - 1
integration/graph_test.go

@@ -2,8 +2,8 @@ package docker
 
 
 import (
 import (
 	"errors"
 	"errors"
+	"github.com/docker/docker/autogen/dockerversion"
 	"github.com/docker/docker/daemon/graphdriver"
 	"github.com/docker/docker/daemon/graphdriver"
-	"github.com/docker/docker/dockerversion"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/graph"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/image"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/archive"

+ 3 - 8
project/make.sh

@@ -99,14 +99,10 @@ if [ "$DOCKER_EXECDRIVER" = 'lxc' ]; then
 fi
 fi
 
 
 # Use these flags when compiling the tests and final binary
 # Use these flags when compiling the tests and final binary
-LDFLAGS='
-	-X '$DOCKER_PKG'/dockerversion.GITCOMMIT "'$GITCOMMIT'"
-	-X '$DOCKER_PKG'/dockerversion.VERSION "'$VERSION'"
-'
 
 
-if [ -z "$DEBUG" ]; then
-	LDFLAGS="-w $LDFLAGS"
-fi
+IAMSTATIC='true'
+source "$(dirname "$BASH_SOURCE")/make/.dockerversion"
+LDFLAGS='-w'
 
 
 LDFLAGS_STATIC='-linkmode external'
 LDFLAGS_STATIC='-linkmode external'
 # Cgo -H windows is incompatible with -linkmode external.
 # Cgo -H windows is incompatible with -linkmode external.
@@ -128,7 +124,6 @@ TESTFLAGS+=" -test.timeout=${TIMEOUT}"
 EXTLDFLAGS_STATIC_DOCKER="$EXTLDFLAGS_STATIC -lpthread -Wl,--unresolved-symbols=ignore-in-object-files"
 EXTLDFLAGS_STATIC_DOCKER="$EXTLDFLAGS_STATIC -lpthread -Wl,--unresolved-symbols=ignore-in-object-files"
 LDFLAGS_STATIC_DOCKER="
 LDFLAGS_STATIC_DOCKER="
 	$LDFLAGS_STATIC
 	$LDFLAGS_STATIC
-	-X $DOCKER_PKG/dockerversion.IAMSTATIC true
 	-extldflags \"$EXTLDFLAGS_STATIC_DOCKER\"
 	-extldflags \"$EXTLDFLAGS_STATIC_DOCKER\"
 "
 "
 
 

+ 3 - 0
project/make/.dockerinit

@@ -1,6 +1,9 @@
 #!/bin/bash
 #!/bin/bash
 set -e
 set -e
 
 
+IAMSTATIC="true"
+source "$(dirname "$BASH_SOURCE")/.dockerversion"
+
 # dockerinit still needs to be a static binary, even if docker is dynamic
 # dockerinit still needs to be a static binary, even if docker is dynamic
 go build \
 go build \
 	-o "$DEST/dockerinit-$VERSION" \
 	-o "$DEST/dockerinit-$VERSION" \

+ 24 - 0
project/make/.dockerversion

@@ -0,0 +1,24 @@
+#!/bin/bash
+
+rm -rf autogen
+mkdir -p autogen/dockerversion
+cat > autogen/dockerversion/dockerversion.go <<EOF
+// AUTOGENERATED FILE; see $BASH_SOURCE
+package dockerversion
+
+var (
+	GITCOMMIT string = "$GITCOMMIT"
+	VERSION   string = "$VERSION"
+)
+EOF
+
+cat > autogen/dockerversion/static.go <<EOF
+// AUTOGENERATED FILE; see $BASH_SOURCE
+package dockerversion
+
+var (
+	IAMSTATIC string = "${IAMSTATIC:-true}"
+	INITSHA1  string = "$DOCKER_INITSHA1"
+	INITPATH  string = "$DOCKER_INITPATH"
+)
+EOF

+ 2 - 0
project/make/binary

@@ -11,6 +11,8 @@ if [[ "$(uname -s)" == CYGWIN* ]]; then
 	DEST=$(cygpath -mw $DEST)
 	DEST=$(cygpath -mw $DEST)
 fi
 fi
 
 
+source "$(dirname "$BASH_SOURCE")/.dockerversion"
+
 go build \
 go build \
 	-o "$DEST/$BINARY_FULLNAME" \
 	-o "$DEST/$BINARY_FULLNAME" \
 	"${BUILDFLAGS[@]}" \
 	"${BUILDFLAGS[@]}" \

+ 1 - 1
project/make/dynbinary

@@ -14,7 +14,7 @@ fi
 # DOCKER_INITSHA1 is exported so that other bundlescripts can easily access it later without recalculating it
 # DOCKER_INITSHA1 is exported so that other bundlescripts can easily access it later without recalculating it
 
 
 (
 (
-	export LDFLAGS_STATIC_DOCKER="-X $DOCKER_PKG/dockerversion.INITSHA1 \"$DOCKER_INITSHA1\" -X $DOCKER_PKG/dockerversion.INITPATH \"$DOCKER_INITPATH\""
+	export IAMSTATIC="false"
 	export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
 	export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
 	export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here
 	export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here
 	source "$(dirname "$BASH_SOURCE")/binary"
 	source "$(dirname "$BASH_SOURCE")/binary"

+ 1 - 1
registry/httpfactory.go

@@ -3,7 +3,7 @@ package registry
 import (
 import (
 	"runtime"
 	"runtime"
 
 
-	"github.com/docker/docker/dockerversion"
+	"github.com/docker/docker/autogen/dockerversion"
 	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/pkg/parsers/kernel"
 	"github.com/docker/docker/utils"
 	"github.com/docker/docker/utils"
 )
 )

+ 1 - 1
utils/utils.go

@@ -21,7 +21,7 @@ import (
 	"sync"
 	"sync"
 
 
 	log "github.com/Sirupsen/logrus"
 	log "github.com/Sirupsen/logrus"
-	"github.com/docker/docker/dockerversion"
+	"github.com/docker/docker/autogen/dockerversion"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/fileutils"
 	"github.com/docker/docker/pkg/fileutils"
 	"github.com/docker/docker/pkg/ioutils"
 	"github.com/docker/docker/pkg/ioutils"