summaryrefslogtreecommitdiff
path: root/media-sound/snapcast/snapcast-0.34.0.ebuild
blob: 7fa9c222fee703fb95080af59074f4ad0ae848db (plain)
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
148
149
150
151
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{13..14} )
inherit cmake edo optfeature python-single-r1 systemd

DESCRIPTION="Synchronous multi-room audio player"
HOMEPAGE="https://github.com/snapcast/snapcast"
SRC_URI="https://github.com/snapcast/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="GPL-3+"
SLOT="0"
KEYWORDS="amd64 ~arm ppc ppc64 ~riscv x86"
IUSE="alsa +client +expat +flac jack +opus pipewire python +server soxr ssl test tremor +vorbis +zeroconf"
REQUIRED_USE="
	|| ( server client )
	server? (
		python? ( ${PYTHON_REQUIRED_USE} )
	)
"
RESTRICT="!test? ( test )"

RDEPEND="
	alsa? ( media-libs/alsa-lib )
	client? (
		acct-user/snapclient
		tremor? (
			media-libs/libogg
			media-libs/tremor
		)
	)
	flac? ( media-libs/flac:= )
	jack? ( virtual/jack )
	opus? ( media-libs/opus )
	pipewire? ( media-video/pipewire:= )
	server? (
		acct-group/snapserver
		>=acct-user/snapserver-0-r3
		expat? ( dev-libs/expat )
		python? ( ${PYTHON_DEPS} )
	)
	soxr? ( media-libs/soxr )
	ssl? ( dev-libs/openssl:= )
	vorbis? (
		media-libs/libogg
		media-libs/libvorbis
	)
	zeroconf? ( net-dns/avahi[dbus] )
"
DEPEND="
	${RDEPEND}
	dev-cpp/nlohmann_json
	dev-libs/boost:=
	jack? ( dev-libs/boost:=[context] )
	test? (
		>=dev-cpp/catch-3:0
		dev-libs/openssl
	)
"

PATCHES=(
	"${FILESDIR}"/${PN}-0.34.0-snapclient_group.patch
	"${FILESDIR}"/${PN}-0.34.0-opt_soxr.patch
	"${FILESDIR}"/${PN}-0.34.0-drop-lint.patch
)

pkg_setup() {
	use server && use python && python-single-r1_pkg_setup
}

src_prepare() {
	# 3rd-party
	rm common/json.hpp || die
	sed -e 's@"common/json.hpp"@<nlohmann/json.hpp>@' \
		-i common/message/json_message.hpp \
		-i common/stream_uri.hpp \
		-i server/control_server.cpp \
		-i server/streamreader/metadata.hpp \
		-i server/streamreader/pcm_stream.hpp \
		-i server/streamreader/properties.hpp \
		-i server/config.hpp \
		-i server/jsonrpcpp.hpp \
		-i server/jwt.hpp || die

	cmake_src_prepare
}

src_configure() {
	local mycmakeargs=(
		-DBUILD_CLIENT=$(usex client)
		-DBUILD_SERVER=$(usex server)
		-DBUILD_STATIC_LIBS=no
		-DBUILD_TESTS=$(usex test)
		-DCMAKE_INSTALL_SYSCONFDIR="${EPREFIX}/etc"
		-DBUILD_WITH_ALSA=$(usex alsa)
		-DBUILD_WITH_AVAHI=$(usex zeroconf)
		-DBUILD_WITH_EXPAT=$(usex expat)
		-DBUILD_WITH_FLAC=$(usex flac)
		-DBUILD_WITH_JACK=$(usex jack)
		-DBUILD_WITH_OPUS=$(usex opus)
		-DBUILD_WITH_PIPEWIRE=$(usex pipewire)
		-DBUILD_WITH_SOXR=$(usex soxr)
		-DBUILD_WITH_SSL=$(usex ssl)
		-DBUILD_WITH_TREMOR=$(usex tremor)
		-DBUILD_WITH_VORBIS=$(usex vorbis)
	)

	cmake_src_configure
}

src_test() {
	edo "${S}"/bin/snapcast_test
}

src_install() {
	cmake_src_install

	local bin
	for bin in server client ; do
		if use ${bin} ; then
			doman ${bin}/snap${bin}.1

			newconfd "${FILESDIR}"/snap${bin}.confd-r1 snap${bin}
			newinitd "${FILESDIR}"/snap${bin}.initd-r1 snap${bin}
			systemd_dounit extras/package/rpm/snap${bin}.service
		fi
	done

	if use server; then
		if use python; then
			python_fix_shebang "${ED}"/usr/share/snapserver/plug-ins
		else
			rm "${ED}"/usr/share/snapserver/plug-ins/*.py || die
		fi
	fi
}

pkg_postinst() {
	if use client && ! use zeroconf; then
		ewarn "zeroconf is disabled but the url by default is 'tcp://_snapcast._tcp'."
		ewarn "Please define an url in SNAPCLIENT_OPTS into ${EROOT}/etc/conf.d/snapclient"
	fi
	if use server && use python; then
		optfeature "librespot stream plugin" dev-python/websocket-client dev-python/requests
		optfeature "mopidy stream plugin" dev-python/websocket-client
		optfeature "mpd stream plugin" dev-python/dbus-python dev-python/musicbrainzngs
		optfeature "mpd stream plugin" dev-python/pygobject dev-python/python-mpd2
	fi
}