homebrew-core/Formula/virt-manager.rb

111 lines
4.3 KiB
Ruby

class VirtManager < Formula
include Language::Python::Virtualenv
desc "App for managing virtual machines"
homepage "https://virt-manager.org/"
url "https://virt-manager.org/download/sources/virt-manager/virt-manager-4.1.0.tar.gz"
sha256 "950681d7b32dc61669278ad94ef31da33109bf6fcf0426ed82dfd7379aa590a2"
license "GPL-2.0-or-later"
revision 1
head "https://github.com/virt-manager/virt-manager.git", branch: "main"
bottle do
sha256 cellar: :any, arm64_monterey: "933cb3be47ad74530134790be879f8ae2d2cd856cf24ef0f945733825cb4cfe2"
sha256 cellar: :any, arm64_big_sur: "047d1e006707eca158a33f76640bfac39a0f0050478d5333657663b1e2e79933"
sha256 cellar: :any, monterey: "cbbbc39c8a74c4564e5348ce6b4111241f6b8b5c18413060793f5098a9c2f9ee"
sha256 cellar: :any, big_sur: "68d7598d629d8d7a51762011d989a85ad6067f3c901d2a64a595f9bdd2576657"
sha256 cellar: :any, catalina: "e3fc0aa9c16ae9a1481a0089157262c2d821fe3b5a7f766273faedb65a05398a"
end
depends_on "docutils" => :build
depends_on "intltool" => :build
depends_on "pkg-config" => :build
depends_on "adwaita-icon-theme"
depends_on "cpio"
depends_on "gtk-vnc"
depends_on "gtksourceview4"
depends_on "libosinfo"
depends_on "libvirt-glib"
depends_on "libxml2" # can't use from macos, since we need python3 bindings
depends_on :macos
depends_on "osinfo-db"
depends_on "py3cairo"
depends_on "pygobject3"
depends_on "python@3.10"
depends_on "spice-gtk"
depends_on "vte3"
# Resources are for Python `libvirt-python` and `requests` packages
resource "certifi" do
url "https://files.pythonhosted.org/packages/cc/85/319a8a684e8ac6d87a1193090e06b6bbb302717496380e225ee10487c888/certifi-2022.6.15.tar.gz"
sha256 "84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d"
end
resource "charset-normalizer" do
url "https://files.pythonhosted.org/packages/a1/34/44964211e5410b051e4b8d2869c470ae8a68ae274953b1c7de6d98bbcf94/charset-normalizer-2.1.1.tar.gz"
sha256 "5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845"
end
resource "idna" do
url "https://files.pythonhosted.org/packages/62/08/e3fc7c8161090f742f504f40b1bccbfc544d4a4e09eb774bf40aafce5436/idna-3.3.tar.gz"
sha256 "9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
end
resource "libvirt-python" do
url "https://files.pythonhosted.org/packages/02/19/e694910782b77468b54848e7562072641e8fb39e3f4b0b825534b0cd9d3f/libvirt-python-8.7.0.tar.gz"
sha256 "60dcb571e44b6f0d7ca812addb513feac863c3c6c02282871cdfdcda5104dbb3"
end
resource "requests" do
url "https://files.pythonhosted.org/packages/a5/61/a867851fd5ab77277495a8709ddda0861b28163c4613b011bc00228cc724/requests-2.28.1.tar.gz"
sha256 "7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983"
end
resource "urllib3" do
url "https://files.pythonhosted.org/packages/b2/56/d87d6d3c4121c0bcec116919350ca05dc3afd2eeb7dc88d07e8083f8ea94/urllib3-1.26.12.tar.gz"
sha256 "3fa96cf423e6987997fc326ae8df396db2a8b7c667747d47ddd8ecba91f4a74e"
end
def install
python = "python3.10"
venv = virtualenv_create(libexec, python)
venv.pip_install resources
args = Language::Python.setup_install_args(prefix, python)
args.insert((args.index "install"), "--no-update-icon-cache", "--no-compile-schemas")
system libexec/"bin/python", "setup.py", "configure", "--prefix=#{prefix}"
system libexec/"bin/python", *args
end
def post_install
# manual schema compile step
system Formula["glib"].opt_bin/"glib-compile-schemas", HOMEBREW_PREFIX/"share/glib-2.0/schemas"
# manual icon cache update step
system Formula["gtk+3"].opt_bin/"gtk3-update-icon-cache", HOMEBREW_PREFIX/"share/icons/hicolor"
end
test do
libvirt_pid = fork do
exec Formula["libvirt"].opt_sbin/"libvirtd", "-f", Formula["libvirt"].etc/"libvirt/libvirtd.conf"
end
output = testpath/"virt-manager.log"
virt_manager_pid = fork do
$stdout.reopen(output)
$stderr.reopen(output)
exec bin/"virt-manager", "-c", "test:///default", "--debug"
end
sleep 10
assert_match "conn=test:///default changed to state=Active", output.read
ensure
Process.kill("TERM", libvirt_pid)
Process.kill("TERM", virt_manager_pid)
Process.wait(libvirt_pid)
Process.wait(virt_manager_pid)
end
end