Use code generation to set IAMSTATIC instead of -X
Signed-off-by: Michael Hudson-Doyle <michael.hudson@linaro.org>
This commit is contained in:
parent
6ce4f82ebe
commit
3e10b93106
4 changed files with 23 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -27,3 +27,4 @@ docs/AWS_S3_BUCKET
|
|||
docs/GIT_BRANCH
|
||||
docs/VERSION
|
||||
docs/GITCOMMIT
|
||||
dockerversion/static.go
|
||||
|
|
|
@ -94,6 +94,8 @@ if [ -z "$DOCKER_CLIENTONLY" ]; then
|
|||
DOCKER_BUILDTAGS+=" daemon"
|
||||
fi
|
||||
|
||||
rm -f dockerversion/static.go
|
||||
|
||||
# Use these flags when compiling the tests and final binary
|
||||
LDFLAGS='
|
||||
-w
|
||||
|
@ -115,7 +117,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\"
|
||||
"
|
||||
|
||||
|
|
|
@ -3,6 +3,17 @@ set -e
|
|||
|
||||
DEST=$1
|
||||
|
||||
: ${IAMSTATIC:=true}
|
||||
|
||||
cat > dockerversion/static.go <<EOF
|
||||
// AUTOGENERATED FILE; see hack/make/binary and hack/make/dynbinary
|
||||
package dockerversion
|
||||
|
||||
func init() {
|
||||
IAMSTATIC = $IAMSTATIC
|
||||
}
|
||||
EOF
|
||||
|
||||
go build \
|
||||
-o "$DEST/docker-$VERSION" \
|
||||
"${BUILDFLAGS[@]}" \
|
||||
|
|
|
@ -5,6 +5,14 @@ DEST=$1
|
|||
|
||||
if [ -z "$DOCKER_CLIENTONLY" ]; then
|
||||
# dockerinit still needs to be a static binary, even if docker is dynamic
|
||||
cat > dockerversion/static.go <<EOF
|
||||
// AUTOGENERATED FILE; see hack/make/binary and hack/make/dynbinary
|
||||
package dockerversion
|
||||
|
||||
func init() {
|
||||
IAMSTATIC = true
|
||||
}
|
||||
EOF
|
||||
go build \
|
||||
-o "$DEST/dockerinit-$VERSION" \
|
||||
"${BUILDFLAGS[@]}" \
|
||||
|
@ -40,6 +48,7 @@ fi
|
|||
|
||||
(
|
||||
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
|
||||
source "$(dirname "$BASH_SOURCE")/binary"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue