diff --git a/ci/install_musl.sh b/ci/install_musl.sh new file mode 100755 index 0000000000..30d2d642b5 --- /dev/null +++ b/ci/install_musl.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Copyright (c) 2020 Ant Group +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -e + +install_aarch64_musl() { + local arch=$(uname -m) + if [ "${arch}" == "aarch64" ]; then + local musl_tar="${arch}-linux-musl-native.tgz" + local musl_dir="${arch}-linux-musl-native" + pushd /tmp + curl -sLO https://musl.cc/${musl_tar} + tar -zxf ${musl_tar} + mkdir -p /usr/local/musl/ + cp -r ${musl_dir}/* /usr/local/musl/ + popd + fi +} + +install_aarch64_musl diff --git a/tools/osbuilder/rootfs-builder/rootfs.sh b/tools/osbuilder/rootfs-builder/rootfs.sh index da9c16d07e..9800d9d8ce 100755 --- a/tools/osbuilder/rootfs-builder/rootfs.sh +++ b/tools/osbuilder/rootfs-builder/rootfs.sh @@ -539,9 +539,11 @@ EOT AGENT_DEST="${AGENT_DIR}/${AGENT_BIN}" if [ -z "${AGENT_SOURCE_BIN}" ] ; then - # rust agent needs x86_64-unknown-linux-musl - rustup show | grep x86_64-unknown-linux-musl > /dev/null || bash ${script_dir}/../../../ci/install_rust.sh + bash ${script_dir}/../../../ci/install_musl.sh + # rust agent needs ${arch}-unknown-linux-musl + rustup show | grep linux-musl > /dev/null || bash ${script_dir}/../../../ci/install_rust.sh test -r "${HOME}/.cargo/env" && source "${HOME}/.cargo/env" + [ "$ARCH" == "aarch64" ] && OLD_PATH=$PATH && export PATH=$PATH:/usr/local/musl/bin agent_pkg="${RUST_AGENT_PKG}" agent_dir="${script_dir}/../../../src/agent/" @@ -554,6 +556,7 @@ EOT make clean make LIBC=${LIBC} INIT=${AGENT_INIT} make install DESTDIR="${ROOTFS_DIR}" LIBC=${LIBC} INIT=${AGENT_INIT} SECCOMP=${SECCOMP} + [ "$ARCH" == "aarch64" ] && export PATH=$OLD_PATH && rm -rf /usr/local/musl popd else cp ${AGENT_SOURCE_BIN} ${AGENT_DEST}