tools: clh: Add the possibility to always build from sources

The current code will always pull the release binaries in case the
version requested by Kata Containers matches with a released version.

This, however, has a limitation of preventing users / CIs to build
cloud-hypervisor from source for a reason or another, such as passing a
specific build flag to cloud-hypervisor.

This is a pre-req to solving
https://github.com/kata-containers/kata-containers/issues/3671.

While here, a small changes were needed in order to improve readability
and debugability of why we're building something from the sources rather
than simply downloading and using a pre-built binary.

Fixes: #3672

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2022-02-15 13:16:44 +01:00
parent a3b3274121
commit 55cdef2295

View File

@ -15,6 +15,7 @@ ARCH=$(uname -m)
script_dir=$(dirname $(readlink -f "$0"))
kata_version="${kata_version:-}"
force_build_from_source="${force_build_from_source:-false}"
source "${script_dir}/../../scripts/lib.sh"
@ -55,7 +56,15 @@ build_clh_from_source() {
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 [ "${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