class Mpd < Formula desc "Music Player Daemon" homepage "https://www.musicpd.org/" url "https://www.musicpd.org/download/mpd/0.21/mpd-0.21.5.tar.xz" sha256 "2ea9f0eb3a7bdae5d705adf4e8ec45ef38b5b9ddf133f32b8926dd4e205b0ef9" head "https://github.com/MusicPlayerDaemon/MPD.git" bottle do cellar :any sha256 "0d7097c4dc2715a22d52dfb043079af7caff6334c86f02df9a94d391e7c07a3d" => :mojave sha256 "53ac967273ff331d9935747054ca99ed0f928527d1c89ffbcc8a3b0d6b46386d" => :high_sierra sha256 "c4a226d7ac56d643e0a9e9cf767511b642340af52c157f7bf014fad25791e35b" => :sierra end depends_on "boost" => :build depends_on "meson" => :build depends_on "ninja" => :build depends_on "pkg-config" => :build depends_on "expat" depends_on "faad2" depends_on "ffmpeg" depends_on "flac" depends_on "fluid-synth" depends_on "glib" depends_on "icu4c" depends_on "lame" depends_on "libao" depends_on "libid3tag" depends_on "libmpdclient" depends_on "libnfs" depends_on "libsamplerate" depends_on "libupnp" depends_on "libvorbis" depends_on "opus" depends_on "sqlite" def install # mpd specifies -std=gnu++0x, but clang appears to try to build # that against libstdc++ anyway, which won't work. # The build is fine with G++. ENV.libcxx args = %W[ --prefix=#{prefix} --sysconfdir=#{etc} -Dlibwrap=disabled -Dmad=disabled -Dmpcdec=disabled -Dsoundcloud=disabled -Dao=enabled -Dbzip2=enabled -Dexpat=enabled -Dffmpeg=enabled -Dfluidsynth=enabled -Dnfs=enabled -Dupnp=enabled -Dvorbisenc=enabled ] system "meson", *args, "output/release", "." system "ninja", "-C", "output/release" ENV.deparallelize # Directories are created in parallel, so let's not do that system "ninja", "-C", "output/release", "install" (etc/"mpd").install "doc/mpdconf.example" => "mpd.conf" end def caveats; <<~EOS MPD requires a config file to start. Please copy it from #{etc}/mpd/mpd.conf into one of these paths: - ~/.mpd/mpd.conf - ~/.mpdconf and tailor it to your needs. EOS end plist_options :manual => "mpd" def plist; <<~EOS Label #{plist_name} WorkingDirectory #{HOMEBREW_PREFIX} ProgramArguments #{opt_bin}/mpd --no-daemon RunAtLoad KeepAlive ProcessType Interactive EOS end test do pid = fork do exec "#{bin}/mpd --stdout --no-daemon --no-config" end sleep 2 begin ohai "Connect to MPD command (localhost:6600)" TCPSocket.open("localhost", 6600) do |sock| assert_match "OK MPD", sock.gets ohai "Ping server" sock.puts("ping") assert_match "OK", sock.gets sock.close end ensure Process.kill "SIGINT", pid Process.wait pid end end end