2014-01-22 05:21:56 +04:00
|
|
|
#!/usr/bin/env bash
|
2013-10-17 12:08:14 +04:00
|
|
|
set -e
|
2013-08-07 08:00:50 +04:00
|
|
|
|
2013-08-10 04:38:48 +04:00
|
|
|
# This script builds various binary artifacts from a checkout of the docker
|
|
|
|
# source code.
|
2013-08-07 08:00:50 +04:00
|
|
|
#
|
|
|
|
# Requirements:
|
2013-08-10 04:38:48 +04:00
|
|
|
# - The current directory should be a checkout of the docker source code
|
2015-04-11 20:22:16 +03:00
|
|
|
# (https://github.com/docker/docker). Whatever version is checked out
|
2013-08-10 04:38:48 +04:00
|
|
|
# will be built.
|
|
|
|
# - The VERSION file, at the root of the repository, should exist, and
|
|
|
|
# will be used as Docker binary version and package version.
|
|
|
|
# - The hash of the git commit will also be included in the Docker binary,
|
2015-12-24 20:11:49 +03:00
|
|
|
# with the suffix -unsupported if the repository isn't clean.
|
2015-12-13 19:00:39 +03:00
|
|
|
# - The script is intended to be run inside the docker container specified
|
2013-08-10 04:38:48 +04:00
|
|
|
# in the Dockerfile at the root of the source. In other words:
|
|
|
|
# DO NOT CALL THIS SCRIPT DIRECTLY.
|
2013-12-02 11:59:45 +04:00
|
|
|
# - The right way to call this script is to invoke "make" from
|
2014-02-11 03:21:20 +04:00
|
|
|
# your checkout of the Docker repository.
|
2014-01-05 08:15:15 +04:00
|
|
|
# the Makefile will do a "docker build -t docker ." and then
|
2014-05-08 17:11:17 +04:00
|
|
|
# "docker run hack/make.sh" in the resulting image.
|
2013-09-23 22:19:28 +04:00
|
|
|
#
|
2013-08-07 08:00:50 +04:00
|
|
|
|
2013-10-17 12:08:14 +04:00
|
|
|
set -o pipefail
|
2013-08-07 08:00:50 +04:00
|
|
|
|
2014-07-31 03:02:04 +04:00
|
|
|
export DOCKER_PKG='github.com/docker/docker'
|
2015-04-14 18:38:14 +03:00
|
|
|
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2015-04-14 19:43:33 +03:00
|
|
|
export MAKEDIR="$SCRIPTDIR/make"
|
2016-06-02 22:09:09 +03:00
|
|
|
export PKG_CONFIG=${PKG_CONFIG:-pkg-config}
|
2014-07-31 03:02:04 +04:00
|
|
|
|
2016-03-27 08:56:45 +03:00
|
|
|
: ${TEST_REPEAT:=0}
|
|
|
|
|
2013-08-10 04:43:02 +04:00
|
|
|
# We're a nice, sexy, little shell script, and people might try to run us;
|
|
|
|
# but really, they shouldn't. We want to be in a container!
|
2016-01-14 01:53:49 +03:00
|
|
|
inContainer="AssumeSoInitially"
|
|
|
|
if [ "$(go env GOHOSTOS)" = 'windows' ]; then
|
2016-01-24 20:22:50 +03:00
|
|
|
if [ -z "$FROM_DOCKERFILE" ]; then
|
2016-01-14 01:53:49 +03:00
|
|
|
unset inContainer
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ "$PWD" != "/go/src/$DOCKER_PKG" ] || [ -z "$DOCKER_CROSSPLATFORMS" ]; then
|
|
|
|
unset inContainer
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2016-01-24 12:28:18 +03:00
|
|
|
if [ -z "$inContainer" ]; then
|
2014-01-25 10:01:12 +04:00
|
|
|
{
|
2016-01-14 01:53:49 +03:00
|
|
|
echo "# WARNING! I don't seem to be running in a Docker container."
|
2014-01-25 10:01:12 +04:00
|
|
|
echo "# The result of this command might be an incorrect build, and will not be"
|
2016-01-14 01:53:49 +03:00
|
|
|
echo "# officially supported."
|
2014-01-25 10:01:12 +04:00
|
|
|
echo "#"
|
|
|
|
echo "# Try this instead: make all"
|
|
|
|
echo "#"
|
|
|
|
} >&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
2013-08-10 04:43:02 +04:00
|
|
|
|
2013-09-10 05:45:40 +04:00
|
|
|
# List of bundles to create when no argument is passed
|
|
|
|
DEFAULT_BUNDLES=(
|
2014-04-04 10:37:50 +04:00
|
|
|
validate-dco
|
2016-02-08 21:52:53 +03:00
|
|
|
validate-default-seccomp
|
2014-04-04 10:37:50 +04:00
|
|
|
validate-gofmt
|
2015-07-23 01:19:32 +03:00
|
|
|
validate-lint
|
2015-06-12 22:19:56 +03:00
|
|
|
validate-pkg
|
2015-04-22 21:20:32 +03:00
|
|
|
validate-test
|
2015-01-30 22:45:02 +03:00
|
|
|
validate-toml
|
2015-04-01 07:48:03 +03:00
|
|
|
validate-vet
|
2014-07-03 22:29:07 +04:00
|
|
|
|
2016-02-20 01:42:51 +03:00
|
|
|
binary-client
|
|
|
|
binary-daemon
|
2015-11-06 10:35:47 +03:00
|
|
|
dynbinary
|
2014-07-03 22:29:07 +04:00
|
|
|
|
2014-04-30 02:49:03 +04:00
|
|
|
test-unit
|
2014-03-31 21:55:55 +04:00
|
|
|
test-integration-cli
|
2014-12-19 10:20:59 +03:00
|
|
|
test-docker-py
|
2014-07-03 22:29:07 +04:00
|
|
|
|
2013-12-09 07:20:55 +04:00
|
|
|
cover
|
2013-12-19 10:06:14 +04:00
|
|
|
cross
|
2013-11-18 07:25:08 +04:00
|
|
|
tgz
|
2013-09-10 05:45:40 +04:00
|
|
|
)
|
|
|
|
|
2015-04-14 19:31:52 +03:00
|
|
|
VERSION=$(< ./VERSION)
|
2016-04-14 18:29:12 +03:00
|
|
|
if command -v git &> /dev/null && [ -d .git ] && git rev-parse &> /dev/null; then
|
2013-11-22 02:11:17 +04:00
|
|
|
GITCOMMIT=$(git rev-parse --short HEAD)
|
2014-02-11 00:44:34 +04:00
|
|
|
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
|
2015-12-24 20:11:49 +03:00
|
|
|
GITCOMMIT="$GITCOMMIT-unsupported"
|
2016-03-25 17:09:03 +03:00
|
|
|
echo "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
|
|
|
echo "# GITCOMMIT = $GITCOMMIT"
|
|
|
|
echo "# The version you are building is listed as unsupported because"
|
|
|
|
echo "# there are some files in the git repository that are in an uncommited state."
|
|
|
|
echo "# Commit these changes, or add to .gitignore to remove the -unsupported from the version."
|
|
|
|
echo "# Here is the current list:"
|
|
|
|
git status --porcelain --untracked-files=no
|
|
|
|
echo "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
2013-11-22 02:11:17 +04:00
|
|
|
fi
|
2016-03-26 02:38:00 +03:00
|
|
|
! BUILDTIME=$(date --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/') &> /dev/null
|
2015-12-03 21:12:11 +03:00
|
|
|
if [ -z $BUILDTIME ]; then
|
|
|
|
# If using bash 3.1 which doesn't support --rfc-3389, eg Windows CI
|
|
|
|
BUILDTIME=$(date -u)
|
|
|
|
fi
|
2013-11-22 02:11:17 +04:00
|
|
|
elif [ "$DOCKER_GITCOMMIT" ]; then
|
|
|
|
GITCOMMIT="$DOCKER_GITCOMMIT"
|
|
|
|
else
|
|
|
|
echo >&2 'error: .git directory missing and DOCKER_GITCOMMIT not specified'
|
|
|
|
echo >&2 ' Please either build with the .git directory accessible, or specify the'
|
|
|
|
echo >&2 ' exact (--short) commit hash you are building using DOCKER_GITCOMMIT for'
|
|
|
|
echo >&2 ' future accountability in diagnosing build issues. Thanks!'
|
|
|
|
exit 1
|
2013-08-15 05:01:13 +04:00
|
|
|
fi
|
2013-08-07 08:00:50 +04:00
|
|
|
|
2014-02-10 05:21:01 +04:00
|
|
|
if [ "$AUTO_GOPATH" ]; then
|
|
|
|
rm -rf .gopath
|
2014-07-31 03:02:04 +04:00
|
|
|
mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
|
|
|
|
ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
|
2015-04-14 18:21:12 +03:00
|
|
|
export GOPATH="${PWD}/.gopath:${PWD}/vendor"
|
2016-03-26 02:38:00 +03:00
|
|
|
|
|
|
|
if [ "$(go env GOOS)" = 'solaris' ]; then
|
|
|
|
# sys/unix is installed outside the standard library on solaris
|
|
|
|
# TODO need to allow for version change, need to get version from go
|
2016-07-18 12:52:27 +03:00
|
|
|
export GO_VERSION=${GO_VERSION:-"1.6.3"}
|
|
|
|
export GOPATH="${GOPATH}:/usr/lib/gocode/${GO_VERSION}"
|
2016-03-26 02:38:00 +03:00
|
|
|
fi
|
2014-02-10 05:21:01 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! "$GOPATH" ]; then
|
2015-04-11 20:22:16 +03:00
|
|
|
echo >&2 'error: missing GOPATH; please see https://golang.org/doc/code.html#GOPATH'
|
2014-02-10 05:21:01 +04:00
|
|
|
echo >&2 ' alternatively, set AUTO_GOPATH=1'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-01-08 06:43:11 +03:00
|
|
|
if [ "$DOCKER_EXPERIMENTAL" ]; then
|
2015-05-20 01:09:58 +03:00
|
|
|
echo >&2 '# WARNING! DOCKER_EXPERIMENTAL is set: building experimental features'
|
|
|
|
echo >&2
|
2016-03-28 21:36:20 +03:00
|
|
|
DOCKER_BUILDTAGS+=" experimental"
|
2015-05-20 01:09:58 +03:00
|
|
|
fi
|
|
|
|
|
2016-04-27 20:08:20 +03:00
|
|
|
DOCKER_BUILDTAGS+=" daemon"
|
2016-06-02 22:09:09 +03:00
|
|
|
if ${PKG_CONFIG} 'libsystemd >= 209' 2> /dev/null ; then
|
2016-02-20 01:42:51 +03:00
|
|
|
DOCKER_BUILDTAGS+=" journald"
|
2016-06-02 22:09:09 +03:00
|
|
|
elif ${PKG_CONFIG} 'libsystemd-journal' 2> /dev/null ; then
|
2016-02-20 01:42:51 +03:00
|
|
|
DOCKER_BUILDTAGS+=" journald journald_compat"
|
2014-08-01 21:34:06 +04:00
|
|
|
fi
|
|
|
|
|
2015-04-03 10:30:12 +03:00
|
|
|
# test whether "btrfs/version.h" exists and apply btrfs_noversion appropriately
|
|
|
|
if \
|
|
|
|
command -v gcc &> /dev/null \
|
2015-11-17 20:44:36 +03:00
|
|
|
&& ! gcc -E - -o /dev/null &> /dev/null <<<'#include <btrfs/version.h>' \
|
2015-04-03 10:30:12 +03:00
|
|
|
; then
|
|
|
|
DOCKER_BUILDTAGS+=' btrfs_noversion'
|
|
|
|
fi
|
|
|
|
|
2015-04-22 01:14:59 +03:00
|
|
|
# test whether "libdevmapper.h" is new enough to support deferred remove
|
|
|
|
# functionality.
|
|
|
|
if \
|
|
|
|
command -v gcc &> /dev/null \
|
2016-03-11 23:08:58 +03:00
|
|
|
&& ! ( echo -e '#include <libdevmapper.h>\nint main() { dm_task_deferred_remove(NULL); }'| gcc -xc - -o /dev/null -ldevmapper &> /dev/null ) \
|
2015-04-22 01:14:59 +03:00
|
|
|
; then
|
|
|
|
DOCKER_BUILDTAGS+=' libdm_no_deferred_remove'
|
|
|
|
fi
|
|
|
|
|
2013-09-10 03:20:30 +04:00
|
|
|
# Use these flags when compiling the tests and final binary
|
2014-11-20 20:56:54 +03:00
|
|
|
|
2015-02-05 00:22:38 +03:00
|
|
|
IAMSTATIC='true'
|
2015-04-14 18:38:14 +03:00
|
|
|
source "$SCRIPTDIR/make/.go-autogen"
|
2015-05-07 15:22:44 +03:00
|
|
|
if [ -z "$DOCKER_DEBUG" ]; then
|
|
|
|
LDFLAGS='-w'
|
|
|
|
fi
|
2014-11-20 20:56:54 +03:00
|
|
|
|
2015-11-16 01:47:48 +03:00
|
|
|
LDFLAGS_STATIC=''
|
2014-03-07 06:55:22 +04:00
|
|
|
EXTLDFLAGS_STATIC='-static'
|
2014-09-25 22:22:24 +04:00
|
|
|
# ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
|
|
|
|
# with options like -race.
|
2016-01-05 05:46:04 +03:00
|
|
|
ORIG_BUILDFLAGS=( -tags "autogen netgo static_build sqlite_omit_load_extension $DOCKER_BUILDTAGS" -installsuffix netgo )
|
2015-01-17 08:00:44 +03:00
|
|
|
# see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
|
2016-01-05 05:46:04 +03:00
|
|
|
|
|
|
|
# When $DOCKER_INCREMENTAL_BINARY is set in the environment, enable incremental
|
|
|
|
# builds by installing dependent packages to the GOPATH.
|
|
|
|
REBUILD_FLAG="-a"
|
|
|
|
if [ "$DOCKER_INCREMENTAL_BINARY" ]; then
|
|
|
|
REBUILD_FLAG="-i"
|
|
|
|
fi
|
|
|
|
ORIG_BUILDFLAGS+=( $REBUILD_FLAG )
|
|
|
|
|
2014-09-25 22:22:24 +04:00
|
|
|
BUILDFLAGS=( $BUILDFLAGS "${ORIG_BUILDFLAGS[@]}" )
|
|
|
|
# Test timeout.
|
2016-01-20 09:30:54 +03:00
|
|
|
|
|
|
|
if [ "${DOCKER_ENGINE_GOARCH}" == "arm" ]; then
|
2016-03-11 22:06:56 +03:00
|
|
|
: ${TIMEOUT:=10m}
|
2016-03-04 20:32:30 +03:00
|
|
|
elif [ "${DOCKER_ENGINE_GOARCH}" == "windows" ]; then
|
2016-03-11 22:06:56 +03:00
|
|
|
: ${TIMEOUT:=8m}
|
2016-01-20 09:30:54 +03:00
|
|
|
else
|
2016-03-11 22:06:56 +03:00
|
|
|
: ${TIMEOUT:=5m}
|
2016-01-20 09:30:54 +03:00
|
|
|
fi
|
|
|
|
|
2014-03-07 06:55:22 +04:00
|
|
|
LDFLAGS_STATIC_DOCKER="
|
|
|
|
$LDFLAGS_STATIC
|
2015-09-08 21:29:43 +03:00
|
|
|
-extldflags \"$EXTLDFLAGS_STATIC\"
|
2014-03-07 06:55:22 +04:00
|
|
|
"
|
|
|
|
|
2014-03-01 02:45:56 +04:00
|
|
|
if [ "$(uname -s)" = 'FreeBSD' ]; then
|
|
|
|
# Tell cgo the compiler is Clang, not GCC
|
|
|
|
# https://code.google.com/p/go/source/browse/src/cmd/cgo/gcc.go?spec=svne77e74371f2340ee08622ce602e9f7b15f29d8d3&r=e6794866ebeba2bf8818b9261b54e2eef1c9e588#752
|
|
|
|
export CC=clang
|
|
|
|
|
|
|
|
# "-extld clang" is a workaround for
|
|
|
|
# https://code.google.com/p/go/issues/detail?id=6845
|
|
|
|
LDFLAGS="$LDFLAGS -extld clang"
|
|
|
|
fi
|
|
|
|
|
2014-04-16 19:41:19 +04:00
|
|
|
# If sqlite3.h doesn't exist under /usr/include,
|
|
|
|
# check /usr/local/include also just in case
|
|
|
|
# (e.g. FreeBSD Ports installs it under the directory)
|
|
|
|
if [ ! -e /usr/include/sqlite3.h ] && [ -e /usr/local/include/sqlite3.h ]; then
|
|
|
|
export CGO_CFLAGS='-I/usr/local/include'
|
|
|
|
export CGO_LDFLAGS='-L/usr/local/lib'
|
|
|
|
fi
|
|
|
|
|
2013-12-09 07:20:55 +04:00
|
|
|
HAVE_GO_TEST_COVER=
|
2013-12-17 09:54:06 +04:00
|
|
|
if \
|
2013-12-31 05:58:25 +04:00
|
|
|
go help testflag | grep -- -cover > /dev/null \
|
2013-12-17 09:54:06 +04:00
|
|
|
&& go tool -n cover > /dev/null 2>&1 \
|
|
|
|
; then
|
2013-12-09 07:20:55 +04:00
|
|
|
HAVE_GO_TEST_COVER=1
|
|
|
|
fi
|
|
|
|
|
2013-12-09 00:49:57 +04:00
|
|
|
# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'.
|
|
|
|
# You can use this to select certain tests to run, eg.
|
|
|
|
#
|
2015-04-30 10:40:48 +03:00
|
|
|
# TESTFLAGS='-test.run ^TestBuild$' ./hack/make.sh test-unit
|
|
|
|
#
|
|
|
|
# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want
|
|
|
|
# to run certain tests on your local host, you should run with command:
|
|
|
|
#
|
|
|
|
# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration-cli
|
2013-12-09 00:49:57 +04:00
|
|
|
#
|
|
|
|
go_test_dir() {
|
|
|
|
dir=$1
|
2014-02-11 03:21:20 +04:00
|
|
|
coverpkg=$2
|
2013-12-09 07:20:55 +04:00
|
|
|
testcover=()
|
2016-03-27 08:56:45 +03:00
|
|
|
testcoverprofile=()
|
|
|
|
testbinary="$DEST/test.main"
|
2013-12-09 07:20:55 +04:00
|
|
|
if [ "$HAVE_GO_TEST_COVER" ]; then
|
|
|
|
# if our current go install has -cover, we want to use it :)
|
|
|
|
mkdir -p "$DEST/coverprofiles"
|
|
|
|
coverprofile="docker${dir#.}"
|
2015-05-29 23:07:16 +03:00
|
|
|
coverprofile="$ABS_DEST/coverprofiles/${coverprofile//\//-}"
|
2016-03-27 08:56:45 +03:00
|
|
|
testcover=( -test.cover )
|
|
|
|
testcoverprofile=( -test.coverprofile "$coverprofile" $coverpkg )
|
2013-12-09 07:20:55 +04:00
|
|
|
fi
|
2013-12-09 00:49:57 +04:00
|
|
|
(
|
2014-07-31 03:02:04 +04:00
|
|
|
echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}"
|
2013-12-09 00:49:57 +04:00
|
|
|
cd "$dir"
|
2015-05-29 23:07:16 +03:00
|
|
|
export DEST="$ABS_DEST" # we're in a subshell, so this is safe -- our integration-cli tests need DEST, and "cd" screws it up
|
2016-03-27 08:56:45 +03:00
|
|
|
go test -c -o "$testbinary" ${testcover[@]} -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}"
|
|
|
|
i=0
|
|
|
|
while ((++i)); do
|
|
|
|
test_env "$testbinary" ${testcoverprofile[@]} $TESTFLAGS
|
|
|
|
if [ $i -gt "$TEST_REPEAT" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
echo "Repeating test ($i)"
|
|
|
|
done
|
2013-12-09 00:49:57 +04:00
|
|
|
)
|
|
|
|
}
|
2015-02-14 13:27:31 +03:00
|
|
|
test_env() {
|
|
|
|
# use "env -i" to tightly control the environment variables that bleed into the tests
|
|
|
|
env -i \
|
|
|
|
DEST="$DEST" \
|
2016-02-25 01:59:11 +03:00
|
|
|
DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \
|
|
|
|
DOCKER_CERT_PATH="$DOCKER_TEST_CERT_PATH" \
|
2016-01-19 23:23:46 +03:00
|
|
|
DOCKER_ENGINE_GOARCH="$DOCKER_ENGINE_GOARCH" \
|
2015-02-14 13:27:31 +03:00
|
|
|
DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \
|
2015-04-08 02:53:39 +03:00
|
|
|
DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \
|
2015-02-14 13:27:31 +03:00
|
|
|
DOCKER_HOST="$DOCKER_HOST" \
|
2015-10-10 05:09:02 +03:00
|
|
|
DOCKER_REMAP_ROOT="$DOCKER_REMAP_ROOT" \
|
2015-08-05 19:21:45 +03:00
|
|
|
DOCKER_REMOTE_DAEMON="$DOCKER_REMOTE_DAEMON" \
|
2015-02-14 13:27:31 +03:00
|
|
|
GOPATH="$GOPATH" \
|
2016-03-11 22:06:56 +03:00
|
|
|
GOTRACEBACK=all \
|
2015-05-29 23:07:16 +03:00
|
|
|
HOME="$ABS_DEST/fake-HOME" \
|
2015-02-14 13:27:31 +03:00
|
|
|
PATH="$PATH" \
|
2015-05-23 01:14:22 +03:00
|
|
|
TEMP="$TEMP" \
|
2015-02-14 13:27:31 +03:00
|
|
|
"$@"
|
|
|
|
}
|
2013-12-09 00:49:57 +04:00
|
|
|
|
2015-01-10 03:28:40 +03:00
|
|
|
# a helper to provide ".exe" when it's appropriate
|
|
|
|
binary_extension() {
|
|
|
|
if [ "$(go env GOOS)" = 'windows' ]; then
|
|
|
|
echo -n '.exe'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-03-20 05:58:39 +04:00
|
|
|
hash_files() {
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
f="$1"
|
|
|
|
shift
|
|
|
|
dir="$(dirname "$f")"
|
|
|
|
base="$(basename "$f")"
|
|
|
|
for hashAlgo in md5 sha256; do
|
|
|
|
if command -v "${hashAlgo}sum" &> /dev/null; then
|
|
|
|
(
|
|
|
|
# subshell and cd so that we get output files like:
|
|
|
|
# $HASH docker-$VERSION
|
|
|
|
# instead of:
|
|
|
|
# $HASH /go/src/github.com/.../$VERSION/binary/docker-$VERSION
|
|
|
|
cd "$dir"
|
|
|
|
"${hashAlgo}sum" "$base" > "$base.$hashAlgo"
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-09-10 05:45:40 +04:00
|
|
|
bundle() {
|
2015-05-29 23:07:16 +03:00
|
|
|
local bundle="$1"; shift
|
|
|
|
echo "---> Making bundle: $(basename "$bundle") (in $DEST)"
|
|
|
|
source "$SCRIPTDIR/make/$bundle" "$@"
|
2013-08-07 08:00:50 +04:00
|
|
|
}
|
|
|
|
|
2016-03-22 21:49:01 +03:00
|
|
|
copy_containerd() {
|
2016-03-23 21:02:38 +03:00
|
|
|
dir="$1"
|
|
|
|
# Add nested executables to bundle dir so we have complete set of
|
|
|
|
# them available, but only if the native OS/ARCH is the same as the
|
|
|
|
# OS/ARCH of the build target
|
|
|
|
if [ "$(go env GOOS)/$(go env GOARCH)" == "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then
|
|
|
|
if [ -x /usr/local/bin/docker-runc ]; then
|
|
|
|
echo "Copying nested executables into $dir"
|
|
|
|
for file in containerd containerd-shim containerd-ctr runc; do
|
2016-04-11 22:02:01 +03:00
|
|
|
cp `which "docker-$file"` "$dir/"
|
2016-03-23 21:02:38 +03:00
|
|
|
if [ "$2" == "hash" ]; then
|
|
|
|
hash_files "$dir/docker-$file"
|
|
|
|
fi
|
|
|
|
done
|
2016-03-23 03:55:47 +03:00
|
|
|
fi
|
2016-03-23 21:02:38 +03:00
|
|
|
fi
|
2016-03-22 21:49:01 +03:00
|
|
|
}
|
|
|
|
|
2016-05-24 04:44:43 +03:00
|
|
|
install_binary() {
|
|
|
|
file="$1"
|
|
|
|
target="${DOCKER_MAKE_INSTALL_PREFIX:=/usr/local}/bin/"
|
|
|
|
if [ "$(go env GOOS)" == "linux" ]; then
|
|
|
|
echo "Installing $(basename $file) to ${target}"
|
|
|
|
cp -L "$file" "$target"
|
|
|
|
else
|
|
|
|
echo "Install is only supported on linux"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-07 08:00:50 +04:00
|
|
|
main() {
|
2013-09-23 22:19:28 +04:00
|
|
|
# We want this to fail if the bundles already exist and cannot be removed.
|
2013-09-10 05:45:40 +04:00
|
|
|
# This is to avoid mixing bundles from different versions of the code.
|
|
|
|
mkdir -p bundles
|
2015-11-05 04:17:37 +03:00
|
|
|
if [ -e "bundles/$VERSION" ] && [ -z "$KEEPBUNDLE" ]; then
|
2013-09-10 05:45:40 +04:00
|
|
|
echo "bundles/$VERSION already exists. Removing."
|
2015-04-14 19:08:08 +03:00
|
|
|
rm -fr "bundles/$VERSION" && mkdir "bundles/$VERSION" || exit 1
|
2013-09-23 22:19:28 +04:00
|
|
|
echo
|
2013-09-10 05:45:40 +04:00
|
|
|
fi
|
2015-04-03 11:07:57 +03:00
|
|
|
|
|
|
|
if [ "$(go env GOHOSTOS)" != 'windows' ]; then
|
|
|
|
# Windows and symlinks don't get along well
|
2015-05-26 15:54:08 +03:00
|
|
|
|
2015-05-27 10:21:09 +03:00
|
|
|
rm -f bundles/latest
|
|
|
|
ln -s "$VERSION" bundles/latest
|
2015-04-03 11:07:57 +03:00
|
|
|
fi
|
|
|
|
|
2013-09-10 05:45:40 +04:00
|
|
|
if [ $# -lt 1 ]; then
|
2013-10-18 07:33:34 +04:00
|
|
|
bundles=(${DEFAULT_BUNDLES[@]})
|
2013-09-10 05:45:40 +04:00
|
|
|
else
|
|
|
|
bundles=($@)
|
|
|
|
fi
|
|
|
|
for bundle in ${bundles[@]}; do
|
2015-05-29 23:07:16 +03:00
|
|
|
export DEST="bundles/$VERSION/$(basename "$bundle")"
|
|
|
|
# Cygdrive paths don't play well with go build -o.
|
|
|
|
if [[ "$(uname -s)" == CYGWIN* ]]; then
|
|
|
|
export DEST="$(cygpath -mw "$DEST")"
|
|
|
|
fi
|
|
|
|
mkdir -p "$DEST"
|
|
|
|
ABS_DEST="$(cd "$DEST" && pwd -P)"
|
|
|
|
bundle "$bundle"
|
2013-09-23 22:19:28 +04:00
|
|
|
echo
|
2013-09-10 05:45:40 +04:00
|
|
|
done
|
2013-08-07 08:00:50 +04:00
|
|
|
}
|
|
|
|
|
2013-09-10 05:45:40 +04:00
|
|
|
main "$@"
|