From 55cdef2295a318d22d63f212085f350f2c2931d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Tue, 15 Feb 2022 13:16:44 +0100 Subject: [PATCH] tools: clh: Add the possibility to always build from sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../cloud-hypervisor/build-static-clh.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/packaging/static-build/cloud-hypervisor/build-static-clh.sh b/tools/packaging/static-build/cloud-hypervisor/build-static-clh.sh index f174daac0..e1ceb42f7 100755 --- a/tools/packaging/static-build/cloud-hypervisor/build-static-clh.sh +++ b/tools/packaging/static-build/cloud-hypervisor/build-static-clh.sh @@ -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