Skip to content

Commit 5b7b48a

Browse files
committed
go-librespot 0.3.3 (new formula)
1 parent 369172c commit 5b7b48a

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

Formula/g/go-librespot.rb

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
class GoLibrespot < Formula
2+
desc "Spotify client"
3+
homepage "https://github.com/devgianlu/go-librespot"
4+
url "https://github.com/devgianlu/go-librespot/archive/refs/tags/v0.3.3.tar.gz"
5+
sha256 "15678b4d6954b381fb9c5a84aca2b0d7706e4d0b2c3644bafcb79cea6d31064c"
6+
license "GPL-3.0-only"
7+
head "https://github.com/devgianlu/go-librespot.git", branch: "master"
8+
9+
depends_on "go" => :build
10+
depends_on "pkgconf" => :build
11+
depends_on "libogg"
12+
depends_on "libvorbis"
13+
14+
on_linux do
15+
depends_on "alsa-lib"
16+
end
17+
18+
def install
19+
ldflags = %W[
20+
-s -w
21+
-X github.com/devgianlu/go-librespot.version=#{version}
22+
]
23+
ldflags << "-X github.com/devgianlu/go-librespot.commit=#{Utils.git_short_head(length: 8)}" if build.head?
24+
25+
system "go", "build", *std_go_args(output: bin/"go-librespot", ldflags: ldflags), "./cmd/daemon"
26+
27+
# On macOS, create a minimal config that selects the correct backend.
28+
return unless OS.mac?
29+
30+
(buildpath/"config.yml").write <<~YAML
31+
# Auto-generated by Homebrew. You can edit this file.
32+
# Use CoreAudio via AudioToolbox on macOS.
33+
audio_backend: audio-toolbox
34+
YAML
35+
pkgetc.install "config.yml"
36+
end
37+
38+
def post_install
39+
(var/"log").mkpath
40+
end
41+
42+
service do
43+
run [opt_bin/"go-librespot", "--config_dir", etc/"go-librespot"]
44+
keep_alive true
45+
log_path var/"log/go-librespot.log"
46+
error_log_path var/"log/go-librespot.log"
47+
end
48+
49+
test do
50+
cfg = testpath/"config.yml"
51+
cfg.write <<~YAML
52+
volume_steps: not_a_number
53+
YAML
54+
55+
output = shell_output("#{bin}/go-librespot --config_dir #{testpath} 2>&1", 1)
56+
assert_match "failed loading config", output
57+
assert_match "failed to unmarshal configuration", output
58+
end
59+
end

0 commit comments

Comments
 (0)