2022-02-03 13:19:06 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
|
2022-05-14 08:08:22 +00:00
|
|
|
export PLATFORM=$1
|
|
|
|
export ZT_ISA=$2
|
2022-02-03 13:19:06 +00:00
|
|
|
export VERSION=$3
|
2022-05-14 08:08:22 +00:00
|
|
|
export EVENT=$4
|
2022-02-03 13:19:06 +00:00
|
|
|
|
2022-05-14 08:08:22 +00:00
|
|
|
case $PLATFORM in
|
|
|
|
el*|fc*|amzn*)
|
|
|
|
export PKGFMT=rpm
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
export PKGFMT=deb
|
|
|
|
esac
|
|
|
|
|
|
|
|
# OSX
|
|
|
|
# x86_64-apple-darwin
|
|
|
|
# aarch64-apple-darwin
|
2022-02-03 13:19:06 +00:00
|
|
|
|
2022-05-14 08:08:22 +00:00
|
|
|
# Windows
|
|
|
|
# x86_64-pc-windows-msvc
|
|
|
|
# i686-pc-windows-msvc
|
|
|
|
# aarch64-pc-windows-msvc
|
|
|
|
|
|
|
|
# Linux
|
|
|
|
# i686-unknown-linux-gnu
|
|
|
|
# x86_64-unknown-linux-gnu
|
|
|
|
# arm-unknown-linux-gnueabi ?
|
|
|
|
# arm-unknown-linux-gnueabihf ?
|
|
|
|
# armv7-unknown-linux-gnueabihf
|
|
|
|
#
|
|
|
|
|
|
|
|
case $ZT_ISA in
|
|
|
|
386)
|
|
|
|
export DOCKER_ARCH=386
|
|
|
|
export RUST_TRIPLET=i686-unknown-linux-gnu
|
|
|
|
;;
|
|
|
|
amd64)
|
|
|
|
export DOCKER_ARCH=amd64
|
|
|
|
export RUST_TRIPLET=x86_64-unknown-linux-gnu
|
2022-02-03 13:19:06 +00:00
|
|
|
;;
|
2022-05-14 08:08:22 +00:00
|
|
|
armv6)
|
|
|
|
export DOCKER_ARCH=arm/v6
|
|
|
|
export RUST_TRIPLET=arm-unknown-linux-gnueabi
|
|
|
|
;;
|
|
|
|
armv7)
|
|
|
|
export DOCKER_ARCH=arm/v7
|
|
|
|
export RUST_TRIPLET=arm-unknown-linux-gnueabihf
|
2022-02-03 13:19:06 +00:00
|
|
|
;;
|
|
|
|
arm64)
|
2022-05-14 08:08:22 +00:00
|
|
|
export DOCKER_ARCH=arm64/v8
|
|
|
|
export RUST_TRIPLET=aarch64-unknown-linux-gnu
|
2022-02-03 13:19:06 +00:00
|
|
|
;;
|
2022-05-14 08:08:22 +00:00
|
|
|
riscv64)
|
|
|
|
export DOCKER_ARCH=riscv64
|
|
|
|
export RUST_TRIPLET=riscv64gc-unknown-linux-gnu
|
|
|
|
;;
|
|
|
|
ppc64le)
|
|
|
|
export DOCKER_ARCH=ppc64le
|
|
|
|
export RUST_TRIPLET=powerpc64le-unknown-linux-gnu
|
|
|
|
;;
|
|
|
|
mips64le)
|
|
|
|
export DOCKER_ARCH=mips64le
|
|
|
|
export RUST_TRIPLET=mips64el-unknown-linux-gnuabi64
|
|
|
|
;;
|
|
|
|
s390x)
|
|
|
|
export DOCKER_ARCH=s390x
|
|
|
|
export RUST_TRIPLET=s390x-unknown-linux-gnu
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "ERROR: could not determine architecture settings. PLEASE FIX ME"
|
|
|
|
exit 1
|
2022-02-03 13:19:06 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-05-14 08:08:22 +00:00
|
|
|
if [ -f "ci/Dockerfile.${PLATFORM}" ]; then
|
|
|
|
export DOCKERFILE="ci/Dockerfile.${PLATFORM}"
|
|
|
|
else
|
|
|
|
export DOCKERFILE="ci/Dockerfile.${PKGFMT}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "#~~~~~~~~~~~~~~~~~~~~"
|
|
|
|
echo "$0 variables:"
|
|
|
|
echo "nproc: $(nproc)"
|
|
|
|
echo "ZT_ISA: ${ZT_ISA}"
|
|
|
|
echo "DOCKER_ARCH: ${DOCKER_ARCH}"
|
|
|
|
echo "RUST_TRIPLET: ${RUST_TRIPLET}"
|
|
|
|
echo "VERSION: ${VERSION}"
|
|
|
|
echo "EVENT: ${EVENT}"
|
|
|
|
echo "PKGFMT: ${PKGFMT}"
|
|
|
|
echo "PWD: ${PWD}"
|
|
|
|
echo "DOCKERFILE: ${DOCKERFILE}"
|
|
|
|
echo "#~~~~~~~~~~~~~~~~~~~~"
|
|
|
|
|
|
|
|
if [ ${EVENT} == "push" ]; then
|
|
|
|
make munge_rpm zerotier-one.spec VERSION=${VERSION}
|
|
|
|
make munge_deb debian/changelog VERSION=${VERSION}
|
|
|
|
fi
|
|
|
|
|
|
|
|
export DOCKER_BUILDKIT=1
|
2022-02-03 13:19:06 +00:00
|
|
|
docker run --privileged --rm tonistiigi/binfmt --install all
|
2022-05-14 08:08:22 +00:00
|
|
|
|
|
|
|
# docker pull --platform linux/${DOCKER_ARCH} registry.sean.farm/${PLATFORM}-builder
|
|
|
|
|
|
|
|
docker buildx build \
|
|
|
|
--build-arg PLATFORM="${PLATFORM}" \
|
|
|
|
--build-arg RUST_TRIPLET="${RUST_TRIPLET}" \
|
|
|
|
--build-arg DOCKER_ARCH="${DOCKER_ARCH}" \
|
|
|
|
--platform linux/${DOCKER_ARCH} \
|
|
|
|
-f ${DOCKERFILE} \
|
|
|
|
-t build \
|
|
|
|
. \
|
|
|
|
--output type=local,dest=. \
|
|
|
|
--target export
|