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

Addresses #9207

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
This commit is contained in:
Srini Brahmaroutu 2015-02-04 21:22:38 +00:00
parent 55566f2f8f
commit 6871b9b16a
19 changed files with 46 additions and 36 deletions

1
.gitignore vendored
View File

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

View File

@ -27,7 +27,7 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/docker/docker/api"
"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/graph"
"github.com/docker/docker/nat"

View File

@ -15,7 +15,7 @@ import (
log "github.com/Sirupsen/logrus"
"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/stdcopy"
"github.com/docker/docker/pkg/term"

View File

@ -17,7 +17,7 @@ import (
log "github.com/Sirupsen/logrus"
"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/pkg/signal"
"github.com/docker/docker/pkg/stdcopy"

View File

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

View File

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

View File

@ -5,7 +5,7 @@ import (
"runtime"
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/pkg/parsers/kernel"
"github.com/docker/docker/pkg/parsers/operatingsystem"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -99,14 +99,10 @@ if [ "$DOCKER_EXECDRIVER" = 'lxc' ]; then
fi
# 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'
# 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"
LDFLAGS_STATIC_DOCKER="
$LDFLAGS_STATIC
-X $DOCKER_PKG/dockerversion.IAMSTATIC true
-extldflags \"$EXTLDFLAGS_STATIC_DOCKER\"
"

View File

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

View File

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

View File

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

View File

@ -14,7 +14,7 @@ fi
# 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[@]/static_build /}" ) # we're not building a "static" binary here
source "$(dirname "$BASH_SOURCE")/binary"

View File

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

View File

@ -21,7 +21,7 @@ import (
"sync"
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/fileutils"
"github.com/docker/docker/pkg/ioutils"