build: fix buildx.sh with git config

This commit is contained in:
Zaiming (Stone) Shi 2023-04-04 12:39:33 +02:00
parent b16c516e6b
commit 974b180da8
1 changed files with 25 additions and 14 deletions

View File

@ -27,6 +27,13 @@ help() {
echo " E.g. ghcr.io/emqx/emqx-builder/5.0-28:1.13.4-24.3.4.2-2-debian11" echo " E.g. ghcr.io/emqx/emqx-builder/5.0-28:1.13.4-24.3.4.2-2-debian11"
} }
die() {
msg="$1"
echo "$msg" >&2
help
exit 1
}
while [ "$#" -gt 0 ]; do while [ "$#" -gt 0 ]; do
case $1 in case $1 in
-h|--help) -h|--help)
@ -81,13 +88,23 @@ while [ "$#" -gt 0 ]; do
esac esac
done done
if [ -z "${PROFILE:-}" ] || ## we have a different naming for them
[ -z "${PKGTYPE:-}" ] || if [[ $(uname -m) == "x86_64" ]]; then
[ -z "${BUILDER:-}" ] || NATIVE_ARCH='amd64'
[ -z "${ARCH:-}" ]; then elif [[ $(uname -m) == "aarch64" ]]; then
help NATIVE_ARCH='arm64'
exit 1 elif [[ $(uname -m) == "arm64" ]]; then
NATIVE_ARCH='arm64'
elif [[ $(uname -m) == "armv7l" ]]; then
# CHECKME: really ?
NATIVE_ARCH='arm64'
fi fi
ARCH="${ARCH:-${NATIVE_ARCH:-}}"
[ -z "${PROFILE:-}" ] && die "missing --prifile"
[ -z "${PKGTYPE:-}" ] && die "missing --pkgtyp"
[ -z "${BUILDER:-}" ] && die "missing --builder"
[ -z "${ARCH:-}" ] && die "missing --arch"
# ensure dir # ensure dir
cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/.." cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
@ -128,13 +145,7 @@ if [[ "$HOST_SYSTEM" = "$BUILDER_SYSTEM" ]]; then
fi fi
IS_NATIVE_ARCH='no' IS_NATIVE_ARCH='no'
if [[ $(uname -m) == "x86_64" && "$ARCH" == "amd64" ]]; then if [[ "$NATIVE_ARCH" == "$ARCH" ]]; 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' IS_NATIVE_ARCH='yes'
fi fi
@ -151,7 +162,7 @@ elif docker info; then
--platform="linux/$ARCH" \ --platform="linux/$ARCH" \
--env ACLOCAL_PATH="/usr/share/aclocal:/usr/local/share/aclocal" \ --env ACLOCAL_PATH="/usr/share/aclocal:/usr/local/share/aclocal" \
"$BUILDER" \ "$BUILDER" \
bash -euc "$CMD_RUN" bash -euc "git config --global --add safe.directory /emqx && $CMD_RUN"
else else
echo "Error: Docker not available on unsupported platform" echo "Error: Docker not available on unsupported platform"
exit 1; exit 1;