2020-11-26 05:27:55 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-12-01 07:33:49 +00:00
|
|
|
set -euo pipefail
|
2020-11-26 05:27:55 +00:00
|
|
|
|
2021-12-01 07:33:49 +00:00
|
|
|
if [ -z "${BINDIR:-}" ] && [ -z "${PREFIX:-}" ]; then
|
|
|
|
PREFIX="$(realpath "$(dirname "$0")/..")"
|
2021-05-06 16:09:37 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
: "${VERSION:=v0.5.1}"
|
|
|
|
: "${BINDIR:="${PREFIX}/bin"}"
|
|
|
|
: "${DEST:="${BINDIR}/buildx"}"
|
2020-11-26 05:27:55 +00:00
|
|
|
|
|
|
|
os=""
|
|
|
|
case "$(uname)" in
|
|
|
|
Linux)
|
|
|
|
os="linux"
|
|
|
|
;;
|
|
|
|
Darwin)
|
|
|
|
os="darwin"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo >&2 "unknown OS"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
arch="$(uname -m)"
|
|
|
|
case "${arch}" in
|
|
|
|
x86_64)
|
|
|
|
arch="amd64"
|
|
|
|
;;
|
|
|
|
aarch64)
|
|
|
|
arch="arm64"
|
|
|
|
;;
|
|
|
|
armv7l)
|
|
|
|
arch="arm-v7"
|
|
|
|
;;
|
|
|
|
armv6l)
|
|
|
|
arch="arm-v6"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
url="https://github.com/docker/buildx/releases/download/${VERSION}/buildx-${VERSION}.${os}-${arch}"
|
|
|
|
|
|
|
|
echo "Installing buildx ${VERSION} as ${DEST}"
|
|
|
|
set -x
|
|
|
|
mkdir -p "${BINDIR}"
|
|
|
|
rm -f "${DEST}.download"
|
|
|
|
curl -f -L -o "${DEST}.download" "${url}"
|
|
|
|
chmod +x "${DEST}.download"
|
|
|
|
mv "${DEST}.download" "${DEST}"
|