142 lines
4.3 KiB
Ruby
142 lines
4.3 KiB
Ruby
class Mpd < Formula
|
|
desc "Music Player Daemon"
|
|
homepage "https://www.musicpd.org/"
|
|
url "https://www.musicpd.org/download/mpd/0.23/mpd-0.23.8.tar.xz"
|
|
sha256 "86bb569bf3b519821f36f6bb5564e484e85d2564411b34b200fe2cd3a04e78cf"
|
|
license "GPL-2.0-or-later"
|
|
head "https://github.com/MusicPlayerDaemon/MPD.git", branch: "master"
|
|
|
|
livecheck do
|
|
url "https://www.musicpd.org/download.html"
|
|
regex(/href=.*?mpd[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "c1e5f343586226a73515a55ab6eefdfc4f612d1228d8a61448932b80c0ee34a2"
|
|
sha256 cellar: :any, arm64_big_sur: "f49c948bee82b0295edcd6e737de721f34042660a35d3d985d198ae46bcb1a42"
|
|
sha256 cellar: :any, monterey: "548e4d6980f7d6494e3a8a2ac1fa1eb9a8567f2f91a234ce008ed57f7ae68593"
|
|
sha256 cellar: :any, big_sur: "18fb691d0de481fe2f71853b6b4d3e9e883ba39aecc1e64be712e6925d8a1cec"
|
|
sha256 cellar: :any, catalina: "fb403070b7af2733711ac15cb30f9e4fee565959ff0ffbf3895b20d676ddbe5d"
|
|
sha256 x86_64_linux: "718a4161042fe464adc1a0591f229a3fc69cd1dce5ef236a7e8d55743230dd9b"
|
|
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 "fmt"
|
|
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 macos: :mojave # requires C++17 features unavailable in High Sierra
|
|
depends_on "opus"
|
|
depends_on "sqlite"
|
|
|
|
uses_from_macos "curl"
|
|
|
|
on_linux do
|
|
depends_on "gcc"
|
|
end
|
|
|
|
fails_with gcc: "5"
|
|
|
|
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
|
|
|
|
# Replace symbols available only on macOS 12+ with their older versions.
|
|
# https://github.com/MusicPlayerDaemon/MPD/issues/1580
|
|
if MacOS.version <= :big_sur
|
|
new_syms = ["kAudioObjectPropertyElementMain", "kAudioHardwareServiceDeviceProperty_VirtualMainVolume"]
|
|
# Doing `ENV.append_to_cflags` twice results in line length errors.
|
|
new_syms.each do |new_sym|
|
|
old_sym = new_sym.sub("Main", "Master")
|
|
ENV.append_to_cflags "-D#{new_sym}=#{old_sym}"
|
|
end
|
|
end
|
|
|
|
args = %W[
|
|
--sysconfdir=#{etc}
|
|
-Dmad=disabled
|
|
-Dmpcdec=disabled
|
|
-Dsoundcloud=disabled
|
|
-Dao=enabled
|
|
-Dbzip2=enabled
|
|
-Dexpat=enabled
|
|
-Dffmpeg=enabled
|
|
-Dfluidsynth=enabled
|
|
-Dnfs=enabled
|
|
-Dshout=enabled
|
|
-Dupnp=pupnp
|
|
-Dvorbisenc=enabled
|
|
]
|
|
|
|
system "meson", "setup", "output/release", *args, *std_meson_args
|
|
system "meson", "compile", "-C", "output/release"
|
|
ENV.deparallelize # Directories are created in parallel, so let's not do that
|
|
system "meson", "install", "-C", "output/release"
|
|
|
|
pkgetc.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
|
|
|
|
service do
|
|
run [opt_bin/"mpd", "--no-daemon"]
|
|
keep_alive true
|
|
process_type :interactive
|
|
working_dir HOMEBREW_PREFIX
|
|
end
|
|
|
|
test do
|
|
# oss_output: Error opening OSS device "/dev/dsp": No such file or directory
|
|
# oss_output: Error opening OSS device "/dev/sound/dsp": No such file or directory
|
|
return if OS.linux? && ENV["HOMEBREW_GITHUB_ACTIONS"]
|
|
|
|
require "expect"
|
|
|
|
port = free_port
|
|
|
|
(testpath/"mpd.conf").write <<~EOS
|
|
bind_to_address "127.0.0.1"
|
|
port "#{port}"
|
|
EOS
|
|
|
|
io = IO.popen("#{bin}/mpd --stdout --no-daemon #{testpath}/mpd.conf 2>&1", "r")
|
|
io.expect("output: Successfully detected a osx audio device", 30)
|
|
|
|
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
|
|
end
|
|
end
|