Merge pull request #497 from egernst/nemu-static

nemu: add support for static build of nemu
This commit is contained in:
James O. D. Hunt 2019-05-10 16:21:57 +01:00 committed by GitHub
commit f13416129c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 152 additions and 0 deletions

View File

@ -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 <<EOT | sudo tee kata-nemu
#!/bin/bash
${prefix}/bin/kata-runtime --kata-config "${prefix}/share/defaults/${project}/configuration-nemu.toml" \$@
EOT
sudo chmod +x kata-nemu
popd
}
@ -183,6 +197,7 @@ main() {
install_kata_components
install_kernel
install_qemu
install_nemu
install_firecracker
tarball_name="${destdir}.tar.xz"
pushd "${destdir}" >>/dev/null

View File

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

View File

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

View File

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