mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 00:07:16 +00:00
packaging: Build from source if the clh release binary is missing
This patch add fall-back code path that builds cloud-hypervisor static binary from source, when the downloading of cloud-hypervisor binary is failing. This is useful when we experience network issues, and also useful for upgrading clh to non-released version. Together with the changes in the tests repo (https://github.com/kata-containers/tests/pull/2862), the Jenkins config file is also updated with new Execute shell script for the clh CI in the kata-containers repo. Those two changes fix the regression on clh CI here. Please check details in the issue below. Fixes: #781 Fixes: https://github.com/kata-containers/tests/issues/2858 Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
bacd41bb65
commit
01df3c1d5e
@ -18,7 +18,28 @@ cloud_hypervisor_version="${cloud_hypervisor_version:-}"
|
|||||||
[ -n "$cloud_hypervisor_version" ] || cloud_hypervisor_version=$(get_from_kata_deps "assets.hypervisor.cloud_hypervisor.version" "${kata_version}")
|
[ -n "$cloud_hypervisor_version" ] || cloud_hypervisor_version=$(get_from_kata_deps "assets.hypervisor.cloud_hypervisor.version" "${kata_version}")
|
||||||
[ -n "$cloud_hypervisor_version" ] || die "failed to get cloud_hypervisor version"
|
[ -n "$cloud_hypervisor_version" ] || die "failed to get cloud_hypervisor version"
|
||||||
|
|
||||||
info "Download cloud-hypervisor version: ${cloud_hypervisor_version}"
|
pull_clh_released_binary() {
|
||||||
cloud_hypervisor_binary="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/${cloud_hypervisor_version}/cloud-hypervisor-static"
|
info "Download cloud-hypervisor version: ${cloud_hypervisor_version}"
|
||||||
|
cloud_hypervisor_binary="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/${cloud_hypervisor_version}/cloud-hypervisor-static"
|
||||||
|
|
||||||
curl --fail -L ${cloud_hypervisor_binary} -o cloud-hypervisor
|
curl --fail -L ${cloud_hypervisor_binary} -o cloud-hypervisor || return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
build_clh_from_source() {
|
||||||
|
info "Build ${cloud_hypervisor_repo} version: ${cloud_hypervisor_version}"
|
||||||
|
repo_dir=$(basename "${cloud_hypervisor_repo}")
|
||||||
|
repo_dir="${repo_dir//.git}"
|
||||||
|
[ -d "${repo_dir}" ] || git clone "${cloud_hypervisor_repo}"
|
||||||
|
pushd "${repo_dir}"
|
||||||
|
git fetch || true
|
||||||
|
git checkout "${cloud_hypervisor_version}"
|
||||||
|
./scripts/dev_cli.sh build --release --libc musl
|
||||||
|
rm -f cloud-hypervisor
|
||||||
|
cp build/cargo_target/$(uname -m)-unknown-linux-musl/release/cloud-hypervisor .
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! pull_clh_released_binary; then
|
||||||
|
info "failed to pull cloud-hypervisor released binary, trying to build from source"
|
||||||
|
build_clh_from_source
|
||||||
|
fi
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (c) 2019 Intel Corporation
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
FROM ubuntu:18.04
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get --no-install-recommends install -yq apt-utils ca-certificates build-essential mtools libssl-dev pkg-config curl git
|
|
||||||
RUN nohup curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
||||||
RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
|
|
||||||
ENV PATH="/root/.cargo/bin:${PATH}"
|
|
@ -1,36 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Copyright (c) 2019 Intel Corporation
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
script_dir=$(dirname $(readlink -f "$0"))
|
|
||||||
docker_image="cloud-hypervisor-builder"
|
|
||||||
|
|
||||||
DOCKER_CLI="docker"
|
|
||||||
|
|
||||||
if ! command -v docker && command -v podman; then
|
|
||||||
DOCKER_CLI="podman"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo "${DOCKER_CLI}" build -t "${docker_image}" "${script_dir}"
|
|
||||||
|
|
||||||
if test -t 1; then
|
|
||||||
USE_TTY="-ti"
|
|
||||||
else
|
|
||||||
USE_TTY=""
|
|
||||||
echo "INFO: not tty build"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo "${DOCKER_CLI}" run \
|
|
||||||
--rm \
|
|
||||||
-v "$(pwd):/$(pwd)" \
|
|
||||||
-w "$(pwd)" \
|
|
||||||
--env "CARGO_HOME=$(pwd)" \
|
|
||||||
${USE_TTY} \
|
|
||||||
"${docker_image}" \
|
|
||||||
cargo build --release
|
|
Loading…
Reference in New Issue
Block a user