2013-12-02 17:48:26 -05:00
|
|
|
#!/bin/bash
|
2014-04-08 00:14:19 -04:00
|
|
|
set -e
|
2013-10-18 01:40:41 -04:00
|
|
|
|
|
|
|
DEST=$1
|
|
|
|
|
2014-03-06 23:22:25 -05:00
|
|
|
if [ -z "$DOCKER_CLIENTONLY" ]; then
|
|
|
|
# dockerinit still needs to be a static binary, even if docker is dynamic
|
|
|
|
go build \
|
2014-03-19 21:58:39 -04:00
|
|
|
-o "$DEST/dockerinit-$VERSION" \
|
2014-03-06 23:22:25 -05:00
|
|
|
"${BUILDFLAGS[@]}" \
|
|
|
|
-ldflags "
|
|
|
|
$LDFLAGS
|
|
|
|
$LDFLAGS_STATIC
|
|
|
|
-extldflags \"$EXTLDFLAGS_STATIC\"
|
|
|
|
" \
|
|
|
|
./dockerinit
|
|
|
|
echo "Created binary: $DEST/dockerinit-$VERSION"
|
2014-03-19 21:58:39 -04:00
|
|
|
ln -sf "dockerinit-$VERSION" "$DEST/dockerinit"
|
|
|
|
|
|
|
|
hash_files "$DEST/dockerinit-$VERSION"
|
2014-03-06 23:22:25 -05:00
|
|
|
|
|
|
|
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)"
|
2014-02-13 12:07:53 -05:00
|
|
|
else
|
2014-03-06 23:22:25 -05:00
|
|
|
# DOCKER_CLIENTONLY must be truthy, so we don't need to bother with dockerinit :)
|
|
|
|
export DOCKER_INITSHA1=""
|
2014-02-13 12:07:53 -05:00
|
|
|
fi
|
2013-10-18 01:40:41 -04:00
|
|
|
# exported so that "dyntest" can easily access it later without recalculating it
|
|
|
|
|
2013-12-08 20:40:05 -05:00
|
|
|
(
|
2014-03-06 21:55:22 -05:00
|
|
|
export LDFLAGS_STATIC_DOCKER="-X github.com/dotcloud/docker/dockerversion.INITSHA1 \"$DOCKER_INITSHA1\" -X github.com/dotcloud/docker/dockerversion.INITPATH \"$DOCKER_INITPATH\""
|
2014-06-19 16:35:30 -04:00
|
|
|
export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
|
2013-12-08 20:40:05 -05:00
|
|
|
source "$(dirname "$BASH_SOURCE")/binary"
|
|
|
|
)
|