homebrew-core/Formula/libvirt.rb

93 lines
2.5 KiB
Ruby

class Libvirt < Formula
desc "C virtualization API"
homepage "https://www.libvirt.org"
url "https://libvirt.org/sources/libvirt-7.0.0.tar.xz"
sha256 "ca3833844d08c22867f1d1a46edc36bda7d6fe1a4f267e7d77100b79fc9ddd89"
license all_of: ["LGPL-2.1-or-later", "GPL-2.0-or-later"]
livecheck do
url "https://libvirt.org/sources/"
regex(/href=.*?libvirt[._-]v?([\d.]+)\.t/i)
end
bottle do
sha256 "e938967382f8bbaf26fa13347af40cd447277bcefd66363057a16aa84599dc71" => :big_sur
sha256 "34251a1f80e19044ac5b7f59978fef583ca543ec0da3a2ce202274585ccb14af" => :catalina
sha256 "c067a0606d1ed6bdf8d9a3338bfc31c3ee4e856ee9b55f52b8bc004b39db5083" => :mojave
end
head do
url "https://github.com/libvirt/libvirt.git"
end
depends_on "docutils" => :build
depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "perl" => :build
depends_on "pkg-config" => :build
depends_on "python@3.9" => :build
depends_on "rpcgen" => :build
depends_on "gettext"
depends_on "glib"
depends_on "gnutls"
depends_on "libgcrypt"
depends_on "libiscsi"
depends_on "libssh2"
depends_on "yajl"
def install
mkdir "build" do
args = %W[
--localstatedir=#{var}
--mandir=#{man}
--sysconfdir=#{etc}
-Ddriver_esx=enabled
-Ddriver_qemu=enabled
-Dinit_script=none
]
system "meson", *std_meson_args, *args, ".."
system "meson", "compile"
system "meson", "install"
end
end
plist_options manual: "libvirtd"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>#{HOMEBREW_PREFIX}/bin</string>
</dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{sbin}/libvirtd</string>
<string>-f</string>
<string>#{etc}/libvirt/libvirtd.conf</string>
</array>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
if build.head?
output = shell_output("#{bin}/virsh -V")
assert_match "Compiled with support for:", output
else
output = shell_output("#{bin}/virsh -v")
assert_match version.to_s, output
end
end
end