-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
runner
authored and
runner
committed
Sep 23, 2024
1 parent
fc68e01
commit adb3351
Showing
1 changed file
with
133 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
class Qemu < Formula | ||
desc "Generic machine emulator and virtualizer" | ||
homepage "https://www.qemu.org/" | ||
url "https://download.qemu.org/qemu-9.0.2.tar.xz" | ||
sha256 "a8c3f596aece96da3b00cafb74baafa0d14515eafb8ed1ee3f7f5c2d0ebf02b6" | ||
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 | ||
|
||
bottle do | ||
sha256 arm64_sonoma: "f7c729dfe2f6ff174b0e68ef67f6904f7228167f9fa138f05ea56fcc876f2861" | ||
sha256 arm64_ventura: "20c6cc71639d1c2db5333ceeb9a5d8ddffbb96c02599a1f6fdca1ddfc088481e" | ||
sha256 arm64_monterey: "80be85976762b70be78b797254e58bf095d49cc5bf8b3e28e61a8743c76f961e" | ||
sha256 sonoma: "8b4446ccb692293a7d6f7b5950739f2e33477e75d03e86c1400bdeb2ff9b328e" | ||
sha256 ventura: "9fd7800fc9eb9821615e556f53f0735d88455afef8baa2ed98c8f9eebbd840d5" | ||
sha256 monterey: "a3491a35f409c26099e6f2a4d1c640d1349ea23478bd72cd85e3b38e68e04902" | ||
sha256 x86_64_linux: "333b9bc3a3e36feae843fec7383187ee3799a2e443d4c644f4674064a6bc28cb" | ||
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 | ||
uses_from_macos "bzip2" | ||
uses_from_macos "zlib" | ||
|
||
on_linux do | ||
depends_on "attr" | ||
depends_on "cairo" | ||
depends_on "elfutils" | ||
depends_on "gdk-pixbuf" | ||
depends_on "gtk+3" | ||
depends_on "libcap-ng" | ||
depends_on "libepoxy" | ||
depends_on "libx11" | ||
depends_on "libxkbcommon" | ||
depends_on "mesa" | ||
depends_on "systemd" | ||
end | ||
|
||
fails_with gcc: "5" | ||
|
||
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 | ||
# 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 | ||
|
||
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 |