mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-27 19:35:32 +00:00
Merge pull request #3673 from fidencio/wip/allow-passing-a-build-flag-to-cloud-hypervisor
tools: clh: Allow to set when to build from sources and the build flags passed down to cargo
This commit is contained in:
commit
d0c8eb7e14
@ -15,6 +15,8 @@ ARCH=$(uname -m)
|
||||
|
||||
script_dir=$(dirname $(readlink -f "$0"))
|
||||
kata_version="${kata_version:-}"
|
||||
force_build_from_source="${force_build_from_source:-false}"
|
||||
extra_build_args="${extra_build_args:-}"
|
||||
|
||||
source "${script_dir}/../../scripts/lib.sh"
|
||||
|
||||
@ -39,6 +41,7 @@ pull_clh_released_binary() {
|
||||
curl --fail -L ${cloud_hypervisor_binary} -o cloud-hypervisor-static || return 1
|
||||
mkdir -p cloud-hypervisor
|
||||
mv -f cloud-hypervisor-static cloud-hypervisor/cloud-hypervisor
|
||||
chmod +x cloud_hypervisor/cloud-hypervisor
|
||||
}
|
||||
|
||||
build_clh_from_source() {
|
||||
@ -49,13 +52,31 @@ build_clh_from_source() {
|
||||
pushd "${repo_dir}"
|
||||
git fetch || true
|
||||
git checkout "${cloud_hypervisor_version}"
|
||||
./scripts/dev_cli.sh build --release --libc musl
|
||||
if [ -n "${extra_build_args}" ]; then
|
||||
info "Build cloud-hypervisor with extra args: ${extra_build_args}"
|
||||
./scripts/dev_cli.sh build --release --libc musl -- ${extra_build_args}
|
||||
else
|
||||
./scripts/dev_cli.sh build --release --libc musl
|
||||
fi
|
||||
rm -f cloud-hypervisor
|
||||
cp build/cargo_target/$(uname -m)-unknown-linux-musl/release/cloud-hypervisor .
|
||||
popd
|
||||
}
|
||||
|
||||
if [ ${ARCH} == "aarch64" ] || ! pull_clh_released_binary; then
|
||||
info "arch is aarch64 or failed to pull cloud-hypervisor released binary on x86_64, trying to build from source"
|
||||
build_clh_from_source
|
||||
if [ "${ARCH}" == "aarch64" ]; then
|
||||
info "aarch64 binaries are not distributed as part of the Cloud Hypervisor releases, forcing to build from source"
|
||||
force_build_from_source="true"
|
||||
fi
|
||||
|
||||
if [ -n "${extra_build_args}" ]; then
|
||||
info "As an extra build argument has been passed to the script, forcing to build from source"
|
||||
force_build_from_source="true"
|
||||
fi
|
||||
|
||||
if [ "${force_build_from_source}" == "true" ]; then
|
||||
info "Build cloud-hypervisor from source as it's been request via the force_build_from_source flag"
|
||||
build_clh_from_source
|
||||
else
|
||||
pull_clh_released_binary ||
|
||||
(info "Failed to pull cloud-hypervisor released binary, trying to build from source" && build_clh_from_source)
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user