diff --git a/artifact-list.sh b/artifact-list.sh index 87669c8e8..d96858705 100755 --- a/artifact-list.sh +++ b/artifact-list.sh @@ -10,6 +10,7 @@ set -o pipefail set -o nounset supported_artifacts=( + "install_clh" "install_docker_config_script" "install_experimental_kernel" "install_firecracker" diff --git a/release/kata-deploy-binaries.sh b/release/kata-deploy-binaries.sh index 1a584b533..43f84203e 100755 --- a/release/kata-deploy-binaries.sh +++ b/release/kata-deploy-binaries.sh @@ -167,6 +167,19 @@ install_firecracker() { popd } +# Install static cloud-hypervisor asset +install_clh() { + info "build static cloud-hypervisor" + "${script_dir}/../static-build/cloud-hypervisor/build-static-clh.sh" + info "Install static cloud-hypervisor" + mkdir -p "${destdir}/opt/kata/bin/" + sudo install -D --owner root --group root --mode 0744 cloud-hypervisor/cloud-hypervisor "${destdir}/opt/kata/bin/cloud-hypervisor" + pushd "${destdir}" + # create tarball for github release action + tar -czvf ../kata-static-clh.tar.gz * + popd +} + install_docker_config_script() { local docker_config_script_name="kata-configure-docker.sh" local docker_config_script="${script_dir}/../static-build/scripts/${docker_config_script_name}" @@ -268,6 +281,7 @@ main() { install_kata_components install_experimental_kernel install_kernel + install_clh install_qemu install_qemu_virtiofsd install_firecracker diff --git a/static-build/cloud-hypervisor/build-static-clh.sh b/static-build/cloud-hypervisor/build-static-clh.sh new file mode 100755 index 000000000..c205631fd --- /dev/null +++ b/static-build/cloud-hypervisor/build-static-clh.sh @@ -0,0 +1,40 @@ +#!/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")) + +source "${script_dir}/../../scripts/lib.sh" + +cloud_hypervisor_repo="${cloud_hypervisor_repo:-}" +cloud_hypervisor_version="${cloud_hypervisor_version:-}" + +if [ -z "$cloud_hypervisor_repo" ]; then + info "Get cloud_hypervisor information from runtime versions.yaml" + cloud_hypervisor_url=$(get_from_kata_deps "assets.hypervisor.cloud_hypervisor.url") + [ -n "$cloud_hypervisor_url" ] || die "failed to get cloud_hypervisor url" + cloud_hypervisor_repo="${cloud_hypervisor_url}.git" +fi +[ -n "$cloud_hypervisor_repo" ] || die "failed to get cloud_hypervisor repo" + +[ -n "$cloud_hypervisor_version" ] || cloud_hypervisor_version=$(get_from_kata_deps "assets.hypervisor.cloud_hypervisor.version") +[ -n "$cloud_hypervisor_version" ] || die "failed to get cloud_hypervisor version" + +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}" +cd "${repo_dir}" +git fetch || true +git checkout "${cloud_hypervisor_version}" +"${script_dir}/docker-build/build.sh" +rm -f cloud-hypervisor +cp ./target/release/cloud-hypervisor . diff --git a/static-build/cloud-hypervisor/docker-build/Dockerfile b/static-build/cloud-hypervisor/docker-build/Dockerfile new file mode 100644 index 000000000..4c511b7a0 --- /dev/null +++ b/static-build/cloud-hypervisor/docker-build/Dockerfile @@ -0,0 +1,12 @@ +# +# Copyright (c) 2019 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +FROM ubuntu:18.04 + +RUN apt-get update +RUN apt-get install -yq 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}" diff --git a/static-build/cloud-hypervisor/docker-build/build.sh b/static-build/cloud-hypervisor/docker-build/build.sh new file mode 100755 index 000000000..6d157eea2 --- /dev/null +++ b/static-build/cloud-hypervisor/docker-build/build.sh @@ -0,0 +1,30 @@ +#!/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 build -t "${docker_image}" "${script_dir}" + +if test -t 1; then + USE_TTY="-ti" +else + USE_TTY="" + echo "INFO: not tty build" +fi + +docker run \ + --rm \ + -v "$(pwd):/$(pwd)" \ + -w "$(pwd)" \ + --env "CARGO_HOME=$(pwd)" \ + ${USE_TTY} \ + "${docker_image}" \ + cargo build --release diff --git a/static-build/qemu-virtiofs/Dockerfile b/static-build/qemu-virtiofs/Dockerfile index ef77df947..f2c7413e2 100644 --- a/static-build/qemu-virtiofs/Dockerfile +++ b/static-build/qemu-virtiofs/Dockerfile @@ -41,6 +41,7 @@ RUN apt-get install -y \ RUN cd .. && git clone "${QEMU_VIRTIOFS_REPO}" qemu-virtiofs RUN git checkout "${QEMU_VIRTIOFS_TAG}" ADD qemu/patches/virtiofsd/0001-add-time-to-seccomp.patch /root/0001-add-time-to-seccomp.patch +ADD qemu/patches/virtiofsd/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch /root/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch RUN patch -p1 < /root/0001-add-time-to-seccomp.patch RUN patch -p1 < /root/0002-libvhost-user-Fix-the-VHOST_USER_PROTOCOL_F_SLAVE_SE.patch ADD scripts/configure-hypervisor.sh /root/configure-hypervisor.sh