Source

FROM stagex/pallet-clang-meson-busybox AS build
ARG VERSION
COPY --from=stagex/core-bash . /
COPY --from=stagex/core-binutils . /
COPY --from=stagex/core-gzip . /
COPY --from=stagex/core-py-packaging . /
COPY --from=stagex/core-py-urllib3 . /
COPY --from=stagex/core-git . /
COPY --from=stagex/core-curl . /
COPY --from=stagex/core-pcre2 . /
COPY --from=stagex/core-make . /
COPY --from=stagex/core-gettext . /
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-distlib . /
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-libusb . /
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
RUN --network=none <<-EOF
	export LTOFLAGS="-flto=auto"
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--libexecdir=/usr/lib/qemu \
		--docdir=/usr/share/doc/qemu \
		--python=/usr/bin/python \
		--cc=clang \
		--audio-drv-list=oss,alsa \
		--enable-canokey \
		--enable-curses \
		--enable-modules \
		--enable-tpm \
		--enable-vhost-net \
		--enable-attr \
		--enable-linux-aio \
		--enable-slirp \
		--enable-libusb \
		--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-linux-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-*
	# HACK: none of these binaries are deterministic so we cannot ship them
	# Would love if anyone can figure this out but cannot let it block release
	rm /rootfs/usr/bin/qemu-system-aarch64
	rm /rootfs/usr/bin/qemu-system-arm
	rm /rootfs/usr/bin/qemu-system-hppa
	rm /rootfs/usr/bin/qemu-system-loongarch64
	rm /rootfs/usr/bin/qemu-system-mips
	rm /rootfs/usr/bin/qemu-system-mips64
	rm /rootfs/usr/bin/qemu-system-mips64el
	rm /rootfs/usr/bin/qemu-system-mipsel
	rm /rootfs/usr/bin/qemu-system-or1k
	rm /rootfs/usr/bin/qemu-system-ppc
	rm /rootfs/usr/bin/qemu-system-ppc64
	rm /rootfs/usr/bin/qemu-system-riscv32
	rm /rootfs/usr/bin/qemu-system-riscv64
	rm /rootfs/usr/bin/qemu-system-rx
	rm /rootfs/usr/bin/qemu-system-sparc
	rm /rootfs/usr/bin/qemu-system-sparc64
	rm /rootfs/usr/bin/qemu-system-avr                                        
	rm /rootfs/usr/bin/qemu-system-i386                                       
	rm /rootfs/usr/bin/qemu-system-m68k                                       
	rm /rootfs/usr/bin/qemu-system-microblaze
	rm /rootfs/usr/bin/qemu-system-microblazeel
EOF

#HACK: These have not been updated or built in more than a decade
# All distros use the binary blobs stored in the tree
# Using GCC to build them in isolation is the lesser evil
# Also, they are firmware used only at runtime, so this
# will not present any incompatibility problems
COPY --from=stagex/core-gcc . /
COPY --from=stagex/core-mpfr . /
COPY --from=stagex/core-mpc . /
COPY --from=stagex/core-isl . /
COPY --from=stagex/core-gmp . /
COPY <<-EOF pc-bios/optionrom/config.mak
		TOPSRC_DIR=/qemu-${VERSION}
		CC=/usr/bin/gcc
		LD=/usr/bin/ld
EOF
RUN --network=none <<-EOF
	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 -dC pc-bios/optionrom all
	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/ /
Copied to clipboard!