class Fwupd < Formula include Language::Python::Virtualenv desc "Firmware update daemon" homepage "https://github.com/fwupd/fwupd" url "https://github.com/fwupd/fwupd/releases/download/2.0.19/fwupd-2.0.19.tar.xz" sha256 "3bb7a4a1e2d00f0ab513e4c667d7bf5a3ff34a9802757849d3fedf07dd40ddbb" license "LGPL-2.1-or-later" head "https://github.com/fwupd/fwupd.git", branch: "main" bottle do sha256 arm64_tahoe: "2fa5b73d90474196fc4c078ef381628c55047831cdff94c57d7ff4f4416c99c9" sha256 arm64_sequoia: "7d44c4946e051921de152f991b466e3d5de1005b3a4d8b6960012498a658a676" sha256 arm64_sonoma: "36de29b6636c587053425b12fafa8405e01001041a451bc6da2dbc16c8e596d5" sha256 sonoma: "575239e884179f1ef9a1384d1637bb9b42decf4769a423ce3467ca781807a737" sha256 arm64_linux: "2c608dd2dc0c8d735145a76baa9cc7c45c5d03897e5d1cabeb03681fc9ee2f36" sha256 x86_64_linux: "4d217c35f0ab6ed08b01646301856026e20d8da0548387368ad4c8bd255b7773" end depends_on "gettext" => :build # for msgfmt depends_on "gobject-introspection" => :build depends_on "meson" => :build depends_on "ninja" => :build depends_on "pkgconf" => [:build, :test] depends_on "python@3.14" => :build depends_on "vala" => :build depends_on "glib" depends_on "gnutls" depends_on "json-glib" depends_on "libarchive" depends_on "libcbor" depends_on "libjcat" depends_on "libusb" depends_on "libxmlb" depends_on "protobuf-c" depends_on "readline" depends_on "sqlite" depends_on "usb.ids" depends_on "xz" uses_from_macos "curl" uses_from_macos "zlib" on_macos do depends_on "gettext" end on_linux do depends_on "util-linux" end pypi_packages package_name: "", extra_packages: ["jinja2", "markupsafe"] resource "jinja2" do url "https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz" sha256 "0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d" end resource "markupsafe" do url "https://files.pythonhosted.org/packages/7e/99/7690b6d4034fffd95959cbe0c02de8deb3098cc577c67bb6a24fe5d7caa7/markupsafe-3.0.3.tar.gz" sha256 "722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698" end def python3 "python3.14" end def install venv = virtualenv_create(buildpath/"venv", python3) venv.pip_install resources ENV.prepend_path "PYTHONPATH", buildpath/"venv"/Language::Python.site_packages(python3) system "meson", "setup", "build", "-Dbuild=standalone", # this is used as PolicyKit is not available on macOS "-Dlibarchive=enabled", # fail if missing "-Dpython=#{which(python3)}", "-Dsupported_build=enabled", "-Dplugin_flashrom=disabled", "-Dplugin_modem_manager=disabled", "-Dplugin_uefi_capsule_splash=false", "-Dtests=false", "-Ddocs=disabled", "-Dvendor_ids_dir=#{Formula["usb.ids"].opt_share}/misc/usb.ids", *std_meson_args system "meson", "compile", "-C", "build", "--verbose" system "meson", "install", "-C", "build" end test do # check apps like gnome-firmware can link (testpath/"test.c").write <<~C #include int main(int argc, char *argv[]) { FwupdClient *client = fwupd_client_new(); g_assert_nonnull(client); return 0; } C pkgconf_flags = shell_output("pkgconf --cflags --libs fwupd").chomp.split system ENV.cc, "test.c", "-o", "test", *pkgconf_flags system "./test" # this is a lame test, but fwupdtool requires root access to do anything much interesting system bin/"fwupdtool", "-h" end end