osbuilder: install musl for aarch64

So that it can do musl static build.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao 2020-08-27 10:14:08 +08:00
parent b24f2cb969
commit c624fa7469
2 changed files with 28 additions and 2 deletions

23
ci/install_musl.sh Executable file
View File

@ -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

View File

@ -539,9 +539,11 @@ EOT
AGENT_DEST="${AGENT_DIR}/${AGENT_BIN}" AGENT_DEST="${AGENT_DIR}/${AGENT_BIN}"
if [ -z "${AGENT_SOURCE_BIN}" ] ; then if [ -z "${AGENT_SOURCE_BIN}" ] ; then
# rust agent needs x86_64-unknown-linux-musl bash ${script_dir}/../../../ci/install_musl.sh
rustup show | grep x86_64-unknown-linux-musl > /dev/null || bash ${script_dir}/../../../ci/install_rust.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" 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_pkg="${RUST_AGENT_PKG}"
agent_dir="${script_dir}/../../../src/agent/" agent_dir="${script_dir}/../../../src/agent/"
@ -554,6 +556,7 @@ EOT
make clean make clean
make LIBC=${LIBC} INIT=${AGENT_INIT} make LIBC=${LIBC} INIT=${AGENT_INIT}
make install DESTDIR="${ROOTFS_DIR}" LIBC=${LIBC} INIT=${AGENT_INIT} SECCOMP=${SECCOMP} make install DESTDIR="${ROOTFS_DIR}" LIBC=${LIBC} INIT=${AGENT_INIT} SECCOMP=${SECCOMP}
[ "$ARCH" == "aarch64" ] && export PATH=$OLD_PATH && rm -rf /usr/local/musl
popd popd
else else
cp ${AGENT_SOURCE_BIN} ${AGENT_DEST} cp ${AGENT_SOURCE_BIN} ${AGENT_DEST}