Merge pull request #762 from likebreath/fix_clh_ci

packaging: Build from source if the clh release binary is missing
This commit is contained in:
Bo Chen 2020-09-23 13:46:24 -07:00 committed by GitHub
commit 952b9fe856
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 51 deletions

View File

@ -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" ] || die "failed to get cloud_hypervisor version"
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"
pull_clh_released_binary() {
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

View File

@ -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}"

View File

@ -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