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

Merge pull request #10155 from tianon/netgo-take-three

Let's try fixing "netgo" again
This commit is contained in:
Alexander Morozov 2015-01-20 09:45:42 -08:00
commit b2fe1b3dd9
8 changed files with 46 additions and 72 deletions

View file

@ -97,9 +97,6 @@ RUN cd /usr/local/go/src \
./make.bash --no-clean 2>&1; \ ./make.bash --no-clean 2>&1; \
done done
# Reinstall standard library with netgo
RUN go clean -i net && go install -tags netgo std
# We still support compiling with older Go, so need to grab older "gofmt" # We still support compiling with older Go, so need to grab older "gofmt"
ENV GOFMT_VERSION 1.3.3 ENV GOFMT_VERSION 1.3.3
RUN curl -sSL https://storage.googleapis.com/golang/go${GOFMT_VERSION}.$(go env GOOS)-$(go env GOARCH).tar.gz | tar -C /go/bin -xz --strip-components=2 go/bin/gofmt RUN curl -sSL https://storage.googleapis.com/golang/go${GOFMT_VERSION}.$(go env GOOS)-$(go env GOARCH).tar.gz | tar -C /go/bin -xz --strip-components=2 go/bin/gofmt

View file

@ -48,13 +48,11 @@ DEFAULT_BUNDLES=(
binary binary
test-unit test-unit
test-integration
test-integration-cli test-integration-cli
test-docker-py test-docker-py
dynbinary dynbinary
dyntest-unit test-integration
dyntest-integration
cover cover
cross cross
@ -113,7 +111,8 @@ fi
EXTLDFLAGS_STATIC='-static' EXTLDFLAGS_STATIC='-static'
# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build # ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
# with options like -race. # with options like -race.
ORIG_BUILDFLAGS=( -a -tags "netgo static_build $DOCKER_BUILDTAGS" ) ORIG_BUILDFLAGS=( -a -tags "netgo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
# see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
BUILDFLAGS=( $BUILDFLAGS "${ORIG_BUILDFLAGS[@]}" ) BUILDFLAGS=( $BUILDFLAGS "${ORIG_BUILDFLAGS[@]}" )
# Test timeout. # Test timeout.
: ${TIMEOUT:=30m} : ${TIMEOUT:=30m}

29
project/make/.dockerinit Normal file
View file

@ -0,0 +1,29 @@
#!/bin/bash
set -e
# dockerinit still needs to be a static binary, even if docker is dynamic
go build \
-o "$DEST/dockerinit-$VERSION" \
"${BUILDFLAGS[@]}" \
-ldflags "
$LDFLAGS
$LDFLAGS_STATIC
-extldflags \"$EXTLDFLAGS_STATIC\"
" \
./dockerinit
echo "Created binary: $DEST/dockerinit-$VERSION"
ln -sf "dockerinit-$VERSION" "$DEST/dockerinit"
sha1sum=
if command -v sha1sum &> /dev/null; then
sha1sum=sha1sum
elif command -v shasum &> /dev/null; then
# Mac OS X - why couldn't they just use the same command name and be happy?
sha1sum=shasum
else
echo >&2 'error: cannot find sha1sum command or equivalent'
exit 1
fi
# sha1 our new dockerinit to ensure separate docker and dockerinit always run in a perfect pair compiled for one another
export DOCKER_INITSHA1="$($sha1sum $DEST/dockerinit-$VERSION | cut -d' ' -f1)"

View file

@ -4,39 +4,14 @@ set -e
DEST=$1 DEST=$1
if [ -z "$DOCKER_CLIENTONLY" ]; then if [ -z "$DOCKER_CLIENTONLY" ]; then
# dockerinit still needs to be a static binary, even if docker is dynamic source "$(dirname "$BASH_SOURCE")/.dockerinit"
go build \
-o "$DEST/dockerinit-$VERSION" \
"${BUILDFLAGS[@]}" \
-ldflags "
$LDFLAGS
$LDFLAGS_STATIC
-extldflags \"$EXTLDFLAGS_STATIC\"
" \
./dockerinit
echo "Created binary: $DEST/dockerinit-$VERSION"
ln -sf "dockerinit-$VERSION" "$DEST/dockerinit"
hash_files "$DEST/dockerinit-$VERSION" hash_files "$DEST/dockerinit-$VERSION"
sha1sum=
if command -v sha1sum &> /dev/null; then
sha1sum=sha1sum
elif command -v shasum &> /dev/null; then
# Mac OS X - why couldn't they just use the same command name and be happy?
sha1sum=shasum
else
echo >&2 'error: cannot find sha1sum command or equivalent'
exit 1
fi
# sha1 our new dockerinit to ensure separate docker and dockerinit always run in a perfect pair compiled for one another
export DOCKER_INITSHA1="$($sha1sum $DEST/dockerinit-$VERSION | cut -d' ' -f1)"
else else
# DOCKER_CLIENTONLY must be truthy, so we don't need to bother with dockerinit :) # DOCKER_CLIENTONLY must be truthy, so we don't need to bother with dockerinit :)
export DOCKER_INITSHA1="" export DOCKER_INITSHA1=""
fi fi
# exported so that "dyntest" 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 LDFLAGS_STATIC_DOCKER="-X $DOCKER_PKG/dockerversion.INITSHA1 \"$DOCKER_INITSHA1\" -X $DOCKER_PKG/dockerversion.INITPATH \"$DOCKER_INITPATH\""

View file

@ -1,18 +0,0 @@
#!/bin/bash
set -e
DEST=$1
INIT=$DEST/../dynbinary/dockerinit-$VERSION
if [ ! -x "$INIT" ]; then
echo >&2 'error: dynbinary must be run before dyntest-integration'
false
fi
(
export TEST_DOCKERINIT_PATH="$INIT"
export LDFLAGS_STATIC_DOCKER="
-X $DOCKER_PKG/dockerversion.INITSHA1 \"$DOCKER_INITSHA1\"
"
source "$(dirname "$BASH_SOURCE")/test-integration"
)

View file

@ -1,18 +0,0 @@
#!/bin/bash
set -e
DEST=$1
INIT=$DEST/../dynbinary/dockerinit-$VERSION
if [ ! -x "$INIT" ]; then
echo >&2 'error: dynbinary must be run before dyntest-unit'
false
fi
(
export TEST_DOCKERINIT_PATH="$INIT"
export LDFLAGS_STATIC_DOCKER="
-X $DOCKER_PKG/dockerversion.INITSHA1 \"$DOCKER_INITSHA1\"
"
source "$(dirname "$BASH_SOURCE")/test-unit"
)

View file

@ -3,8 +3,18 @@ set -e
DEST=$1 DEST=$1
INIT=$DEST/../dynbinary/dockerinit-$VERSION
[ -x "$INIT" ] || {
source "$(dirname "$BASH_SOURCE")/.dockerinit"
INIT="$DEST/dockerinit"
}
export TEST_DOCKERINIT_PATH="$INIT"
bundle_test_integration() { bundle_test_integration() {
LDFLAGS="$LDFLAGS $LDFLAGS_STATIC_DOCKER" go_test_dir ./integration \ LDFLAGS="
$LDFLAGS
-X $DOCKER_PKG/dockerversion.INITSHA1 \"$DOCKER_INITSHA1\"
" go_test_dir ./integration \
"-coverpkg $(find_dirs '*.go' | sed 's,^\.,'$DOCKER_PKG',g' | paste -d, -s)" "-coverpkg $(find_dirs '*.go' | sed 's,^\.,'$DOCKER_PKG',g' | paste -d, -s)"
} }

View file

@ -23,7 +23,7 @@ bundle_test_unit() {
TESTDIRS=$(find_dirs '*_test.go') TESTDIRS=$(find_dirs '*_test.go')
fi fi
( (
export LDFLAGS="$LDFLAGS $LDFLAGS_STATIC_DOCKER" export LDFLAGS
export TESTFLAGS export TESTFLAGS
export HAVE_GO_TEST_COVER export HAVE_GO_TEST_COVER
export DEST export DEST