class Qemu < Formula desc "Emulator for x86 and PowerPC" homepage "https://www.qemu.org/" url "https://download.qemu.org/qemu-8.1.3.tar.xz" sha256 "43cc176804105586f74f90398f34e9f85787dff400d3b640d81f7779fbe265bb" license "GPL-2.0-only" revision 2 head "https://git.qemu.org/git/qemu.git", branch: "master" livecheck do url "https://www.qemu.org/download/" regex(/href=.*?qemu[._-]v?(\d+(?:\.\d+)+)\.t/i) end bottle do sha256 arm64_sonoma: "0e014bd08f9cba2d8f7fa9f080abd56a22fbad130709735af5d7d5808dfb6f67" sha256 arm64_ventura: "93a9c3f749e636642d8910a4620a4b3c4bc2c5a13e1b7a24a23506115b21d884" sha256 arm64_monterey: "5e1f8994011ef7624396b0fd0dfb7d473a057d5740b4756a4268fc0b0ef99842" sha256 sonoma: "4e02534017485a86218a0e0285788afea3ce4fe3e91956dc80cfe8e43d264b9d" sha256 ventura: "7d9f4cdc4d1990981734cbb027851dc0174ad76c7405c8860c79c2af41f1ad1c" sha256 monterey: "834e334ab5149ad89fed06b5a2e5213ab37a743d5ca0911a021a4cc79fd61a74" sha256 x86_64_linux: "f01852dbfd458d73b4be1f62299e43474d15dfd530ed3a3604fc4ac30a2fb97a" end depends_on "libtool" => :build depends_on "meson" => :build depends_on "ninja" => :build depends_on "pkg-config" => :build depends_on "spice-protocol" => :build depends_on "capstone" depends_on "dtc" depends_on "glib" depends_on "gnutls" depends_on "jpeg-turbo" 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" uses_from_macos "bison" => :build uses_from_macos "flex" => :build on_linux do depends_on "attr" 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 def install ENV["LIBTOOL"] = "glibtool" args = %W[ --prefix=#{prefix} --cc=#{ENV.cc} --host-cc=#{ENV.cc} --disable-bsd-user --disable-guest-agent --enable-slirp --enable-capstone --enable-curses --enable-fdt=system --enable-libssh --enable-vde --enable-virtfs --enable-zstd --extra-cflags=-DNCURSES_WIDECHAR=1 --disable-sdl ] # 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 += if OS.mac? ["--disable-gtk", "--enable-cocoa"] else ["--enable-gtk"] end system "./configure", *args system "make", "V=1", "install" end test do expected = build.stable? ? version.to_s : "QEMU Project" archs = %w[ aarch64 alpha arm cris hppa i386 m68k microblaze microblazeel mips mips64 mips64el mipsel nios2 or1k ppc ppc64 riscv32 riscv64 rx s390x sh4 sh4eb sparc sparc64 tricore x86_64 xtensa xtensaeb ] archs.each do |guest_arch| assert_match expected, shell_output("#{bin}/qemu-system-#{guest_arch} --version") end resource("homebrew-test-image").stage testpath assert_match "file format: raw", shell_output("#{bin}/qemu-img info FLOPPY.img") # On macOS, verify that we haven't clobbered the signature on the qemu-system-x86_64 binary if OS.mac? output = shell_output("codesign --verify --verbose #{bin}/qemu-system-x86_64 2>&1") assert_match "valid on disk", output assert_match "satisfies its Designated Requirement", output end end end