From a813b941b82a48d04859669787cbbb21ea469f1e Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Fri, 22 Apr 2022 04:52:55 +0200 Subject: [PATCH] Ports: Add a QEMU port --- Ports/AvailablePorts.md | 1 + Ports/qemu/package.sh | 35 ++++++++++++++++ ...-build-system-support-for-SerenityOS.patch | 40 +++++++++++++++++++ ...d-short-scan-sets-into-the-full-list.patch | 29 ++++++++++++++ Ports/qemu/patches/ReadMe.md | 14 +++++++ 5 files changed, 119 insertions(+) create mode 100755 Ports/qemu/package.sh create mode 100644 Ports/qemu/patches/0001-Add-build-system-support-for-SerenityOS.patch create mode 100644 Ports/qemu/patches/0002-Extend-short-scan-sets-into-the-full-list.patch create mode 100644 Ports/qemu/patches/ReadMe.md diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md index 61fcf85525f..f0e944bad5b 100644 --- a/Ports/AvailablePorts.md +++ b/Ports/AvailablePorts.md @@ -193,6 +193,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n | [`pt2-clone`](pt2-clone/) | ProTracker 2 clone | 1.49 | https://github.com/8bitbubsy/pt2-clone | | [`pv`](pv/) | Pipe Viewer | 1.6.20 | http://www.ivarch.com/programs/pv.shtml | | [`python3`](python3/) | Python | 3.10.4 | https://www.python.org/ | +| [`qemu`](qemu/) | QEMU | 7.0.0 | https://qemu.org | | [`qoi`](qoi/) | Quite OK Image Format for fast, lossless image compression | edb8d7b | https://github.com/phoboslab/qoi | | [`qt6-qtbase`](qt6-qtbase/) | Qt6 QtBase | 6.2.3 | https://qt.io | | [`qt6-serenity`](qt6-serenity/) | QSerenityPlatform | | https://github.com/SerenityPorts/QSerenityPlatform | diff --git a/Ports/qemu/package.sh b/Ports/qemu/package.sh new file mode 100755 index 00000000000..fd5da4623d0 --- /dev/null +++ b/Ports/qemu/package.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env -S bash ../.port_include.sh +port='qemu' +version='7.0.0' +useconfigure='true' +configopts=( + "--target-list=aarch64-softmmu,i386-softmmu,x86_64-softmmu" + "--cross-prefix=${SERENITY_ARCH}-pc-serenity-" + "--extra-ldflags=-lm" + "--without-default-features" + "--disable-strip" + "--enable-pie" + "--enable-sdl" + "--enable-tcg" + "--enable-tools" +) +depends=("glib" "pixman" "SDL2") +files="https://download.qemu.org/qemu-${version}.tar.xz qemu-${version}.tar.xz f6b375c7951f728402798b0baabb2d86478ca53d44cedbefabbe1c46bf46f839" +auth_type='sha256' + +pre_patch() { + # Disable tests (those need way more stuff than QEMU itself) by clearing the respective meson file. + echo '' > "${workdir}/tests/meson.build" +} + +post_install() { + # Add a drop-in fstab entry to make sure that we can use anonymous executable memory and bypass W^X + mkdir -p "${SERENITY_INSTALL_ROOT}/etc/fstab.d" + rm -rf "${SERENITY_INSTALL_ROOT}/etc/fstab.d/qemu" + for i in /usr/local/bin/qemu-system-{aarch64,i386,x86_64}; do + echo "${i} ${i} bind bind,wxallowed,axallowed" >> "${SERENITY_INSTALL_ROOT}/etc/fstab.d/qemu" + done +} + +# We don't have '-pc-serenity-pkg-config', so just use the "normal" one. +export PKG_CONFIG="pkg-config" diff --git a/Ports/qemu/patches/0001-Add-build-system-support-for-SerenityOS.patch b/Ports/qemu/patches/0001-Add-build-system-support-for-SerenityOS.patch new file mode 100644 index 00000000000..cc2640948fc --- /dev/null +++ b/Ports/qemu/patches/0001-Add-build-system-support-for-SerenityOS.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tim Schumacher +Date: Thu, 5 May 2022 18:49:17 +0200 +Subject: [PATCH] Add build system support for SerenityOS + +--- + configure | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/configure b/configure +index 7c08c18..3177605 100755 +--- a/configure ++++ b/configure +@@ -496,6 +496,8 @@ elif check_define __NetBSD__; then + targetos=netbsd + elif check_define __APPLE__; then + targetos=darwin ++elif check_define __serenity__; then ++ targetos=serenity + else + # This is a fatal error, but don't report it yet, because we + # might be going to just print the --help text, or it might +@@ -509,6 +511,7 @@ mingw32="no" + bsd="no" + linux="no" + solaris="no" ++serenity="no" + case $targetos in + windows) + mingw32="yes" +@@ -565,6 +568,9 @@ linux) + linux="yes" + vhost_user=${default_feature:-yes} + ;; ++serenity) ++ serenity="yes" ++;; + esac + + if test ! -z "$cpu" ; then diff --git a/Ports/qemu/patches/0002-Extend-short-scan-sets-into-the-full-list.patch b/Ports/qemu/patches/0002-Extend-short-scan-sets-into-the-full-list.patch new file mode 100644 index 00000000000..356a604a2bf --- /dev/null +++ b/Ports/qemu/patches/0002-Extend-short-scan-sets-into-the-full-list.patch @@ -0,0 +1,29 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tim Schumacher +Date: Thu, 5 May 2022 18:50:31 +0200 +Subject: [PATCH] Extend short scan sets into the full list + +We don't support the (apparently nonstandard) short variant of scan +sets, so extend them into a full list manually. +--- + chardev/char.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/chardev/char.c b/chardev/char.c +index 0169d8d..03ce487 100644 +--- a/chardev/char.c ++++ b/chardev/char.c +@@ -382,11 +382,11 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename, + if (strstart(filename, "vc", &p)) { + qemu_opt_set(opts, "backend", "vc", &error_abort); + if (*p == ':') { +- if (sscanf(p+1, "%7[0-9]x%7[0-9]", width, height) == 2) { ++ if (sscanf(p+1, "%7[0123456789]x%7[0123456789]", width, height) == 2) { + /* pixels */ + qemu_opt_set(opts, "width", width, &error_abort); + qemu_opt_set(opts, "height", height, &error_abort); +- } else if (sscanf(p+1, "%7[0-9]Cx%7[0-9]C", width, height) == 2) { ++ } else if (sscanf(p+1, "%7[0123456789]Cx%7[0123456789]C", width, height) == 2) { + /* chars */ + qemu_opt_set(opts, "cols", width, &error_abort); + qemu_opt_set(opts, "rows", height, &error_abort); diff --git a/Ports/qemu/patches/ReadMe.md b/Ports/qemu/patches/ReadMe.md new file mode 100644 index 00000000000..9ff0f4b617a --- /dev/null +++ b/Ports/qemu/patches/ReadMe.md @@ -0,0 +1,14 @@ +# Patches for qemu on SerenityOS + +## `0001-Add-build-system-support-for-SerenityOS.patch` + +Add build system support for SerenityOS + + +## `0002-Extend-short-scan-sets-into-the-full-list.patch` + +Extend short scan sets into the full list + +We don't support the (apparently nonstandard) short variant of scan +sets, so extend them into a full list manually. +