chore(buildx.sh): no need to parameterise otp version and system

This commit is contained in:
Zaiming (Stone) Shi 2022-04-19 20:41:04 +02:00
parent e7033558f3
commit a0145f4692
1 changed files with 33 additions and 35 deletions

View File

@ -25,9 +25,6 @@ help() {
echo "--src_dir <SRC_DIR>: EMQX source ode in this dir, default to PWD" echo "--src_dir <SRC_DIR>: EMQX source ode in this dir, default to PWD"
echo "--builder <BUILDER>: Builder image to pull" echo "--builder <BUILDER>: Builder image to pull"
echo " E.g. ghcr.io/emqx/emqx-builder/5.0-10:1.13.3-24.2.1-1-debian10" echo " E.g. ghcr.io/emqx/emqx-builder/5.0-10:1.13.3-24.2.1-1-debian10"
echo "--otp <OTP_VSN>: OTP version being used in the builder"
echo "--elixir-vsn <ELIXIR_VSN>: Elixir version being used in the builder"
echo "--system <SYSTEM>: OS used in the builder image"
} }
while [ "$#" -gt 0 ]; do while [ "$#" -gt 0 ]; do
@ -56,14 +53,6 @@ while [ "$#" -gt 0 ]; do
ARCH="$2" ARCH="$2"
shift 2 shift 2
;; ;;
--otp)
OTP_VSN="$2"
shift 2
;;
--elixir-vsn)
ELIXIR_VSN="$2"
shift 2
;;
--elixir) --elixir)
shift 1 shift 1
case ${1:-novalue} in case ${1:-novalue} in
@ -84,10 +73,6 @@ while [ "$#" -gt 0 ]; do
;; ;;
esac esac
;; ;;
--system)
SYSTEM="$2"
shift 2
;;
*) *)
echo "WARN: Unknown arg (ignored): $1" echo "WARN: Unknown arg (ignored): $1"
shift shift
@ -99,10 +84,7 @@ done
if [ -z "${PROFILE:-}" ] || if [ -z "${PROFILE:-}" ] ||
[ -z "${PKGTYPE:-}" ] || [ -z "${PKGTYPE:-}" ] ||
[ -z "${BUILDER:-}" ] || [ -z "${BUILDER:-}" ] ||
[ -z "${ARCH:-}" ] || [ -z "${ARCH:-}" ]; then
[ -z "${OTP_VSN:-}" ] ||
[ -z "${ELIXIR_VSN:-}" ] ||
[ -z "${SYSTEM:-}" ]; then
help help
exit 1 exit 1
fi fi
@ -135,25 +117,41 @@ else
MAKE_TARGET="${PROFILE}-${PKGTYPE}" MAKE_TARGET="${PROFILE}-${PKGTYPE}"
fi fi
HOST_SYSTEM="$(./scripts/get-distro.sh)"
BUILDER_SYSTEM="$(docker run --rm -v "$(pwd)":/emqx "$BUILDER" /emqx/scripts/get-distro.sh)"
CMD_RUN="make ${MAKE_TARGET} && ./scripts/pkg-tests.sh ${MAKE_TARGET}" CMD_RUN="make ${MAKE_TARGET} && ./scripts/pkg-tests.sh ${MAKE_TARGET}"
if [[ $(uname -m) = "x86_64" && "$ARCH" = "amd64" ]]; then IS_NATIVE_SYSTEM='no'
eval "$CMD_RUN" if [[ "$HOST_SYSTEM" = "$BUILDER_SYSTEM" ]]; then
elif [[ $(uname -m) = "aarch64" && "$ARCH" = "arm64" ]]; then IS_NATIVE_SYSTEM='yes'
eval "$CMD_RUN" fi
elif [[ $(uname -m) = "arm64" && "$ARCH" = "arm64" ]]; then
eval "$CMD_RUN" IS_NATIVE_ARCH='no'
elif [[ $(uname -m) = "armv7l" && "$ARCH" = "arm64" ]]; then if [[ $(uname -m) == "x86_64" && "$ARCH" == "amd64" ]]; then
IS_NATIVE_ARCH='yes'
elif [[ $(uname -m) == "aarch64" && "$ARCH" == "arm64" ]]; then
IS_NATIVE_ARCH='yes'
elif [[ $(uname -m) == "arm64" && "$ARCH" == "arm64" ]]; then
IS_NATIVE_ARCH='yes'
elif [[ $(uname -m) == "armv7l" && "$ARCH" == "arm64" ]]; then
IS_NATIVE_ARCH='yes'
fi
if [[ "${IS_NATIVE_SYSTEM}" == 'yes' && "${IS_NATIVE_ARCH}" == 'yes' ]]; then
eval "$CMD_RUN" eval "$CMD_RUN"
elif docker info; then elif docker info; then
docker run --rm --privileged tonistiigi/binfmt:latest --install "${ARCH}" if [[ "${IS_NATIVE_ARCH}" == 'no' ]]; then
docker run -i --rm \ docker run --rm --privileged tonistiigi/binfmt:latest --install "${ARCH}"
-v "$(pwd)":/emqx \ fi
--workdir /emqx \ docker run -i --rm \
--platform="linux/$ARCH" \ -v "$(pwd)":/emqx \
"$BUILDER" \ --workdir /emqx \
bash -euc "$CMD_RUN" --platform="linux/$ARCH" \
"$BUILDER" \
bash -euc "$CMD_RUN"
else else
echo "Error: Docker not available on unsupported platform" echo "Error: Docker not available on unsupported platform"
exit 1; exit 1;
fi fi