qemu: add scripts to build static qemu.

Use a dockerfile to build an static qemu.

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
Jose Carlos Venegas Munoz
2018-06-13 15:12:20 -05:00
parent d5438ea131
commit f1bfbe62a3
4 changed files with 117 additions and 18 deletions

View File

@@ -0,0 +1,46 @@
from ubuntu:16.04
ARG QEMU_REPO
# commit/tag/branch
ARG QEMU_VERSION
WORKDIR /root/qemu
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 \
zlib1g-dev
RUN cd .. && git clone "${QEMU_REPO}" qemu
RUN git checkout "${QEMU_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 /root/configure-hypervisor.sh -s kata-qemu | xargs ./configure --prefix=/opt/kata --with-pkgversion=kata-static
RUN make clean
RUN make -j$(nproc)
RUN make install DESTDIR=/tmp/qemu-static
RUN cd /tmp/qemu-static && tar -czvf kata-qemu-static.tar.gz *

View File

@@ -0,0 +1,8 @@
MK_DIR :=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
CONFIG_DIR := $(MK_DIR)/../../scripts/
build:
"$(MK_DIR)/build-static-qemu.sh"
clean:
rm -f kata-qemu-static.tar.gz

View File

@@ -0,0 +1,49 @@
#!/bin/bash
#
# Copyright (c) 2018 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/"
qemu_repo="${qemu_repo:-}"
qemu_version="${qemu_version:-}"
if [ -z "$qemu_repo" ]; then
info "Get qemu information from runtime versions.yaml"
qemu_url=$(get_from_kata_deps "assets.hypervisor.qemu.url")
[ -n "$qemu_url" ] || die "failed to get qemu url"
qemu_repo="${qemu_url}.git"
fi
[ -n "$qemu_repo" ] || die "failed to get qemu repo"
[ -n "$qemu_version" ] || qemu_version=$(get_from_kata_deps "assets.hypervisor.qemu.version")
[ -n "$qemu_version" ] || die "failed to get qemu version"
info "Build ${qemu_repo} version: ${qemu_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 QEMU_REPO="${qemu_repo}" \
--build-arg QEMU_VERSION="${qemu_version}" \
"${config_dir}" \
-f "${script_dir}/Dockerfile" \
-t qemu-static
docker run \
-ti \
-v "${PWD}":/share qemu-static \
mv /tmp/qemu-static/kata-qemu-static.tar.gz /share/