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
|
2014-09-30 20:37:30 -04:00
|
|
|
cat > dockerversion/static.go <<EOF
|
|
|
|
// AUTOGENERATED FILE; see hack/make/binary and hack/make/dynbinary
|
|
|
|
package dockerversion
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
IAMSTATIC = true
|
|
|
|
}
|
|
|
|
EOF
|
2014-03-06 23:22:25 -05:00
|
|
|
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-10-07 22:31:43 -04:00
|
|
|
export LDFLAGS_STATIC_DOCKER=""
|
|
|
|
cat > dockerversion/init.go <<EOF
|
|
|
|
// AUTOGENERATED FILE; see hack/make/dynbinary, hack/make/dyntest-integration and dyntest-unit
|
|
|
|
package dockerversion
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
INITSHA1 = "$DOCKER_INITSHA1"
|
|
|
|
INITPATH = "$DOCKER_INITPATH"
|
|
|
|
}
|
|
|
|
EOF
|
2014-09-30 20:37:30 -04:00
|
|
|
export IAMSTATIC=false
|
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"
|
|
|
|
)
|