class Netatalk < Formula desc "File server for Macs, compliant with Apple Filing Protocol (AFP)" homepage "https://netatalk.io" url "https://github.com/Netatalk/netatalk/releases/download/netatalk-4-2-4/netatalk-4.2.4.tar.xz" sha256 "4f07bbe118a951dd740d3f51a87b5cafba2496bd0b22e704438f421aa6670f99" license all_of: [ "GPL-2.0-only", "GPL-2.0-or-later", "LGPL-2.0-only", "LGPL-2.1-or-later", "BSD-2-Clause", "BSD-3-Clause", "MIT", ] head "https://github.com/Netatalk/netatalk.git", branch: "main" no_autobump! because: :incompatible_version_format bottle do sha256 arm64_sequoia: "17e4d6ffd0039fbe4adfc873f576685a068a1755974d14890e5592371d9ac960" sha256 arm64_sonoma: "d74905541c89f537266a677868cb5ff6cc0230975e1e619dbeacbdc82fa1437a" sha256 arm64_ventura: "1404002f05914d1cdfaa843e113499bfe67d05cfeac50ed6e91304b9b2b9f1e1" sha256 sonoma: "759e86a275a1ac958615fc9d837bea59a2d4f13ad7cf60b3e40ce34816bd34d7" sha256 ventura: "d0ce9f60f70a3896ca49ac8d13ac87c9946342f5225e467b8e50b88b3e7e7fdc" sha256 arm64_linux: "c792a362f93a358adc2a44683c83649eb54b7513254cc444ea18c7b04830a5be" sha256 x86_64_linux: "ead1152fc2b9997022839c082bc9419328858bd46426f0b0fb673944cf4b2df8" end depends_on "cmark-gfm" => :build depends_on "meson" => :build depends_on "ninja" => :build depends_on "pkgconf" => :build depends_on "berkeley-db@5" # macOS bdb library lacks DBC type etc. depends_on "cracklib" depends_on "iniparser" depends_on "libevent" depends_on "libgcrypt" depends_on "mariadb-connector-c" depends_on "openldap" # macOS LDAP.Framework is not fork safe uses_from_macos "krb5" uses_from_macos "libxcrypt" uses_from_macos "perl" on_linux do depends_on "avahi" # on macOS we use native mDNS instead depends_on "cups" # used by the AppleTalk print server depends_on "libtirpc" # on macOS we use native RPC instead depends_on "linux-pam" end conflicts_with "ad", because: "both install `ad` binaries" def install inreplace "distrib/initscripts/macos.netatalk.in", "@sbindir@", opt_sbin inreplace "distrib/initscripts/macos.netatalk.plist.in", "@bindir@", opt_bin inreplace "distrib/initscripts/macos.netatalk.plist.in", "@sbindir@", opt_sbin inreplace "distrib/initscripts/systemd.netatalk.service.in", "@sbindir@", opt_sbin bdb5_rpath = rpath(target: Formula["berkeley-db@5"].opt_lib) ENV.append "LDFLAGS", "-Wl,-rpath,#{bdb5_rpath}" if OS.linux? args = [ "-Dwith-afpstats=false", "-Dwith-appletalk=#{OS.linux?}", # macOS doesn't have an AppleTalk stack "-Dwith-bdb-path=#{Formula["berkeley-db@5"].opt_prefix}", "-Dwith-cups-libdir-path=#{libexec}", "-Dwith-cups-pap-backend=#{OS.linux?}", "-Dwith-docs=man,readmes,html_manual", "-Dwith-homebrew=true", "-Dwith-init-dir=#{prefix}", "-Dwith-init-hooks=false", "-Dwith-install-hooks=false", "-Dwith-lockfile-path=#{var}/run", "-Dwith-pam-config-path=#{etc}/pam.d", "-Dwith-rpath=false", "-Dwith-spotlight=false", "-Dwith-statedir-path=#{var}", ] system "meson", "setup", "build", *args, *std_meson_args system "meson", "compile", "-C", "build", "--verbose" system "meson", "install", "-C", "build" end service do name macos: "io.netatalk.daemon", linux: "netatalk" require_root true end def caveats on_macos do on_arm do <<~EOS Authenticating as a system user requires manually installing the PAM configuration file to a predetermined location by running: sudo install -d -o $USER -g admin /usr/local/etc mkdir -p /usr/local/etc/pam.d cp $(brew --prefix)/etc/pam.d/netatalk /usr/local/etc/pam.d See `man pam.conf` for more information. EOS end end end test do system sbin/"netatalk", "-V" system sbin/"afpd", "-V" assert_empty shell_output(sbin/"netatalk") end end