From d690519f86cc9da29d375e59d04a36a44f348c9b Mon Sep 17 00:00:00 2001
From: xiedeyantu
Date: Tue, 6 Jun 2023 21:36:33 +0800
Subject: [PATCH] fix build script to adapt to macos m1.
---
dev/generate_helm_chart.sh | 2 +-
dev/image_build_universal.sh | 11 ++++++++---
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/dev/generate_helm_chart.sh b/dev/generate_helm_chart.sh
index 142a40416..7a4e9eae5 100755
--- a/dev/generate_helm_chart.sh
+++ b/dev/generate_helm_chart.sh
@@ -4,7 +4,7 @@ function usage() {
cat << EOT
Script splits clickhouse-operator-install-bundle.yaml to separate files and adjusts them to conform the helm standards
NOTE script requires some pre-installed tools:
- - yq ( https://mikefarah.gitbook.io/yq/ ) > v4.14.x
+ - yq ( https://mikefarah.gitbook.io/yq/ ) > v4.14.x. Do not use brew install yq in MacOS,Version is lower than it.
- jq ( https://github.com/stedolan/jq )
- helm-docs ( https://github.com/norwoodj/helm-docs )
- perl ( https://learn.perl.org/installing/ )
diff --git a/dev/image_build_universal.sh b/dev/image_build_universal.sh
index fccd1d2ed..a80079a9d 100644
--- a/dev/image_build_universal.sh
+++ b/dev/image_build_universal.sh
@@ -26,9 +26,14 @@ if [[ "${MINIKUBE}" == "yes" ]]; then
eval "$(minikube docker-env)"
fi
-if ! docker run --rm --privileged multiarch/qemu-user-static --reset -p yes; then
- sudo apt-get install -y qemu binfmt-support qemu-user-static
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
+ARCHITECTURE=$(uname -m)
+# Do nothing if architecture is arm,such as MacOS M1/M2
+
+if [[ ! "${ARCHITECTURE}" =~ "arm" ]]; then
+ if ! docker run --rm --privileged multiarch/qemu-user-static --reset -p yes; then
+ sudo apt-get install -y qemu binfmt-support qemu-user-static
+ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
+ fi
fi
if [[ "0" == $(docker buildx ls | grep -E 'linux/arm.+\*' | grep -E 'running|inactive') ]]; then