You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
buildx/hack/util

33 lines
876 B
Bash

#!/usr/bin/env sh
: ${PREFER_BUILDCTL=}
: ${PREFER_LEGACY=}
: ${CLI_PLATFORM=}
newerEqualThan() { # $1=minimum wanted version $2=actual-version
[ "$1" = "$(printf "$1\n$2" | sort -V | head -n 1)" ]
}
buildmode="legacy"
if [ "$PREFER_BUILDCTL" = "1" ]; then
buildmode="buildkit";
else
serverVersion=$(docker info --format '{{.ServerVersion}}')
experimental=$(docker info --format '{{.ExperimentalBuild}}')
if [ "$PREFER_LEGACY" != "1" ] && ( newerEqualThan "18.09" $serverVersion || \
( newerEqualThan "18.06" $serverVersion && [ "true" = "$experimental" ] ) || \
[ "$DOCKER_BUILDKIT" = "1" ]); then
buildmode="docker-buildkit";
fi
fi
if [ -z "$CLI_PLATFORM" ]; then
rawos=$(uname -s)
if [ "$rawos" = "Darwin" ]; then
CLI_PLATFORM="darwin/amd64"
elif uname -s | grep MINGW > /dev/null 2>&1 ; then
CLI_PLATFORM="windows/amd64"
fi
fi