2016-01-05 00:50:15 -05:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2016-03-10 22:19:33 -05:00
|
|
|
docker-version-osarch() {
|
|
|
|
local target="$1" # "Client" or "Server"
|
|
|
|
local fmtStr="{{.${target}.Os}}/{{.${target}.Arch}}"
|
|
|
|
if docker version -f "$fmtStr" 2>/dev/null; then
|
|
|
|
# if "docker version -f" works, let's just use that!
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
docker version | awk '
|
|
|
|
$1 ~ /^(Client|Server):$/ { section = 0 }
|
|
|
|
$1 == "'"$target"':" { section = 1; next }
|
|
|
|
section && $1 == "OS/Arch:" { print $2 }
|
2016-03-14 12:30:45 -04:00
|
|
|
|
|
|
|
# old versions of Docker
|
|
|
|
$1 == "OS/Arch" && $2 == "('"${target,,}"'):" { print $3 }
|
2016-03-10 22:19:33 -05:00
|
|
|
'
|
|
|
|
}
|
|
|
|
|
2016-09-21 01:48:06 -04:00
|
|
|
# Retrieve OS/ARCH of docker daemon, e.g. linux/amd64
|
2016-03-10 22:19:33 -05:00
|
|
|
export DOCKER_ENGINE_OSARCH="$(docker-version-osarch 'Server')"
|
2016-01-05 00:50:15 -05:00
|
|
|
export DOCKER_ENGINE_GOOS="${DOCKER_ENGINE_OSARCH%/*}"
|
|
|
|
export DOCKER_ENGINE_GOARCH="${DOCKER_ENGINE_OSARCH##*/}"
|
2015-11-23 14:00:43 -05:00
|
|
|
DOCKER_ENGINE_GOARCH=${DOCKER_ENGINE_GOARCH:=amd64}
|
2016-01-05 00:50:15 -05:00
|
|
|
|
|
|
|
# and the client, just in case
|
2016-03-10 22:19:33 -05:00
|
|
|
export DOCKER_CLIENT_OSARCH="$(docker-version-osarch 'Client')"
|
|
|
|
export DOCKER_CLIENT_GOOS="${DOCKER_CLIENT_OSARCH%/*}"
|
|
|
|
export DOCKER_CLIENT_GOARCH="${DOCKER_CLIENT_OSARCH##*/}"
|
|
|
|
DOCKER_CLIENT_GOARCH=${DOCKER_CLIENT_GOARCH:=amd64}
|
2015-11-23 14:00:43 -05:00
|
|
|
|
|
|
|
# Retrieve the architecture used in contrib/builder/(deb|rpm)/$PACKAGE_ARCH/
|
2016-03-10 22:19:33 -05:00
|
|
|
PACKAGE_ARCH='amd64'
|
|
|
|
case "${DOCKER_ENGINE_GOARCH:-$DOCKER_CLIENT_GOARCH}" in
|
|
|
|
arm)
|
2015-11-23 14:00:43 -05:00
|
|
|
PACKAGE_ARCH='armhf'
|
|
|
|
;;
|
2016-03-10 22:19:33 -05:00
|
|
|
arm64)
|
|
|
|
PACKAGE_ARCH='aarch64'
|
|
|
|
;;
|
|
|
|
amd64|ppc64le|s390x)
|
|
|
|
PACKAGE_ARCH="${DOCKER_ENGINE_GOARCH:-$DOCKER_CLIENT_GOARCH}"
|
2015-11-23 14:00:43 -05:00
|
|
|
;;
|
2016-03-10 22:19:33 -05:00
|
|
|
*)
|
|
|
|
echo >&2 "warning: not sure how to convert '$DOCKER_ENGINE_GOARCH' to a 'Docker' arch, assuming '$PACKAGE_ARCH'"
|
2015-11-23 14:00:43 -05:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
export PACKAGE_ARCH
|
2016-03-10 22:19:33 -05:00
|
|
|
|
|
|
|
DOCKERFILE='Dockerfile'
|
|
|
|
TEST_IMAGE_NAMESPACE=
|
|
|
|
case "$PACKAGE_ARCH" in
|
|
|
|
amd64)
|
|
|
|
case "${DOCKER_ENGINE_GOOS:-$DOCKER_CLIENT_GOOS}" in
|
|
|
|
windows)
|
|
|
|
DOCKERFILE='Dockerfile.windows'
|
|
|
|
;;
|
2016-06-07 03:45:21 -04:00
|
|
|
solaris)
|
|
|
|
DOCKERFILE='Dockerfile.solaris'
|
|
|
|
;;
|
2016-03-10 22:19:33 -05:00
|
|
|
esac
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
DOCKERFILE="Dockerfile.$PACKAGE_ARCH"
|
|
|
|
TEST_IMAGE_NAMESPACE="$PACKAGE_ARCH"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
export DOCKERFILE TEST_IMAGE_NAMESPACE
|