class Clamav < Formula desc "Anti-virus software" homepage "https://www.clamav.net/" url "https://github.com/Cisco-Talos/clamav/releases/download/clamav-1.5.1/clamav-1.5.1.tar.gz" mirror "https://www.clamav.net/downloads/production/clamav-1.5.1.tar.gz" sha256 "64fe4a16a5622c1d71efe9ed7f2c2fbd37f8f237da9f11ff66b73038df71db91" license "GPL-2.0-or-later" revision 1 head "https://github.com/Cisco-Talos/clamav.git", branch: "main" livecheck do url :stable strategy :github_latest end bottle do rebuild 2 sha256 arm64_tahoe: "db4a62ff1e9d672ae1c2c73553dfc777c79c3a9832d9bfef98f0de517460f287" sha256 arm64_sequoia: "aafd1995cb986eca71904a610737c11587b153755d95efea5cfd68e55dd2801a" sha256 arm64_sonoma: "f0b3970e44a1ddbc27909a552d6f51fc8774406936ed0d157292d99e6b012106" sha256 sonoma: "3397a457aa043b820dacbc5a773cd31555f5d953458c2113def81d87a8d6a8f8" sha256 arm64_linux: "7396dfd64356c87f980385437040bfc9d116e395d7dfa7b2c2c26badcdc42da0" sha256 x86_64_linux: "059c8ee25e8e6864c50764d245343ab48d75df67c90d432445010b49412fbca2" end depends_on "cmake" => :build depends_on "pkgconf" => :build depends_on "rust" => :build depends_on "json-c" depends_on "openssl@3" depends_on "pcre2" depends_on "yara" uses_from_macos "bzip2" uses_from_macos "curl" uses_from_macos "libxml2" uses_from_macos "ncurses" on_linux do depends_on "zlib-ng-compat" end skip_clean "share/clamav" def install args = %W[ -DAPP_CONFIG_DIRECTORY=#{pkgetc} -DDATABASE_DIRECTORY=#{var}/lib/clamav -DENABLE_JSON_SHARED=ON -DENABLE_STATIC_LIB=ON -DENABLE_SHARED_LIB=ON -DENABLE_EXAMPLES=OFF -DENABLE_TESTS=OFF -DENABLE_MILTER=OFF ] system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args system "cmake", "--build", "build" system "cmake", "--install", "build" (var/"lib/clamav").mkpath end service do run [opt_sbin/"clamd", "--foreground"] keep_alive true require_root true end def caveats <<~EOS To finish installation & run clamav you will need to edit the example conf files at #{pkgetc}/ EOS end test do assert_match "Database directory: #{var}/lib/clamav", shell_output("#{bin}/clamconf") (testpath/"freshclam.conf").write <<~EOS DNSDatabaseInfo current.cvd.clamav.net DatabaseMirror database.clamav.net EOS system bin/"freshclam", "--datadir=#{testpath}", "--config-file=#{testpath}/freshclam.conf" system bin/"clamscan", "--database=#{testpath}", testpath end end