From 3dc05da13763dd84e74221747e0b8d1db7af3a22 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Sat, 14 Dec 2019 17:56:58 +0700 Subject: [PATCH] Build QEMU from source --- Dockerfile | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ec201a0..36b15fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,48 @@ -FROM qemu/arm as dockerpi-vm +ARG QEMU_VERSION=4.2.0 + +# Build stage for qemu-system-arm +FROM debian:stable-slim AS qemu-system-arm-builder +ARG QEMU_VERSION +ENV QEMU_TARBALL="qemu-${QEMU_VERSION}.tar.xz" +WORKDIR /qemu + +RUN # Update package lists +RUN apt-get update + +RUN # Pull source and verify signatures +RUN apt-get -y install wget +RUN wget "https://download.qemu.org/${QEMU_TARBALL}" + +RUN # Verify signatures +RUN apt-get -y install gpg +RUN wget "https://download.qemu.org/${QEMU_TARBALL}.sig" +RUN gpg --keyserver keyserver.ubuntu.com --recv-keys CEACC9E15534EBABB82D3FA03353C9CEF108B584 +RUN gpg --verify "${QEMU_TARBALL}.sig" "${QEMU_TARBALL}" + +RUN # Extract source tarball +RUN apt-get -y install pkg-config +RUN tar xvf "${QEMU_TARBALL}" + +RUN # Build source +# These seem to be the only deps actually required for a successful build +RUN apt-get -y install python build-essential libglib2.0-dev libpixman-1-dev +# These don't seem to be required but are specified here: https://wiki.qemu.org/Hosts/Linux +RUN apt-get -y install libfdt-dev zlib1g-dev +# Not required or specified anywhere but supress build warnings +RUN apt-get -y install pkg-config flex bison +RUN "qemu-${QEMU_VERSION}/configure" --static --target-list=arm-softmmu +RUN make -j$(nproc) + +RUN # Strip the binary, this gives a substantial size reduction! +RUN strip "arm-softmmu/qemu-system-arm" + + +# Build the dockerpi VM image +FROM busybox:1.31 AS dockerpi-vm LABEL maintainer="Luke Childs " +ARG QEMU_VERSION + +COPY --from=qemu-system-arm-builder /qemu/arm-softmmu/qemu-system-arm /usr/local/bin/qemu-system-arm ADD https://github.com/dhruvvyas90/qemu-rpi-kernel/archive/afe411f2c9b04730bcc6b2168cdc9adca224227c.zip /tmp/qemu-rpi-kernel.zip @@ -14,6 +57,9 @@ VOLUME /sdcard ADD ./entrypoint.sh /entrypoint.sh ENTRYPOINT ["./entrypoint.sh"] + +# Build the dockerpi image +# It's just the VM image with a compressed Raspbian filesystem added FROM dockerpi-vm as dockerpi LABEL maintainer="Luke Childs " ADD http://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-09-30/2019-09-26-raspbian-buster-lite.zip /filesystem.zip