Source
FROM scratch AS build
ARG VERSION
COPY --from=stagex/core-busybox . /
COPY --from=stagex/core-bash . /
COPY --from=stagex/core-gzip . /
COPY --from=stagex/core-gcc . /
COPY --from=stagex/core-binutils . /
COPY --from=stagex/core-python . /
COPY --from=stagex/core-py-packaging . /
COPY --from=stagex/core-py-urllib3 . /
COPY --from=stagex/core-make . /
COPY --from=stagex/core-bison . /
COPY --from=stagex/core-meson . /
COPY --from=stagex/core-samurai . /
COPY --from=stagex/core-libtool . /
COPY --from=stagex/core-openssl . /
COPY --from=stagex/core-git . /
COPY --from=stagex/core-zlib . /
COPY --from=stagex/core-libffi . /
COPY --from=stagex/core-libzstd . /
COPY --from=stagex/core-ncurses . /
COPY --from=stagex/core-curl . /
COPY --from=stagex/core-flex . /
COPY --from=stagex/core-perl . /
COPY --from=stagex/core-pcre2 . /
COPY --from=stagex/core-autoconf . /
COPY --from=stagex/core-automake . /
COPY --from=stagex/core-pkgconf . /
COPY --from=stagex/core-gettext . /
COPY --from=stagex/core-m4 . /
COPY --from=stagex/core-argp-standalone . /
COPY --from=stagex/core-musl . /
COPY --from=stagex/core-musl-fts . /
COPY --from=stagex/core-musl-obstack . /
COPY --from=stagex/core-linux-headers . /
COPY --from=stagex/user-py-docutils . /
COPY --from=stagex/user-py-pygments . /
COPY --from=stagex/user-py-babel . /
COPY --from=stagex/user-py-sphinx . /
COPY --from=stagex/user-py-sphinx_rtd_theme . /
COPY --from=stagex/user-py-sphinxcontrib-applehelp . /
COPY --from=stagex/user-py-sphinxcontrib-devhelp . /
COPY --from=stagex/user-py-sphinxcontrib-htmlhelp . /
COPY --from=stagex/user-py-sphinxcontrib-qthelp . /
COPY --from=stagex/user-py-sphinxcontrib-serializinghtml . /
COPY --from=stagex/user-py-sphinxcontrib-jquery . /
COPY --from=stagex/user-py-jinja2 . /
COPY --from=stagex/user-py-markupsafe . /
COPY --from=stagex/user-py-snowballstemmer . /
COPY --from=stagex/user-py-imagesize . /
COPY --from=stagex/user-py-requests . /
COPY --from=stagex/user-py-idna . /
COPY --from=stagex/user-py-certifi . /
COPY --from=stagex/user-py-alabaster . /
COPY --from=stagex/user-libaio . /
COPY --from=stagex/user-libseccomp . /
COPY --from=stagex/user-libcap-ng . /
COPY --from=stagex/user-libslirp . /
COPY --from=stagex/user-alsa-lib . /
COPY --from=stagex/user-openssh . /
COPY --from=stagex/user-glib . /
COPY --from=stagex/user-lzo . /
COPY --from=stagex/user-dtc . /
COPY --from=stagex/user-numactl . /
COPY --from=stagex/user-canokey-qemu . /
ADD fetch/qemu-${VERSION}.tar.xz .
WORKDIR /qemu-${VERSION}
ADD *.patch .
ENV SOURCE_DATE_EPOCH=1
ENV LDFLAGS=" \
-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro \
-Wl,-z,now -Wl,-z,pack-relative-relocs"
ENV CFLAGS=" \
-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions \
-Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security \
-fstack-clash-protection -fcf-protection \
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"
ENV CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
ENV LTOFLAGS="-flto=auto"
ENV TARGET_LIST="x86_64-softmmu,x86_64-linux-user,i386-softmmu,i386-linux-user"
COPY <<-EOF pc-bios/optionrom/config.mak
TOPSRC_DIR=/qemu-${VERSION}
CC=gcc
CCAS=gcc
AR=ar
AS=as
LD=ld
NM=nm
OBJCOPY=objcopy
RANLIB=ranlib
STRIP=strip
EOF
RUN --network=none <<-EOF
set -eux
# rm -rf pc-bios/*.bz2
rm -rf \
pc-bios/*.bin \
pc-bios/*.rom \
pc-bios/*.img \
pc-bios/*.e500 \
pc-bios/*.dtb \
pc-bios/*.lid \
pc-bios/*.ndrv \
pc-bios/palcode-clipper \
pc-bios/openbios-*
make -j "$(nproc)" -C pc-bios/optionrom all
./configure \
--target-list="$TARGET_LIST" \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--libexecdir=/usr/lib/qemu \
--docdir=/usr/share/doc/qemu \
--python=/usr/bin/python \
--cc=gcc \
--audio-drv-list=oss,alsa \
--enable-canokey \
--enable-curses \
--enable-modules \
--enable-tpm \
--enable-vhost-net \
--enable-attr \
--enable-linux-user \
--enable-slirp \
--enable-tcg \
--enable-guest-agent \
--disable-install-blobs \
--disable-docs \
--disable-sdl \
--disable-gtk \
--disable-bpf \
--disable-capstone \
--disable-glusterfs \
--disable-debug-info \
--disable-opengl \
--disable-bsd-user \
--disable-werror \
--disable-libnfs \
--disable-libssh \
--disable-snappy \
--disable-spice \
--disable-usb-redir \
--disable-vde \
--disable-virglrenderer \
--disable-virtfs \
--disable-vnc \
--disable-vnc-jpeg \
--disable-xen
make ARFLAGS="rc" -j "$(nproc)"
make DESTDIR=/rootfs install
rm -rf /rootfs/var/run
strip /rootfs/usr/bin/qemu-*
install -vDm 644 pc-bios/optionrom/*.bin -t /rootfs/usr/share/qemu
install -vDm 644 pc-bios/optionrom/*.img -t /rootfs/usr/share/qemu
EOF
FROM stagex/core-filesystem AS package
COPY --from=build /rootfs/ /