Skip to content

Instantly share code, notes, and snippets.

@ngsctt
Created July 30, 2022 14:37
Show Gist options
  • Save ngsctt/7b800e8b11c966d005481b5c7224f956 to your computer and use it in GitHub Desktop.
Save ngsctt/7b800e8b11c966d005481b5c7224f956 to your computer and use it in GitHub Desktop.
Custom Homebrew formulae — see https://johnsiu.com/blog/macos-qemu-spice/
class QemuSpice < Formula
desc "Emulator for x86 and PowerPC"
homepage "https://www.qemu.org/"
url "https://download.qemu.org/qemu-7.1.0-rc0.tar.xz"
sha256 "50435f5fb361fbd57b7ec719290fd29f9a6ec96c73f04775a285a514085c7d6a"
license "GPL-2.0-only"
revision 1
head "https://git.qemu.org/git/qemu.git", branch: "master"
bottle do
rebuild 1
sha256 arm64_monterey: "f392a90d2ffce27b0dc370bf2d487b68bf15c174c5c22124f3ffef1bf77c3e6c"
sha256 arm64_big_sur: "961dd7152f2aa4cd3f87429a6928c77307748fdda00ad55c359b2b77c383d99c"
sha256 monterey: "083ca77ed158f6df966acbeeefd086fcb922ea5fe14cea4ff390475403c98686"
sha256 big_sur: "334d48d38b97e7724a64dacd2548594e5264e9995d117f8c4e81351574325090"
sha256 catalina: "806796c78fbb4c453361e94a502e1c0bdef1711959a6307334e4a97380475986"
sha256 x86_64_linux: "200b3d9d2b454dac6e6a0de585ca3267a1b3aab8de327548650de59b895498bd"
end
depends_on "libtool" => :build
depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "glib"
depends_on "gnutls"
depends_on "jpeg"
depends_on "libpng"
depends_on "libslirp"
depends_on "libssh"
depends_on "libusb"
depends_on "lzo"
depends_on "ncurses"
depends_on "nettle"
depends_on "pixman"
depends_on "snappy"
depends_on "vde"
depends_on "zstd"
on_linux do
depends_on "attr"
depends_on "gcc"
depends_on "gtk+3"
depends_on "libcap-ng"
end
fails_with gcc: "5"
# 820KB floppy disk image file of FreeDOS 1.2, used to test QEMU
resource "homebrew-test-image" do
url "https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/official/FD12FLOPPY.zip"
sha256 "81237c7b42dc0ffc8b32a2f5734e3480a3f9a470c50c14a9c4576a2561a35807"
end
# Fixes RDTSCP not being exposed to hosts
# See https://gitlab.com/qemu-project/qemu/-/issues/1011
patch do
url "https://gitlab.com/qemu-project/qemu/-/commit/d8cf2c29cc1077cd8f8ab0580b285bff92f09d1c.diff"
sha256 "b7c0db81e136fb3b9692e56f4c95abbcbd196dc0b7feb517241dda20d9ec3166"
end
def install
ENV["LIBTOOL"] = "glibtool"
args = %W[
--prefix=#{prefix}
--cc=#{ENV.cc}
--host-cc=#{ENV.cc}
--disable-bsd-user
--disable-guest-agent
--enable-curses
--enable-libssh
--enable-slirp=system
--enable-vde
--enable-virtfs
--enable-zstd
--extra-cflags=-DNCURSES_WIDECHAR=1
--disable-sdl
--enable-spice
--enable-vnc
--enable-vnc-jpeg
--enable-vnc-png
]
# Please remove this line when the CI gets updated to a recent version of Ubuntu(kernel version >= 4.9)
args << "--disable-linux-user"
# Sharing Samba directories in QEMU requires the samba.org smbd which is
# incompatible with the macOS-provided version. This will lead to
# silent runtime failures, so we set it to a Homebrew path in order to
# obtain sensible runtime errors. This will also be compatible with
# Samba installations from external taps.
args << "--smbd=#{HOMEBREW_PREFIX}/sbin/samba-dot-org-smbd"
args << "--disable-gtk" if OS.mac?
args << "--enable-cocoa" if OS.mac?
args << "--enable-gtk" if OS.linux?
system "./configure", *args
system "make", "V=1", "install"
end
test do
expected = build.stable? ? version.to_s : "QEMU Project"
assert_match expected, shell_output("#{bin}/qemu-system-aarch64 --version")
assert_match expected, shell_output("#{bin}/qemu-system-alpha --version")
assert_match expected, shell_output("#{bin}/qemu-system-arm --version")
assert_match expected, shell_output("#{bin}/qemu-system-cris --version")
assert_match expected, shell_output("#{bin}/qemu-system-hppa --version")
assert_match expected, shell_output("#{bin}/qemu-system-i386 --version")
assert_match expected, shell_output("#{bin}/qemu-system-m68k --version")
assert_match expected, shell_output("#{bin}/qemu-system-microblaze --version")
assert_match expected, shell_output("#{bin}/qemu-system-microblazeel --version")
assert_match expected, shell_output("#{bin}/qemu-system-mips --version")
assert_match expected, shell_output("#{bin}/qemu-system-mips64 --version")
assert_match expected, shell_output("#{bin}/qemu-system-mips64el --version")
assert_match expected, shell_output("#{bin}/qemu-system-mipsel --version")
assert_match expected, shell_output("#{bin}/qemu-system-nios2 --version")
assert_match expected, shell_output("#{bin}/qemu-system-or1k --version")
assert_match expected, shell_output("#{bin}/qemu-system-ppc --version")
assert_match expected, shell_output("#{bin}/qemu-system-ppc64 --version")
assert_match expected, shell_output("#{bin}/qemu-system-riscv32 --version")
assert_match expected, shell_output("#{bin}/qemu-system-riscv64 --version")
assert_match expected, shell_output("#{bin}/qemu-system-rx --version")
assert_match expected, shell_output("#{bin}/qemu-system-s390x --version")
assert_match expected, shell_output("#{bin}/qemu-system-sh4 --version")
assert_match expected, shell_output("#{bin}/qemu-system-sh4eb --version")
assert_match expected, shell_output("#{bin}/qemu-system-sparc --version")
assert_match expected, shell_output("#{bin}/qemu-system-sparc64 --version")
assert_match expected, shell_output("#{bin}/qemu-system-tricore --version")
assert_match expected, shell_output("#{bin}/qemu-system-x86_64 --version")
assert_match expected, shell_output("#{bin}/qemu-system-xtensa --version")
assert_match expected, shell_output("#{bin}/qemu-system-xtensaeb --version")
resource("homebrew-test-image").stage testpath
assert_match "file format: raw", shell_output("#{bin}/qemu-img info FLOPPY.img")
end
end
class SpiceMacos < Formula
desc "SPICE remote display system server component for macOS"
homepage "https://www.spice-space.org/"
url "https://gitlab.freedesktop.org/spice/spice.git"
version "master"
license "GNU LGPL 2.1+"
end
class Spice < Formula
depends_on "autoconf" => :build
depends_on "autoconf-archive" => :build
depends_on "autogen" => :build
depends_on "automake" => :build
depends_on "gobject-introspection" => :build
depends_on "intltool" => :build
depends_on "libtool" => :build
depends_on "pkg-config" => :build
depends_on "vala" => :build
depends_on "atk"
depends_on "cairo"
depends_on "gdk-pixbuf"
depends_on "gettext"
depends_on "glib"
depends_on "gst-libav"
depends_on "gst-plugins-bad"
depends_on "gst-plugins-base"
depends_on "gst-plugins-good"
depends_on "gst-plugins-ugly"
depends_on "gstreamer"
depends_on "gtk+3"
depends_on "jpeg"
depends_on "json-glib"
depends_on "libusb"
depends_on "lz4"
depends_on "openssl@1.1"
depends_on "opus"
depends_on "pango"
depends_on "pixman"
depends_on "spice-protocol"
depends_on "usbredir"
def install
system "./autogen.sh"
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=#{prefix}"
system "make", "install"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment