net-wireless/bluez: Use acct-group/plugdev
[gentoo.git] / net-wireless / bluez / bluez-5.50-r3.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python2_7 )
7 inherit autotools python-single-r1 systemd udev user multilib-minimal
8
9 DESCRIPTION="Bluetooth Tools and System Daemons for Linux"
10 HOMEPAGE="http://www.bluez.org"
11 SRC_URI="
12         mirror://kernel/linux/bluetooth/${P}.tar.xz
13         https://dev.gentoo.org/~pacho/${PN}/${P}-fedora-backports.tar.xz
14 "
15
16 LICENSE="GPL-2+ LGPL-2.1+"
17 SLOT="0/3"
18 KEYWORDS="amd64 arm arm64 ~hppa ~mips ppc ppc64 x86"
19 IUSE="btpclient cups doc debug deprecated extra-tools experimental +mesh midi +obex +readline selinux systemd test test-programs +udev user-session"
20
21 # Since this release all remaining extra-tools need readline support, but this could
22 # change in the future, hence, this REQUIRED_USE constraint could be dropped
23 # again in the future.
24 REQUIRED_USE="
25         extra-tools? ( deprecated readline )
26         test? ( ${PYTHON_REQUIRED_USE} )
27         test-programs? ( ${PYTHON_REQUIRED_USE} )
28 "
29
30 TEST_DEPS="${PYTHON_DEPS}
31         >=dev-python/dbus-python-1[${PYTHON_USEDEP}]
32         dev-python/pygobject:3[${PYTHON_USEDEP}]
33 "
34 BDEPEND="
35         virtual/pkgconfig
36         test? ( ${TEST_DEPS} )
37 "
38 DEPEND="
39         >=dev-libs/glib-2.28:2[${MULTILIB_USEDEP}]
40         >=sys-apps/hwids-20121202.2
41         btpclient? ( >=dev-libs/ell-0.3 )
42         cups? ( net-print/cups:= )
43         mesh? (
44                 >=dev-libs/ell-0.3
45                 dev-libs/json-c:=
46                 sys-libs/readline:0=
47         )
48         midi? ( media-libs/alsa-lib )
49         obex? ( dev-libs/libical:= )
50         readline? ( sys-libs/readline:0= )
51         systemd? (
52                 >=sys-apps/dbus-1.6:=[user-session=]
53                 sys-apps/systemd
54         )
55         !systemd? ( >=sys-apps/dbus-1.6:= )
56         udev? ( >=virtual/udev-172 )
57 "
58 RDEPEND="${DEPEND}
59         selinux? ( sec-policy/selinux-bluetooth )
60         test-programs? ( ${TEST_DEPS} )
61 "
62
63 PATCHES=(
64         # Fix missing header (fixed in 'master')
65         "${FILESDIR}"/${P}-btpclient-header.patch
66
67         # Fix switch to A2DP sink profile
68         "${FILESDIR}"/${P}-sink-connect.patch
69
70         # Try both udevadm paths to cover udev/systemd vs. eudev locations (#539844)
71         # http://www.spinics.net/lists/linux-bluetooth/msg58739.html
72         "${FILESDIR}"/${PN}-udevadm-path-r1.patch
73
74         # build: Quote systemd variable names, bug #527432
75         # http://article.gmane.org/gmane.linux.bluez.kernel/67230
76         "${FILESDIR}"/${PN}-5.39-systemd-quote.patch
77
78         # Fedora patches
79         # http://www.spinics.net/lists/linux-bluetooth/msg40136.html
80         "${FILESDIR}"/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
81
82         # ???
83         "${FILESDIR}"/0004-agent-Assert-possible-infinite-loop.patch
84 )
85
86 pkg_setup() {
87         if use test || use test-programs; then
88                 python-single-r1_pkg_setup
89         fi
90
91         if ! use udev; then
92                 ewarn
93                 ewarn "You are installing ${PN} with USE=-udev. This means various bluetooth"
94                 ewarn "devices and adapters from Apple, Dell, Logitech etc. will not work,"
95                 ewarn "and hid2hci will not be available."
96                 ewarn
97         fi
98 }
99
100 src_prepare() {
101         default
102
103         # Apply Fedora backports
104         eapply "${WORKDIR}"/${P}-fedora-backports/*.patch
105
106         # http://www.spinics.net/lists/linux-bluetooth/msg38490.html
107         if ! use user-session || ! use systemd; then
108                 eapply "${FILESDIR}"/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch
109         fi
110
111         if use cups; then
112                 sed -i \
113                         -e "s:cupsdir = \$(libdir)/cups:cupsdir = $(cups-config --serverbin):" \
114                         Makefile.{in,tools} || die
115         fi
116
117         # Broken test https://bugzilla.kernel.org/show_bug.cgi?id=196621
118         sed -i -e '/unit_tests += unit\/test-gatt\b/d' Makefile.am || die
119
120         eautoreconf
121
122         multilib_copy_sources
123 }
124
125 multilib_src_configure() {
126         local myconf=(
127                 # readline is automagic when client is enabled
128                 # --enable-client always needs readline, bug #504038
129                 # --enable-mesh is handled in the same way
130                 ac_cv_header_readline_readline_h=$(multilib_native_usex readline)
131                 ac_cv_header_readline_readline_h=$(multilib_native_usex mesh)
132         )
133
134         if ! multilib_is_native_abi; then
135                 myconf+=(
136                         # deps not used for the library
137                         {DBUS,GLIB}_{CFLAGS,LIBS}=' '
138                 )
139         fi
140
141         econf \
142                 --localstatedir=/var \
143                 --disable-android \
144                 --enable-datafiles \
145                 --enable-optimization \
146                 $(use_enable debug) \
147                 --enable-pie \
148                 --enable-threads \
149                 --enable-library \
150                 --enable-tools \
151                 --enable-manpages \
152                 --enable-monitor \
153                 --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
154                 --with-systemduserunitdir="$(systemd_get_userunitdir)" \
155                 $(multilib_native_use_enable btpclient) \
156                 $(multilib_native_use_enable cups) \
157                 $(multilib_native_use_enable deprecated) \
158                 $(multilib_native_use_enable experimental) \
159                 $(multilib_native_use_enable mesh) \
160                 $(multilib_native_use_enable midi) \
161                 $(multilib_native_use_enable obex) \
162                 $(multilib_native_use_enable readline client) \
163                 $(multilib_native_use_enable systemd) \
164                 $(multilib_native_use_enable test-programs test) \
165                 $(multilib_native_use_enable udev) \
166                 $(multilib_native_use_enable udev sixaxis)
167 }
168
169 multilib_src_compile() {
170         if multilib_is_native_abi; then
171                 default
172         else
173                 emake -f Makefile -f - libs \
174                         <<<'libs: $(lib_LTLIBRARIES)'
175         fi
176 }
177
178 multilib_src_test() {
179         multilib_is_native_abi && default
180 }
181
182 multilib_src_install() {
183         if multilib_is_native_abi; then
184                 emake DESTDIR="${D}" install
185
186                 # Only install extra-tools when relevant USE flag is enabled
187                 if use extra-tools; then
188                         ewarn "Upstream doesn't support using this tools and their bugs are"
189                         ewarn "likely to be ignored forever, also that tools can break"
190                         ewarn "without previous announcement."
191                         ewarn "Upstream also states all this tools are not really needed,"
192                         ewarn "then, if you still need to rely on them, you must ask them"
193                         ewarn "to either install that tool by default or add the needed"
194                         ewarn "functionality to the existing 'official' tools."
195                         ewarn "Please report this issues to:"
196                         ewarn "http://www.bluez.org/development/lists/"
197
198                         # Upstream doesn't install this, bug #524640
199                         # http://permalink.gmane.org/gmane.linux.bluez.kernel/53115
200                         # http://comments.gmane.org/gmane.linux.bluez.kernel/54564
201                         # gatttool is only built with readline, bug #530776
202                         dobin attrib/gatttool
203                         dobin tools/btmgmt
204                 fi
205
206                 # Not installed by default after being built, bug #666756
207                 use btpclient && dobin tools/btpclient
208
209                 # Unittests are not that useful once installed, so make them optional
210                 if use test-programs; then
211                         # example-gatt-client is the only one needing
212                         # python3, the others are python2 only. Remove
213                         # until we see how to pull in python2 and python3
214                         # for runtime
215                         rm "${ED}"/usr/$(get_libdir)/bluez/test/example-gatt-server || die
216                         rm "${ED}"/usr/$(get_libdir)/bluez/test/example-gatt-client || die
217                         python_fix_shebang "${ED}"/usr/$(get_libdir)/bluez/test
218                         for i in $(find "${ED}"/usr/$(get_libdir)/bluez/test -maxdepth 1 -type f ! -name "*.*"); do
219                                 dosym "${i}" /usr/bin/bluez-"${i##*/}"
220                         done
221                 fi
222         else
223                 emake DESTDIR="${D}" \
224                         install-includeHEADERS \
225                         install-libLTLIBRARIES \
226                         install-pkgconfigDATA
227         fi
228 }
229
230 multilib_src_install_all() {
231         # We need to ensure obexd can be spawned automatically by systemd
232         # when user-session is enabled:
233         # http://marc.info/?l=linux-bluetooth&m=148096094716386&w=2
234         # https://bugs.gentoo.org/show_bug.cgi?id=577842
235         # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=804908
236         # https://bugs.archlinux.org/task/45816
237         # https://bugzilla.redhat.com/show_bug.cgi?id=1318441
238         # https://bugzilla.redhat.com/show_bug.cgi?id=1389347
239         if use user-session && use systemd; then
240                 ln -s "${ED}"/usr/lib/systemd/user/obex.service "${ED}"/usr/lib/systemd/user/dbus-org.bluez.obex.service
241         fi
242
243         find "${D}" -name '*.la' -delete || die
244
245         keepdir /var/lib/bluetooth
246
247         # Upstream don't want people to play with them
248         # But we keep installing them due to 'historical' reasons
249         insinto /etc/bluetooth
250         local d
251         for d in input network; do
252                 doins profiles/${d}/${d}.conf
253         done
254         doins src/main.conf
255
256         newinitd "${FILESDIR}"/bluetooth-init.d-r4 bluetooth
257
258         einstalldocs
259         use doc && dodoc doc/*.txt
260 }
261
262 pkg_postinst() {
263         use udev && udev_reload
264         systemd_reenable bluetooth.service
265
266         has_version net-dialup/ppp || elog "To use dial up networking you must install net-dialup/ppp."
267 }