1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #10665 from brahmaroutu/autogen_removeXflag

Removing -X flag option and autogenerating code to create Dockerversion....
This commit is contained in:
Michael Crosby 2015-02-20 09:53:07 -08:00
commit b32564798d
19 changed files with 46 additions and 36 deletions

1
.gitignore vendored
View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

View file

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

View file

@ -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 IAMSTATIC='true'
LDFLAGS="-w $LDFLAGS" source "$(dirname "$BASH_SOURCE")/make/.dockerversion"
fi 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\"
" "

View file

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

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) 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[@]}" \

View file

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

View file

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

View file

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