diff --git a/release/kata-deploy-binaries.sh b/release/kata-deploy-binaries.sh index 374d72e60..e5d4886c9 100755 --- a/release/kata-deploy-binaries.sh +++ b/release/kata-deploy-binaries.sh @@ -104,6 +104,14 @@ install_kernel() { popd >>/dev/null } +# Install static nemu asset +install_nemu() { + info "build static nemu" + "${script_dir}/../static-build/nemu/build-static-nemu.sh" + info "Install static nemu" + tar xf kata-nemu-static.tar.gz -C "${destdir}" +} + # Install static qemu asset install_qemu() { info "build static qemu" @@ -159,6 +167,12 @@ ${prefix}/bin/kata-runtime --kata-config "${prefix}/share/defaults/${project}/co EOT sudo chmod +x kata-qemu + cat <>/dev/null diff --git a/static-build/nemu/Dockerfile b/static-build/nemu/Dockerfile new file mode 100644 index 000000000..1691a2a75 --- /dev/null +++ b/static-build/nemu/Dockerfile @@ -0,0 +1,59 @@ +# Copyright (c) 2019 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +from ubuntu:18.04 + +ARG NEMU_REPO +ARG NEMU_VERSION +ARG NEMU_OVMF +ARG VIRTIOFSD_RELEASE +ARG VIRTIOFSD + +WORKDIR /root/nemu +RUN apt-get update +RUN apt-get install -y \ + autoconf \ + automake \ + bc \ + bison \ + cpio \ + flex \ + gawk \ + libaudit-dev \ + libcap-dev \ + libcap-ng-dev \ + libdw-dev \ + libelf-dev \ + libglib2.0-0 \ + libglib2.0-dev \ + libglib2.0-dev git \ + libltdl-dev \ + libpixman-1-dev \ + libtool \ + pkg-config \ + pkg-config \ + python \ + python-dev \ + rsync \ + wget \ + zlib1g-dev + +RUN cd .. && git clone --depth=1 "${NEMU_REPO}" nemu +RUN git checkout "${NEMU_VERSION}" +RUN git clone https://github.com/qemu/capstone.git capstone +RUN git clone https://github.com/qemu/keycodemapdb.git ui/keycodemapdb + +ADD configure-hypervisor.sh /root/configure-hypervisor.sh + +RUN PREFIX=/opt/kata /root/configure-hypervisor.sh -s kata-nemu | xargs ./configure \ + --with-pkgversion=kata-static + +RUN make -j$(nproc) +RUN make install DESTDIR=/tmp/nemu-static + +RUN wget "${NEMU_OVMF}" && mv OVMF.fd /tmp/nemu-static/opt/kata/share/kata-nemu/ +RUN mv /tmp/nemu-static/opt/kata/bin/qemu-system-x86_64 /tmp/nemu-static/opt/kata/bin/nemu-system-x86_64 +RUN wget "${VIRTIOFSD_RELEASE}/${VIRTIOFSD}" && chmod +x ${VIRTIOFSD} && mv ${VIRTIOFSD} /tmp/nemu-static/opt/kata/bin/ + +RUN cd /tmp/nemu-static && tar -czvf kata-nemu-static.tar.gz * diff --git a/static-build/nemu/Makefile b/static-build/nemu/Makefile new file mode 100644 index 000000000..97003df87 --- /dev/null +++ b/static-build/nemu/Makefile @@ -0,0 +1,13 @@ +#Copyright (c) 2019 Intel Corporation +# +#SPDX-License-Identifier: Apache-2.0 +# + +MK_DIR :=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) +CONFIG_DIR := $(MK_DIR)/../../scripts/ + +build: + "$(MK_DIR)/build-static-nemu.sh" + +clean: + rm -f kata-nemu-static.tar.gz diff --git a/static-build/nemu/build-static-nemu.sh b/static-build/nemu/build-static-nemu.sh new file mode 100755 index 000000000..c8c304961 --- /dev/null +++ b/static-build/nemu/build-static-nemu.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# Copyright (c) 2019 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +set -o errexit +set -o nounset +set -o pipefail + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +source "${script_dir}/../../scripts/lib.sh" + +config_dir="${script_dir}/../../scripts/" + +nemu_repo="${nemu_repo:-}" +nemu_version="${nemu_version:-}" +nemu_ovmf_repo="${nemu_ovmf_repo:-}" +nemu_ovmf_version="${nemu_ovmf_version:-}" + +if [ -z "$nemu_repo" ]; then + info "Get nemu information from runtime versions.yaml" + nemu_repo=$(get_from_kata_deps "assets.hypervisor.nemu.url") +fi +[ -n "$nemu_repo" ] || die "failed to get nemu repo" + +[ -n "$nemu_version" ] || nemu_version=$(get_from_kata_deps "assets.hypervisor.nemu.version") +[ -n "$nemu_version" ] || die "failed to get nemu version" + +if [ -z "$nemu_ovmf_repo" ]; then + info "Get nemu information from runtime versions.yaml" + nemu_ovmf_repo=$(get_from_kata_deps "assets.hypervisor.nemu-ovmf.url") + [ -n "$nemu_ovmf_repo" ] || die "failed to get nemu ovmf repo url" +fi + +if [ -z "$nemu_ovmf_version" ]; then + nemu_ovmf_version=$(get_from_kata_deps "assets.hypervisor.nemu-ovmf.version") + [ -n "$nemu_ovmf_version" ] || die "failed to get nemu ovmf version" +fi + +nemu_virtiofsd_binary="virtiofsd-x86_64" +nemu_virtiofsd_release="${nemu_repo}/releases/download/${nemu_version}" +nemu_ovmf_release="${nemu_ovmf_repo}/releases/download/${nemu_ovmf_version}/OVMF.fd" +info "Build ${nemu_repo} version: ${nemu_version}" + +http_proxy="${http_proxy:-}" +https_proxy="${https_proxy:-}" + +docker build \ + --build-arg http_proxy="${http_proxy}" \ + --build-arg https_proxy="${https_proxy}" \ + --build-arg NEMU_REPO="${nemu_repo}" \ + --build-arg NEMU_VERSION="${nemu_version}" \ + --build-arg NEMU_OVMF="${nemu_ovmf_release}" \ + --build-arg VIRTIOFSD_RELEASE="${nemu_virtiofsd_release}" \ + --build-arg VIRTIOFSD="${nemu_virtiofsd_binary}" \ + "${config_dir}" \ + -f "${script_dir}/Dockerfile" \ + -t nemu-static + +docker run \ + -i \ + -v "${PWD}":/share nemu-static \ + mv /tmp/nemu-static/kata-nemu-static.tar.gz /share/