mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
virtiofsd: build rust based virtiofsd from source for non-x86_64
Based on @fidencio's opoinon, On Arm: static build virtiofsd using musl lib; on ppc64 & s390: static build virtiofsd using gnu lib; Fixes: #4258 Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
This commit is contained in:
parent
2c238c8504
commit
d20bc5a4d2
@ -9,6 +9,8 @@ set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
ARCH=$(uname -m)
|
||||
ARCH_LIBC=""
|
||||
LIBC=""
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
@ -19,11 +21,12 @@ virtiofsd_version="${virtiofsd_version:-}"
|
||||
[ -n "$virtiofsd_version" ] || virtiofsd_version=$(get_from_kata_deps "externals.virtiofsd.version")
|
||||
[ -n "$virtiofsd_version" ] || die "failed to get virtiofsd version"
|
||||
|
||||
if [ "${ARCH}" != "x86_64" ]; then
|
||||
info "Only x86_64 binaries are distributed as part of the virtiofsd releases" && exit 1
|
||||
fi
|
||||
[ -d "virtiofsd" ] && rm -r virtiofsd
|
||||
|
||||
pull_virtiofsd_released_binary() {
|
||||
if [ "${ARCH}" != "x86_64" ]; then
|
||||
info "Only x86_64 binaries are distributed as part of the virtiofsd releases" && return 1
|
||||
fi
|
||||
info "Download virtiofsd version: ${virtiofsd_version}"
|
||||
virtiofsd_zip=$(get_from_kata_deps "externals.virtiofsd.meta.binary")
|
||||
[ -n "${virtiofsd_zip}" ] || die "failed to get virtiofsd binary URL"
|
||||
@ -40,4 +43,47 @@ pull_virtiofsd_released_binary() {
|
||||
popd
|
||||
}
|
||||
|
||||
pull_virtiofsd_released_binary
|
||||
init_env() {
|
||||
case ${ARCH} in
|
||||
"aarch64")
|
||||
LIBC="musl"
|
||||
;;
|
||||
"ppc64le")
|
||||
LIBC="gnu"
|
||||
ARCH="powerpc64le"
|
||||
;;
|
||||
"s390")
|
||||
LIBC="gnu"
|
||||
;;
|
||||
"x86_64")
|
||||
LIBC="musl"
|
||||
esac
|
||||
|
||||
ARCH_LIBC=${ARCH}-linux-${LIBC}
|
||||
}
|
||||
|
||||
build_virtiofsd_from_source() {
|
||||
echo "build viriofsd from source"
|
||||
init_env
|
||||
|
||||
virtiofsd_url=$(get_from_kata_deps "externals.virtiofsd.url")
|
||||
|
||||
git clone --depth 1 --branch ${virtiofsd_version} ${virtiofsd_url} virtiofsd
|
||||
pushd virtiofsd
|
||||
|
||||
RUSTFLAGS='-C target-feature=+crt-static -C link-self-contained=yes'
|
||||
LIBSECCOMP_LINK_TYPE=static
|
||||
LIBSECCOMP_LIB_PATH=/usr/lib/${ARCH_LIBC}
|
||||
LIBCAPNG_LINK_TYPE=static
|
||||
LIBCAPNG_LIB_PATH=/usr/lib/${ARCH_LIBC}
|
||||
|
||||
cargo build --release --target ${ARCH}-unknown-linux-${LIBC}
|
||||
|
||||
binary=$(find ./ -name virtiofsd)
|
||||
mv -f ${binary} .
|
||||
chmod +x virtiofsd
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
pull_virtiofsd_released_binary || build_virtiofsd_from_source
|
||||
|
Loading…
Reference in New Issue
Block a user