From 924bda0c61d60d6fd089b390aef108d132b6a596 Mon Sep 17 00:00:00 2001 From: Eric Ernst Date: Wed, 8 May 2019 17:09:00 -0700 Subject: [PATCH] nemu: add support for static build of nemu Fixes: #401 Signed-off-by: Eric Ernst --- static-build/nemu/Dockerfile | 56 +++++++++++++++++++++++ static-build/nemu/Makefile | 13 ++++++ static-build/nemu/build-static-nemu.sh | 63 ++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 static-build/nemu/Dockerfile create mode 100644 static-build/nemu/Makefile create mode 100755 static-build/nemu/build-static-nemu.sh diff --git a/static-build/nemu/Dockerfile b/static-build/nemu/Dockerfile new file mode 100644 index 000000000..186e77bfc --- /dev/null +++ b/static-build/nemu/Dockerfile @@ -0,0 +1,56 @@ +# Copyright (c) 2019 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# +from ubuntu:18.04 + +ARG NEMU_REPO +ARG NEMU_VERSION +ARG NEMU_OVMF + +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 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..339bbe327 --- /dev/null +++ b/static-build/nemu/build-static-nemu.sh @@ -0,0 +1,63 @@ +#!/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_url=$(get_from_kata_deps "assets.hypervisor.nemu.url") + [ -n "$nemu_url" ] || die "failed to get nemu url" + nemu_repo="${nemu_url}.git" +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_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}" \ + "${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/