Gentoo Archives: gentoo-commits

From: Pacho Ramos <pacho@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-wireless/bluez/files/, net-wireless/bluez/
Date: Wed, 23 May 2018 18:52:34
Message-Id: 1527101541.5f6f22e0b7c30080a493a439178ee2b7a92b4afe.pacho@gentoo
1 commit: 5f6f22e0b7c30080a493a439178ee2b7a92b4afe
2 Author: Pacho Ramos <pacho <AT> gentoo <DOT> org>
3 AuthorDate: Wed May 23 18:36:23 2018 +0000
4 Commit: Pacho Ramos <pacho <AT> gentoo <DOT> org>
5 CommitDate: Wed May 23 18:52:21 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5f6f22e0
7
8 net-wireless/bluez: Fix crash with non-LE devices (#655114)
9
10 Package-Manager: Portage-2.3.31, Repoman-2.3.9
11
12 net-wireless/bluez/bluez-5.49-r1.ebuild | 263 +++++++++++++++++++++
13 .../bluez/files/bluez-5.49-crash-non-LE.patch | 51 ++++
14 2 files changed, 314 insertions(+)
15
16 diff --git a/net-wireless/bluez/bluez-5.49-r1.ebuild b/net-wireless/bluez/bluez-5.49-r1.ebuild
17 new file mode 100644
18 index 00000000000..d5c27acdb57
19 --- /dev/null
20 +++ b/net-wireless/bluez/bluez-5.49-r1.ebuild
21 @@ -0,0 +1,263 @@
22 +# Copyright 1999-2018 Gentoo Foundation
23 +# Distributed under the terms of the GNU General Public License v2
24 +
25 +EAPI=6
26 +PYTHON_COMPAT=( python2_7 )
27 +
28 +inherit autotools multilib python-single-r1 readme.gentoo-r1 systemd udev user multilib-minimal
29 +
30 +DESCRIPTION="Bluetooth Tools and System Daemons for Linux"
31 +HOMEPAGE="http://www.bluez.org"
32 +SRC_URI="mirror://kernel/linux/bluetooth/${P}.tar.xz"
33 +
34 +LICENSE="GPL-2+ LGPL-2.1+"
35 +SLOT="0/3"
36 +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~x86"
37 +IUSE="alsa cups doc debug deprecated extra-tools experimental +mesh +obex +readline selinux systemd test test-programs +udev user-session"
38 +
39 +# Since this release all remaining extra-tools need readline support, but this could
40 +# change in the future, hence, this REQUIRED_USE constraint could be dropped
41 +# again in the future.
42 +REQUIRED_USE="
43 + extra-tools? ( deprecated readline )
44 + test? ( ${PYTHON_REQUIRED_USE} )
45 + test-programs? ( ${PYTHON_REQUIRED_USE} )
46 + user-session? ( systemd )
47 +"
48 +
49 +CDEPEND="
50 + >=dev-libs/glib-2.28:2[${MULTILIB_USEDEP}]
51 + >=sys-apps/dbus-1.6:=[user-session=]
52 + >=sys-apps/hwids-20121202.2
53 + alsa? ( media-libs/alsa-lib )
54 + cups? ( net-print/cups:= )
55 + mesh? (
56 + dev-libs/json-c:=
57 + sys-libs/readline:0= )
58 + obex? ( dev-libs/libical:= )
59 + readline? ( sys-libs/readline:0= )
60 + systemd? ( sys-apps/systemd )
61 + udev? ( >=virtual/udev-172 )
62 +"
63 +TEST_DEPS="${PYTHON_DEPS}
64 + >=dev-python/dbus-python-1[${PYTHON_USEDEP}]
65 + dev-python/pygobject:3[${PYTHON_USEDEP}]
66 +"
67 +
68 +DEPEND="${CDEPEND}
69 + virtual/pkgconfig
70 + test? ( ${TEST_DEPS} )
71 +"
72 +RDEPEND="${CDEPEND}
73 + selinux? ( sec-policy/selinux-bluetooth )
74 + test-programs? ( ${TEST_DEPS} )
75 +"
76 +DOC_CONTENTS="
77 + If you want to control your bluetooth devices as a non-root user,
78 + please remember to add you to plugdev group.
79 +"
80 +
81 +PATCHES=(
82 + # Use static group "plugdev" to not force people to become root for
83 + # controlling the devices.
84 + "${FILESDIR}"/${PN}-plugdev.patch
85 +
86 + # Try both udevadm paths to cover udev/systemd vs. eudev locations (#539844)
87 + # http://www.spinics.net/lists/linux-bluetooth/msg58739.html
88 + "${FILESDIR}"/${PN}-udevadm-path.patch
89 +
90 + # build: Quote systemd variable names, bug #527432
91 + # http://article.gmane.org/gmane.linux.bluez.kernel/67230
92 + "${FILESDIR}"/${PN}-5.39-systemd-quote.patch
93 +
94 + # Fedora patches
95 + # http://www.spinics.net/lists/linux-bluetooth/msg40136.html
96 + "${FILESDIR}"/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
97 +
98 + # ???
99 + "${FILESDIR}"/0004-agent-Assert-possible-infinite-loop.patch
100 +
101 + # https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=2c3bba7b38be03834162e34069156f1fd49f0528
102 + # Fixed in next version
103 + "${FILESDIR}"/${P}-crash-non-LE.patch
104 +)
105 +
106 +pkg_setup() {
107 + enewgroup plugdev
108 +
109 + if use test || use test-programs; then
110 + python-single-r1_pkg_setup
111 + fi
112 +
113 + if ! use udev; then
114 + ewarn
115 + ewarn "You are installing ${PN} with USE=-udev. This means various bluetooth"
116 + ewarn "devices and adapters from Apple, Dell, Logitech etc. will not work,"
117 + ewarn "and hid2hci will not be available."
118 + ewarn
119 + fi
120 +}
121 +
122 +src_prepare() {
123 + default
124 +
125 + # http://www.spinics.net/lists/linux-bluetooth/msg38490.html
126 + ! use user-session && eapply "${FILESDIR}"/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch
127 +
128 + if use cups; then
129 + sed -i \
130 + -e "s:cupsdir = \$(libdir)/cups:cupsdir = $(cups-config --serverbin):" \
131 + Makefile.{in,tools} || die
132 + fi
133 +
134 + # Broken test https://bugzilla.kernel.org/show_bug.cgi?id=196621
135 + sed -i -e '/unit_tests += unit\/test-gatt\b/d' Makefile.am || die
136 +
137 + eautoreconf
138 +
139 + multilib_copy_sources
140 +}
141 +
142 +multilib_src_configure() {
143 + local myconf=(
144 + # readline is automagic when client is enabled
145 + # --enable-client always needs readline, bug #504038
146 + # --enable-mesh is handled in the same way
147 + ac_cv_header_readline_readline_h=$(multilib_native_usex readline)
148 + ac_cv_header_readline_readline_h=$(multilib_native_usex mesh)
149 + )
150 +
151 + if ! multilib_is_native_abi; then
152 + myconf+=(
153 + # deps not used for the library
154 + {DBUS,GLIB}_{CFLAGS,LIBS}=' '
155 + )
156 + fi
157 +
158 + # btpclient disabled because we don't have ell library in the tree
159 + econf \
160 + --localstatedir=/var \
161 + --disable-android \
162 + --disable-btpclient \
163 + --enable-datafiles \
164 + --enable-experimental \
165 + --enable-optimization \
166 + $(use_enable debug) \
167 + --enable-pie \
168 + --enable-threads \
169 + --enable-library \
170 + --enable-tools \
171 + --enable-manpages \
172 + --enable-monitor \
173 + --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
174 + --with-systemduserunitdir="$(systemd_get_userunitdir)" \
175 + $(multilib_native_use_enable alsa midi) \
176 + $(multilib_native_use_enable cups) \
177 + $(multilib_native_use_enable deprecated) \
178 + $(multilib_native_use_enable experimental) \
179 + $(multilib_native_use_enable mesh) \
180 + $(multilib_native_use_enable obex) \
181 + $(multilib_native_use_enable readline client) \
182 + $(multilib_native_use_enable systemd) \
183 + $(multilib_native_use_enable test-programs test) \
184 + $(multilib_native_use_enable udev) \
185 + $(multilib_native_use_enable udev sixaxis)
186 +}
187 +
188 +multilib_src_compile() {
189 + if multilib_is_native_abi; then
190 + default
191 + else
192 + emake -f Makefile -f - libs \
193 + <<<'libs: $(lib_LTLIBRARIES)'
194 + fi
195 +}
196 +
197 +multilib_src_test() {
198 + multilib_is_native_abi && default
199 +}
200 +
201 +multilib_src_install() {
202 + if multilib_is_native_abi; then
203 + emake DESTDIR="${D}" install
204 +
205 + # Only install extra-tools when relevant USE flag is enabled
206 + if use extra-tools; then
207 + ewarn "Upstream doesn't support using this tools and their bugs are"
208 + ewarn "likely to be ignored forever, also that tools can break"
209 + ewarn "without previous announcement."
210 + ewarn "Upstream also states all this tools are not really needed,"
211 + ewarn "then, if you still need to rely on them, you must ask them"
212 + ewarn "to either install that tool by default or add the needed"
213 + ewarn "functionality to the existing 'official' tools."
214 + ewarn "Please report this issues to:"
215 + ewarn "http://www.bluez.org/development/lists/"
216 +
217 + # Upstream doesn't install this, bug #524640
218 + # http://permalink.gmane.org/gmane.linux.bluez.kernel/53115
219 + # http://comments.gmane.org/gmane.linux.bluez.kernel/54564
220 + # gatttool is only built with readline, bug #530776
221 + dobin attrib/gatttool
222 + dobin tools/btmgmt
223 + fi
224 +
225 + # Unittests are not that useful once installed, so make them optional
226 + if use test-programs; then
227 + # example-gatt-client is the only one needing
228 + # python3, the others are python2 only. Remove
229 + # until we see how to pull in python2 and python3
230 + # for runtime
231 + rm "${ED}"/usr/$(get_libdir)/bluez/test/example-gatt-server || die
232 + rm "${ED}"/usr/$(get_libdir)/bluez/test/example-gatt-client || die
233 + python_fix_shebang "${ED}"/usr/$(get_libdir)/bluez/test
234 + for i in $(find "${ED}"/usr/$(get_libdir)/bluez/test -maxdepth 1 -type f ! -name "*.*"); do
235 + dosym "${i}" /usr/bin/bluez-"${i##*/}"
236 + done
237 + fi
238 + else
239 + emake DESTDIR="${D}" \
240 + install-includeHEADERS \
241 + install-libLTLIBRARIES \
242 + install-pkgconfigDATA
243 + fi
244 +}
245 +
246 +multilib_src_install_all() {
247 + # We need to ensure obexd can be spawned automatically by systemd
248 + # when user-session is enabled:
249 + # http://marc.info/?l=linux-bluetooth&m=148096094716386&w=2
250 + # https://bugs.gentoo.org/show_bug.cgi?id=577842
251 + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=804908
252 + # https://bugs.archlinux.org/task/45816
253 + # https://bugzilla.redhat.com/show_bug.cgi?id=1318441
254 + # https://bugzilla.redhat.com/show_bug.cgi?id=1389347
255 + use user-session && ln -s "${ED}"/usr/lib/systemd/user/obex.service "${ED}"/usr/lib/systemd/user/dbus-org.bluez.obex.service
256 +
257 + find "${D}" -name '*.la' -delete || die
258 +
259 + keepdir /var/lib/bluetooth
260 +
261 + # Upstream don't want people to play with them
262 + # But we keep installing them due to 'historical' reasons
263 + insinto /etc/bluetooth
264 + local d
265 + for d in input network; do
266 + doins profiles/${d}/${d}.conf
267 + done
268 + doins src/main.conf
269 +
270 + newinitd "${FILESDIR}"/bluetooth-init.d-r4 bluetooth
271 +
272 + einstalldocs
273 + use doc && dodoc doc/*.txt
274 + ! use systemd && readme.gentoo_create_doc
275 +}
276 +
277 +pkg_postinst() {
278 + ! use systemd && readme.gentoo_print_elog
279 +
280 + use udev && udev_reload
281 + systemd_reenable bluetooth.service
282 +
283 + has_version net-dialup/ppp || elog "To use dial up networking you must install net-dialup/ppp."
284 +}
285
286 diff --git a/net-wireless/bluez/files/bluez-5.49-crash-non-LE.patch b/net-wireless/bluez/files/bluez-5.49-crash-non-LE.patch
287 new file mode 100644
288 index 00000000000..b66868e7140
289 --- /dev/null
290 +++ b/net-wireless/bluez/files/bluez-5.49-crash-non-LE.patch
291 @@ -0,0 +1,51 @@
292 +From 2c3bba7b38be03834162e34069156f1fd49f0528 Mon Sep 17 00:00:00 2001
293 +From: "antoine.belvire@×××××××.net" <antoine.belvire@×××××××.net>
294 +Date: Tue, 27 Mar 2018 20:30:26 +0200
295 +Subject: adapter: Don't refresh adv_manager for non-LE devices
296 +
297 +btd_adv_manager_refresh is called upon MGMT_SETTING_DISCOVERABLE setting change
298 +but as only LE adapters have an adv_manager, this leads to segmentation fault
299 +for non-LE devices:
300 +
301 +0 btd_adv_manager_refresh (manager=0x0) at src/advertising.c:1176
302 +1 0x0000556fe45fcb02 in settings_changed (settings=<optimized out>,
303 + adapter=0x556fe53f7c70) at src/adapter.c:543
304 +2 new_settings_callback (index=<optimized out>, length=<optimized out>,
305 + param=<optimized out>, user_data=0x556fe53f7c70) at src/adapter.c:573
306 +3 0x0000556fe462c278 in request_complete (mgmt=mgmt@entry=0x556fe53f20c0,
307 + status=<optimized out>, opcode=opcode@entry=7, index=index@entry=0,
308 + length=length@entry=4, param=0x556fe53eb5f9) at src/shared/mgmt.c:261
309 +4 0x0000556fe462cd9d in can_read_data (io=<optimized out>,
310 + user_data=0x556fe53f20c0) at src/shared/mgmt.c:353
311 +5 0x0000556fe46396e3 in watch_callback (channel=<optimized out>,
312 + cond=<optimized out>, user_data=<optimized out>)
313 + at src/shared/io-glib.c:170
314 +6 0x00007fe351c980e5 in g_main_context_dispatch ()
315 + from /usr/lib64/libglib-2.0.so.0
316 +7 0x00007fe351c984b0 in ?? () from /usr/lib64/libglib-2.0.so.0
317 +8 0x00007fe351c987c2 in g_main_loop_run () from /usr/lib64/libglib-2.0.so.0
318 +9 0x0000556fe45abc75 in main (argc=<optimized out>, argv=<optimized out>)
319 + at src/main.c:770
320 +
321 +This commit prevents the call to btd_adv_manager_refresh for non-LE devices.
322 +---
323 + src/adapter.c | 3 ++-
324 + 1 file changed, 2 insertions(+), 1 deletion(-)
325 +
326 +diff --git a/src/adapter.c b/src/adapter.c
327 +index 6b9222b..daccfdc 100644
328 +--- a/src/adapter.c
329 ++++ b/src/adapter.c
330 +@@ -540,7 +540,8 @@ static void settings_changed(struct btd_adapter *adapter, uint32_t settings)
331 + g_dbus_emit_property_changed(dbus_conn, adapter->path,
332 + ADAPTER_INTERFACE, "Discoverable");
333 + store_adapter_info(adapter);
334 +- btd_adv_manager_refresh(adapter->adv_manager);
335 ++ if (adapter->supported_settings & MGMT_SETTING_LE)
336 ++ btd_adv_manager_refresh(adapter->adv_manager);
337 + }
338 +
339 + if (changed_mask & MGMT_SETTING_BONDABLE) {
340 +--
341 +cgit v1.1
342 +