Created
February 6, 2022 03:24
-
-
Save yveszoundi/22ef1fe023d48f04879d04fd0352fef8 to your computer and use it in GitHub Desktop.
MacOS QEMU homebrew formula with spice support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Qemu < Formula | |
desc "Emulator for x86 and PowerPC" | |
homepage "https://www.qemu.org/" | |
url "https://download.qemu.org/qemu-6.2.0.tar.xz" | |
sha256 "68e15d8e45ac56326e0b9a4afa8b49a3dfe8aba3488221d098c84698bca65b45" | |
license "GPL-2.0-only" | |
head "https://git.qemu.org/git/qemu.git", branch: "master" | |
bottle do | |
sha256 arm64_monterey: "57ffc7f97cbd053121f7767f08c2386beac29ef8efa7f93398d347b24d979621" | |
sha256 arm64_big_sur: "4550d24a0d2e6a708bdce2364087cb684b8655e18b8426fa6ef4d5dae8f68279" | |
sha256 monterey: "b543588b7415090b74759097084dd2104139f4a8e778204cc3bce2b280603c32" | |
sha256 big_sur: "8f1b83d17955d66e6df076a1d0abd4a00fdf91d23a0644d696a5937e1e64d156" | |
sha256 catalina: "16455455bed508272b6de05d7f75c9d26b1e7bed3349f1fd56d361a3bc601616" | |
sha256 x86_64_linux: "93904b6e664abd95780e085c21eee15312b3bd56f742fbbfa1ccb03ec6762003" | |
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 "spice" | |
on_linux do | |
depends_on "gcc" | |
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/FD12FLOPPY.zip" | |
sha256 "81237c7b42dc0ffc8b32a2f5734e3480a3f9a470c50c14a9c4576a2561a35807" | |
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 | |
--extra-cflags=-DNCURSES_WIDECHAR=1 | |
--disable-sdl | |
--disable-gtk | |
--enable-spice | |
--enable-spice-protocol | |
--enable-vnc | |
--enable-vnc-jpeg | |
--enable-vnc-png | |
] | |
# 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 << "--enable-cocoa" if OS.mac? | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment