forked from Homebrew/homebrew-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpd.rb
147 lines (129 loc) · 4.09 KB
/
mpd.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
class Mpd < Formula
desc "Music Player Daemon"
homepage "https://www.musicpd.org/"
url "https://www.musicpd.org/download/mpd/0.22/mpd-0.22.6.tar.xz"
sha256 "2be149a4895c3cb613477f8cf1193593e3d8a1d38a75ffa7d32da8c8316a4d5e"
license "GPL-2.0-or-later"
revision 2
head "https://github.com/MusicPlayerDaemon/MPD.git"
bottle do
sha256 cellar: :any, arm64_big_sur: "17788f621266bae943e912f8ec02c09e4a82fee90b071868dbf47279012892c5"
sha256 cellar: :any, big_sur: "6ad7522c6793e94000346e9ebfeffb16be3cf5e7b6137d980727bfd0709f7335"
sha256 cellar: :any, catalina: "ec2f59889ddd17efe2b15029ab61878798bd3fcd302229edf029891b08245b75"
sha256 cellar: :any, mojave: "d3aac34e250c84974268cae2fd7aeda94dba391768f5df9a246cc63899a0a002"
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 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
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
on_linux 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 ENV["HOMEBREW_GITHUB_ACTIONS"]
end
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