137 lines
3.6 KiB
Ruby
137 lines
3.6 KiB
Ruby
class Mpd < Formula
|
|
desc "Music Player Daemon"
|
|
homepage "https://www.musicpd.org/"
|
|
url "https://www.musicpd.org/download/mpd/0.21/mpd-0.21.25.tar.xz"
|
|
sha256 "20a0ad01bf327b2dbeb6ae8e1af952cb0de83d2d63fab0fa4b7183a74765c201"
|
|
license "GPL-2.0"
|
|
head "https://github.com/MusicPlayerDaemon/MPD.git"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "e0f7ce87e92b540230d05c111f5571a568d6b75562b2d4b5abcc2975dde45a7a" => :catalina
|
|
sha256 "f21a70a4d1c8ebcc7c72caa6d7284c1a549c6c630290a9b4c7cc1b5ced1415ea" => :mojave
|
|
sha256 "b2ac7ec06cd9dd81f63f1bd1ce0bd6eff8171d2c5b0f79e385a05d01ddad2db2" => :high_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 "libgcrypt"
|
|
depends_on "libid3tag"
|
|
depends_on "libmpdclient"
|
|
depends_on "libnfs"
|
|
depends_on "libsamplerate"
|
|
depends_on "libshout"
|
|
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 = std_meson_args + %W[
|
|
--sysconfdir=#{etc}
|
|
-Dlibwrap=disabled
|
|
-Dmad=disabled
|
|
-Dmpcdec=disabled
|
|
-Dsoundcloud=disabled
|
|
-Dao=enabled
|
|
-Dbzip2=enabled
|
|
-Dexpat=enabled
|
|
-Dffmpeg=enabled
|
|
-Dfluidsynth=enabled
|
|
-Dnfs=enabled
|
|
-Dshout=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
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>WorkingDirectory</key>
|
|
<string>#{HOMEBREW_PREFIX}</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>#{opt_bin}/mpd</string>
|
|
<string>--no-daemon</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>KeepAlive</key>
|
|
<true/>
|
|
<key>ProcessType</key>
|
|
<string>Interactive</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
port = free_port
|
|
|
|
(testpath/"mpd.conf").write <<~EOS
|
|
bind_to_address "127.0.0.1"
|
|
port "#{port}"
|
|
EOS
|
|
|
|
pid = fork do
|
|
exec "#{bin}/mpd --stdout --no-daemon #{testpath}/mpd.conf"
|
|
end
|
|
sleep 5
|
|
|
|
begin
|
|
ohai "Connect to MPD command (localhost:#{port})"
|
|
TCPSocket.open("localhost", port) 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
|