class QemuIscsi < Formula desc "Generic machine emulator and virtualizer (with libiscsi support)" homepage "https://www.qemu.org/" url "https://download.qemu.org/qemu-11.0.0.tar.xz" sha256 "c04ca36012653f32d11c674d370cf52a710e7d3f18c2d8b63e4932052a4854d6" license "GPL-2.0-only" head "https://gitlab.com/qemu-project/qemu.git", branch: "master" livecheck do url "https://www.qemu.org/download/" regex(/href=.*?qemu[._-]v?(\d+(?:\.\d+)+)\.t/i) end conflicts_with "qemu", because: "qemu-iscsi installs the same binaries as qemu" depends_on "libtool" => :build depends_on "meson" => :build depends_on "ninja" => :build depends_on "pkgconf" => :build depends_on "python-setuptools" => :build depends_on "python@3.14" => :build depends_on "spice-protocol" => :build depends_on "capstone" depends_on "dtc" depends_on "glib" depends_on "gnutls" depends_on "jpeg-turbo" depends_on "libiscsi" depends_on "libpng" depends_on "libslirp" depends_on "libssh" depends_on "libusb" depends_on "lzo" depends_on "ncurses" depends_on "pixman" depends_on "snappy" depends_on "vde" depends_on "zstd" uses_from_macos "bison" => :build uses_from_macos "flex" => :build uses_from_macos "bzip2" on_linux do depends_on "attr" depends_on "cairo" depends_on "elfutils" depends_on "gdk-pixbuf" depends_on "gtk+3" depends_on "keyutils" depends_on "libcap-ng" depends_on "libepoxy" depends_on "libx11" depends_on "libxkbcommon" depends_on "mesa" depends_on "systemd" depends_on "zlib-ng-compat" end def install ENV["LIBTOOL"] = "glibtool" # Remove wheels unless explicitly permitted. Currently this: # * removes `meson` so that brew `meson` is always used # * keeps `pycotap` and `qemu_qmp` which are pure-python "none-any" wheels (allowed in homebrew/core) rm(Dir["python/wheels/*"] - Dir["python/wheels/{pycotap,qemu_qmp}-*-none-any.whl"]) args = %W[ --prefix=#{prefix} --cc=#{ENV.cc} --host-cc=#{ENV.cc} --disable-bsd-user --disable-download --disable-guest-agent --enable-slirp --enable-capstone --enable-curses --enable-fdt=system --enable-libiscsi --enable-libssh --enable-vde --enable-virtfs --enable-zstd --extra-cflags=-DNCURSES_WIDECHAR=1 --disable-sdl ] 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 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 archs = %w[ aarch64 alpha arm avr hppa i386 loongarch64 m68k microblaze mips mips64 mips64el mipsel or1k ppc ppc64 riscv32 riscv64 rx s390x sh4 sh4eb sparc sparc64 tricore x86_64 xtensa xtensaeb ] archs.each do |guest_arch| assert_match version.to_s, 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") assert_match "iscsi", shell_output("#{bin}/qemu-system-x86_64 -drive format=? 2>&1") 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