Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-dev:musl commit in: net-wireless/bluez/, net-wireless/bluez/files/
Date: Sat, 04 Oct 2014 14:47:42
Message-Id: 1412434076.8573dd804a8531cab9dd1ba1de47f94eb33641fd.blueness@gentoo
1 commit: 8573dd804a8531cab9dd1ba1de47f94eb33641fd
2 Author: layman <layman <AT> localhost>
3 AuthorDate: Sat Oct 4 14:46:48 2014 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 4 14:47:56 2014 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=8573dd80
7
8 net-wireless/bluez: fix build on musl, bug #524454
9
10 ---
11 net-wireless/bluez/bluez-5.23-r99.ebuild | 205 +++++++++++++++++++++
12 ...-obexd-without-systemd-in-the-user-sessio.patch | 58 ++++++
13 ...erial.c-use-posix_openpt-instead-of-getpt.patch | 37 ++++
14 ...-GLib-helper-function-to-manipulate-paths.patch | 38 ++++
15 ...01-tools-Fix-compilation-errors-with-musl.patch | 189 +++++++++++++++++++
16 ...-Logitech-diNovo-Edge-keyboard-firmware-i.patch | 29 +++
17 .../0002-autopair-Don-t-handle-the-iCade.patch | 47 +++++
18 .../0004-agent-Assert-possible-infinite-loop.patch | 25 +++
19 net-wireless/bluez/files/bluetooth-init.d-r3 | 21 +++
20 .../bluez/files/bluez-5.23-use-posix_openpt.patch | 20 ++
21 net-wireless/bluez/files/bluez-plugdev.patch | 14 ++
22 net-wireless/bluez/files/rfcomm-init.d-r2 | 35 ++++
23 net-wireless/bluez/metadata.xml | 21 +++
24 13 files changed, 739 insertions(+)
25
26 diff --git a/net-wireless/bluez/bluez-5.23-r99.ebuild b/net-wireless/bluez/bluez-5.23-r99.ebuild
27 new file mode 100644
28 index 0000000..5dc607b
29 --- /dev/null
30 +++ b/net-wireless/bluez/bluez-5.23-r99.ebuild
31 @@ -0,0 +1,205 @@
32 +# Copyright 1999-2014 Gentoo Foundation
33 +# Distributed under the terms of the GNU General Public License v2
34 +# $Header: /var/cvsroot/gentoo-x86/net-wireless/bluez/bluez-5.23.ebuild,v 1.2 2014/09/25 09:11:55 pacho Exp $
35 +
36 +EAPI=5
37 +PYTHON_COMPAT=( python{2_6,2_7,3_2,3_3} )
38 +
39 +inherit autotools eutils multilib python-any-r1 readme.gentoo systemd udev user multilib-minimal
40 +
41 +DESCRIPTION="Bluetooth Tools and System Daemons for Linux"
42 +HOMEPAGE="http://www.bluez.org"
43 +SRC_URI="mirror://kernel/linux/bluetooth/${P}.tar.xz"
44 +
45 +LICENSE="GPL-2+ LGPL-2.1+"
46 +SLOT="0/3"
47 +KEYWORDS="amd64 arm ~mips x86"
48 +IUSE="cups debug +obex +readline selinux systemd test +udev"
49 +REQUIRED_USE="test? ( ${PYTHON_REQUIRED_USE} )"
50 +
51 +RDEPEND="
52 + >=dev-libs/glib-2.28:2
53 + >=sys-apps/dbus-1.6:=
54 + >=sys-apps/hwids-20121202.2
55 + cups? ( net-print/cups:= )
56 + obex? ( dev-libs/libical )
57 + readline? ( sys-libs/readline:= )
58 + selinux? ( sec-policy/selinux-bluetooth )
59 + systemd? ( sys-apps/systemd )
60 + udev? ( >=virtual/udev-172 )
61 + abi_x86_32? (
62 + !<app-emulation/emul-linux-x86-soundlibs-20140406-r1
63 + !app-emulation/emul-linux-x86-soundlibs[-abi_x86_32]
64 + )
65 +"
66 +DEPEND="${RDEPEND}
67 + virtual/pkgconfig
68 + test? (
69 + ${PYTHON_DEPS}
70 + >=dev-python/dbus-python-1
71 + dev-python/pygobject:2
72 + dev-python/pygobject:3
73 + )
74 +"
75 +
76 +DOC_CONTENTS="
77 + If you want to use rfcomm as a normal user, you need to add the user
78 + to the uucp group.
79 +"
80 +
81 +pkg_setup() {
82 + enewgroup plugdev
83 + use test && python-any-r1_pkg_setup
84 +
85 + if ! use udev; then
86 + ewarn
87 + ewarn "You are installing ${PN} with USE=-udev. This means various bluetooth"
88 + ewarn "devices and adapters from Apple, Dell, Logitech etc. will not work,"
89 + ewarn "and hid2hci will not be available."
90 + ewarn
91 + fi
92 +}
93 +
94 +src_prepare() {
95 + # Use static group "plugdev" if there is no ConsoleKit (or systemd logind)
96 + epatch "${FILESDIR}"/bluez-plugdev.patch
97 +
98 + # Fedora patches
99 + # http://www.spinics.net/lists/linux-bluetooth/msg38490.html
100 + epatch "${FILESDIR}"/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch
101 +
102 + # http://www.spinics.net/lists/linux-bluetooth/msg40136.html
103 + epatch "${FILESDIR}"/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
104 +
105 + # http://www.spinics.net/lists/linux-bluetooth/msg41264.html
106 + epatch "${FILESDIR}"/0002-autopair-Don-t-handle-the-iCade.patch
107 +
108 + # ???
109 + epatch "${FILESDIR}"/0004-agent-Assert-possible-infinite-loop.patch
110 +
111 + # Ubuntu workaround for bug #501120
112 + epatch "${FILESDIR}"/0001-work-around-Logitech-diNovo-Edge-keyboard-firmware-i.patch
113 +
114 + # Patches for musl
115 + epatch "${FILESDIR}"/0001-tools-Fix-compilation-errors-with-musl.patch
116 + epatch "${FILESDIR}"/0001-emulator-serial.c-use-posix_openpt-instead-of-getpt.patch
117 +
118 + if use cups; then
119 + sed -i \
120 + -e "s:cupsdir = \$(libdir)/cups:cupsdir = $(cups-config --serverbin):" \
121 + Makefile.{in,tools} || die
122 + fi
123 +
124 + eautoreconf
125 +
126 + multilib_copy_sources
127 +}
128 +
129 +multilib_src_configure() {
130 + local myconf=(
131 + # readline is automagic when client is enabled
132 + # --enable-client always needs readline, bug #504038
133 + ac_cv_header_readline_readline_h=$(multilib_native_usex readline)
134 + )
135 +
136 + if ! multilib_is_native_abi; then
137 + myconf+=(
138 + # deps not used for the library
139 + {DBUS,GLIB}_{CFLAGS,LIBS}=' '
140 + )
141 + fi
142 +
143 + # Missing flags: experimental (sap, nfc, ...)
144 + econf \
145 + --localstatedir=/var \
146 + --disable-android \
147 + --enable-datafiles \
148 + --enable-experimental \
149 + --enable-optimization \
150 + $(use_enable debug) \
151 + --enable-pie \
152 + --enable-threads \
153 + --enable-library \
154 + $(multilib_native_use_enable test) \
155 + --enable-tools \
156 + --enable-manpages \
157 + --enable-monitor \
158 + $(multilib_native_use_enable cups) \
159 + $(multilib_native_use_enable obex) \
160 + $(multilib_native_use_enable readline client) \
161 + $(multilib_native_use_enable systemd) \
162 + $(systemd_with_unitdir) \
163 + $(multilib_native_use_enable udev) \
164 + $(multilib_native_use_enable udev sixaxis)
165 +}
166 +
167 +multilib_src_compile() {
168 + if multilib_is_native_abi; then
169 + default
170 + else
171 + emake -f Makefile -f - libs \
172 + <<<'libs: $(lib_LTLIBRARIES)'
173 + fi
174 +}
175 +
176 +multilib_src_test() {
177 + multilib_is_native_abi && default
178 +}
179 +
180 +multilib_src_install() {
181 + if multilib_is_native_abi; then
182 + emake DESTDIR="${D}" install
183 +
184 + # Unittests are not that useful once installed
185 + if use test ; then
186 + rm -r "${ED}"/usr/$(get_libdir)/bluez/test || die
187 + fi
188 + else
189 + emake DESTDIR="${D}" \
190 + install-includeHEADERS \
191 + install-libLTLIBRARIES \
192 + install-pkgconfigDATA
193 + fi
194 +}
195 +
196 +multilib_src_install_all() {
197 + prune_libtool_files --modules
198 +
199 + keepdir /var/lib/bluetooth
200 +
201 + # Upstream don't want people to play with them
202 + # But we keep installing them due 'historical' reasons
203 + insinto /etc/bluetooth
204 + local d
205 + for d in input network proximity; do
206 + doins profiles/${d}/${d}.conf
207 + done
208 + doins src/main.conf
209 + doins src/bluetooth.conf
210 +
211 +# FIXME:
212 +# Looks like upstream installs it only for systemd, probably not needed
213 +# insinto /usr/share/dbus-1/system-services
214 +# doins src/org.bluez.service
215 +
216 + newinitd "${FILESDIR}"/bluetooth-init.d-r3 bluetooth
217 + newinitd "${FILESDIR}"/rfcomm-init.d-r2 rfcomm
218 +
219 + einstalldocs
220 +
221 + readme.gentoo_create_doc
222 +}
223 +
224 +pkg_postinst() {
225 + readme.gentoo_print_elog
226 +
227 + use udev && udev_reload
228 +
229 + has_version net-dialup/ppp || elog "To use dial up networking you must install net-dialup/ppp."
230 +
231 + if ! has_version sys-auth/consolekit && ! has_version sys-apps/systemd; then
232 + elog "Since you don't have sys-auth/consolekit neither sys-apps/systemd, you will only"
233 + elog "be able to run bluetooth clients as root. If you want to be able to run bluetooth clients as"
234 + elog "a regular user, you need to add the user to the plugdev group."
235 + fi
236 +}
237
238 diff --git a/net-wireless/bluez/files/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch b/net-wireless/bluez/files/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch
239 new file mode 100644
240 index 0000000..1ea3e6f
241 --- /dev/null
242 +++ b/net-wireless/bluez/files/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch
243 @@ -0,0 +1,58 @@
244 +From 3027cb7141fb65cf3eeda69c688db8c4045e2d3f Mon Sep 17 00:00:00 2001
245 +From: Giovanni Campagna <gcampagna-cNUdlRotFMnNLxjTenLetw@××××××××××××.org>
246 +Date: Sat, 12 Oct 2013 17:45:25 +0200
247 +Subject: [PATCH] Allow using obexd without systemd in the user session
248 +
249 +Not all sessions run systemd --user (actually, the majority
250 +doesn't), so the dbus daemon must be able to spawn obexd
251 +directly, and to do so it needs the full path of the daemon.
252 +---
253 + Makefile.obexd | 4 ++--
254 + obexd/src/org.bluez.obex.service | 4 ----
255 + obexd/src/org.bluez.obex.service.in | 4 ++++
256 + 3 files changed, 6 insertions(+), 6 deletions(-)
257 + delete mode 100644 obexd/src/org.bluez.obex.service
258 + create mode 100644 obexd/src/org.bluez.obex.service.in
259 +
260 +diff --git a/Makefile.obexd b/Makefile.obexd
261 +index 3760867..142e7c3 100644
262 +--- a/Makefile.obexd
263 ++++ b/Makefile.obexd
264 +@@ -2,12 +2,12 @@
265 + if SYSTEMD
266 + systemduserunitdir = @SYSTEMD_USERUNITDIR@
267 + systemduserunit_DATA = obexd/src/obex.service
268 ++endif
269 +
270 + dbussessionbusdir = @DBUS_SESSIONBUSDIR@
271 + dbussessionbus_DATA = obexd/src/org.bluez.obex.service
272 +-endif
273 +
274 +-EXTRA_DIST += obexd/src/obex.service.in obexd/src/org.bluez.obex.service
275 ++EXTRA_DIST += obexd/src/obex.service.in obexd/src/org.bluez.obex.service.in
276 +
277 + obex_plugindir = $(libdir)/obex/plugins
278 +
279 +diff --git a/obexd/src/org.bluez.obex.service b/obexd/src/org.bluez.obex.service
280 +deleted file mode 100644
281 +index a538088..0000000
282 +--- a/obexd/src/org.bluez.obex.service
283 ++++ /dev/null
284 +@@ -1,4 +0,0 @@
285 +-[D-BUS Service]
286 +-Name=org.bluez.obex
287 +-Exec=/bin/false
288 +-SystemdService=dbus-org.bluez.obex.service
289 +diff --git a/obexd/src/org.bluez.obex.service.in b/obexd/src/org.bluez.obex.service.in
290 +new file mode 100644
291 +index 0000000..9c815f2
292 +--- /dev/null
293 ++++ b/obexd/src/org.bluez.obex.service.in
294 +@@ -0,0 +1,4 @@
295 ++[D-BUS Service]
296 ++Name=org.bluez.obex
297 ++Exec=@libexecdir@/obexd
298 ++SystemdService=dbus-org.bluez.obex.service
299 +--
300 +1.8.3.1
301 +
302
303 diff --git a/net-wireless/bluez/files/0001-emulator-serial.c-use-posix_openpt-instead-of-getpt.patch b/net-wireless/bluez/files/0001-emulator-serial.c-use-posix_openpt-instead-of-getpt.patch
304 new file mode 100644
305 index 0000000..766734a
306 --- /dev/null
307 +++ b/net-wireless/bluez/files/0001-emulator-serial.c-use-posix_openpt-instead-of-getpt.patch
308 @@ -0,0 +1,37 @@
309 +From 57c33317f5c3f6d21a9b3c56f8d1e97179e4c457 Mon Sep 17 00:00:00 2001
310 +From: "Anthony G. Basile" <blueness@g.o>
311 +Date: Sat, 4 Oct 2014 09:34:05 -0400
312 +Subject: [PATCH] emulator/serial.c: use posix_openpt() instead of getpt()
313 +
314 +getpt(3) is glibc-specific and is not provided on musl. Instead, we
315 +use use posix_openpt(3) which is equivalent and portable.
316 +
317 +Signed-off-by: Anthony G. Basile <blueness@g.o>
318 +---
319 + emulator/serial.c | 3 ++-
320 + 1 file changed, 2 insertions(+), 1 deletion(-)
321 +
322 +diff --git a/emulator/serial.c b/emulator/serial.c
323 +index 9583be4..8b49dc6 100644
324 +--- a/emulator/serial.c
325 ++++ b/emulator/serial.c
326 +@@ -32,6 +32,7 @@
327 + #include <unistd.h>
328 + #include <stdlib.h>
329 + #include <string.h>
330 ++#include <fcntl.h>
331 + #include <sys/param.h>
332 + #include <sys/epoll.h>
333 + #include <sys/uio.h>
334 +@@ -160,7 +161,7 @@ static void open_pty(struct serial *serial)
335 + {
336 + enum btdev_type uninitialized_var(type);
337 +
338 +- serial->fd = getpt();
339 ++ serial->fd = posix_openpt(O_RDWR | O_NOCTTY);
340 + if (serial->fd < 0) {
341 + perror("Failed to get master pseudo terminal");
342 + return;
343 +--
344 +2.0.4
345 +
346
347 diff --git a/net-wireless/bluez/files/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch b/net-wireless/bluez/files/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
348 new file mode 100644
349 index 0000000..004a389
350 --- /dev/null
351 +++ b/net-wireless/bluez/files/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
352 @@ -0,0 +1,38 @@
353 +From f7861d27fbcbc519f57d8496aa9486f487908821 Mon Sep 17 00:00:00 2001
354 +From: Bastien Nocera <hadess@××××××.net>
355 +Date: Sat, 9 Nov 2013 18:13:43 +0100
356 +Subject: [PATCH 1/5] obex: Use GLib helper function to manipulate paths
357 +
358 +Instead of trying to do it by hand. This also makes sure that
359 +relative paths aren't used by the agent.
360 +---
361 + obexd/src/manager.c | 10 +++++-----
362 + 1 file changed, 5 insertions(+), 5 deletions(-)
363 +
364 +diff --git a/obexd/src/manager.c b/obexd/src/manager.c
365 +index cec8a39..f18896e 100644
366 +--- a/obexd/src/manager.c
367 ++++ b/obexd/src/manager.c
368 +@@ -651,14 +651,14 @@ static void agent_reply(DBusPendingCall *call, void *user_data)
369 + DBUS_TYPE_STRING, &name,
370 + DBUS_TYPE_INVALID)) {
371 + /* Splits folder and name */
372 +- const char *slash = strrchr(name, '/');
373 ++ gboolean is_relative = !g_path_is_absolute(name);
374 + DBG("Agent replied with %s", name);
375 +- if (!slash) {
376 +- agent->new_name = g_strdup(name);
377 ++ if (is_relative) {
378 ++ agent->new_name = g_path_get_basename(name);
379 + agent->new_folder = NULL;
380 + } else {
381 +- agent->new_name = g_strdup(slash + 1);
382 +- agent->new_folder = g_strndup(name, slash - name);
383 ++ agent->new_name = g_path_get_basename(name);
384 ++ agent->new_folder = g_path_get_dirname(name);
385 + }
386 + }
387 +
388 +--
389 +1.8.4.2
390 +
391
392 diff --git a/net-wireless/bluez/files/0001-tools-Fix-compilation-errors-with-musl.patch b/net-wireless/bluez/files/0001-tools-Fix-compilation-errors-with-musl.patch
393 new file mode 100644
394 index 0000000..501e75a
395 --- /dev/null
396 +++ b/net-wireless/bluez/files/0001-tools-Fix-compilation-errors-with-musl.patch
397 @@ -0,0 +1,189 @@
398 +From 51ec4fd847369bc77e72850fe93d727ae9c656b9 Mon Sep 17 00:00:00 2001
399 +From: Szymon Janc <szymon.janc@×××××.com>
400 +Date: Fri, 19 Sep 2014 16:10:07 +0200
401 +Subject: [PATCH] tools: Fix compilation errors with musl
402 +
403 +This fix number of includes for <sys/poll.h> instead of <poll.h>
404 +
405 + CC tools/hciattach.o
406 +In file included from tools/hciattach.c:41:0:
407 +/usr/include/sys/poll.h:1:2: error: #warning redirecting incorrect
408 + #include <sys/poll.h> to <poll.h> [-Werror=cpp]
409 + #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
410 + ^
411 +---
412 + tools/amptest.c | 2 +-
413 + tools/btattach.c | 2 +-
414 + tools/btsnoop.c | 1 +
415 + tools/ciptool.c | 2 +-
416 + tools/cltest.c | 2 +-
417 + tools/hciattach.c | 2 +-
418 + tools/hciattach_qualcomm.c | 2 +-
419 + tools/hciattach_tialt.c | 2 +-
420 + tools/hcidump.c | 2 +-
421 + tools/l2ping.c | 2 +-
422 + tools/l2test.c | 2 +-
423 + tools/rfcomm.c | 2 +-
424 + 12 files changed, 12 insertions(+), 11 deletions(-)
425 +
426 +diff --git a/tools/amptest.c b/tools/amptest.c
427 +index 6192f7e..bba0a9a 100644
428 +--- a/tools/amptest.c
429 ++++ b/tools/amptest.c
430 +@@ -32,7 +32,7 @@
431 + #include <alloca.h>
432 + #include <stdlib.h>
433 + #include <stdbool.h>
434 +-#include <sys/poll.h>
435 ++#include <poll.h>
436 + #include <sys/ioctl.h>
437 + #include <sys/socket.h>
438 +
439 +diff --git a/tools/btattach.c b/tools/btattach.c
440 +index 9458fd7..bdbbe16 100644
441 +--- a/tools/btattach.c
442 ++++ b/tools/btattach.c
443 +@@ -35,7 +35,7 @@
444 + #include <getopt.h>
445 + #include <termios.h>
446 + #include <sys/ioctl.h>
447 +-#include <sys/poll.h>
448 ++#include <poll.h>
449 +
450 + #include <bluetooth/bluetooth.h>
451 + #include <bluetooth/hci.h>
452 +diff --git a/tools/btsnoop.c b/tools/btsnoop.c
453 +index 14581f2..71191eb 100644
454 +--- a/tools/btsnoop.c
455 ++++ b/tools/btsnoop.c
456 +@@ -35,6 +35,7 @@
457 + #include <stdbool.h>
458 + #include <string.h>
459 + #include <getopt.h>
460 ++#include <endian.h>
461 + #include <arpa/inet.h>
462 + #include <sys/stat.h>
463 +
464 +diff --git a/tools/ciptool.c b/tools/ciptool.c
465 +index 72338dc..3ff9fb1 100644
466 +--- a/tools/ciptool.c
467 ++++ b/tools/ciptool.c
468 +@@ -32,7 +32,7 @@
469 + #include <string.h>
470 + #include <getopt.h>
471 + #include <signal.h>
472 +-#include <sys/poll.h>
473 ++#include <poll.h>
474 + #include <sys/ioctl.h>
475 + #include <sys/socket.h>
476 +
477 +diff --git a/tools/cltest.c b/tools/cltest.c
478 +index 4ddb98a..0231805 100644
479 +--- a/tools/cltest.c
480 ++++ b/tools/cltest.c
481 +@@ -32,7 +32,7 @@
482 + #include <alloca.h>
483 + #include <stdlib.h>
484 + #include <stdbool.h>
485 +-#include <sys/poll.h>
486 ++#include <poll.h>
487 + #include <sys/ioctl.h>
488 + #include <sys/socket.h>
489 +
490 +diff --git a/tools/hciattach.c b/tools/hciattach.c
491 +index 1904ac5..d8ef7e7 100644
492 +--- a/tools/hciattach.c
493 ++++ b/tools/hciattach.c
494 +@@ -37,8 +37,8 @@
495 + #include <syslog.h>
496 + #include <termios.h>
497 + #include <time.h>
498 ++#include <poll.h>
499 + #include <sys/time.h>
500 +-#include <sys/poll.h>
501 + #include <sys/param.h>
502 + #include <sys/ioctl.h>
503 +
504 +diff --git a/tools/hciattach_qualcomm.c b/tools/hciattach_qualcomm.c
505 +index eb72a0f..0e25905 100644
506 +--- a/tools/hciattach_qualcomm.c
507 ++++ b/tools/hciattach_qualcomm.c
508 +@@ -36,8 +36,8 @@
509 + #include <syslog.h>
510 + #include <termios.h>
511 + #include <time.h>
512 ++#include <poll.h>
513 + #include <sys/time.h>
514 +-#include <sys/poll.h>
515 + #include <sys/param.h>
516 + #include <sys/ioctl.h>
517 + #include <sys/uio.h>
518 +diff --git a/tools/hciattach_tialt.c b/tools/hciattach_tialt.c
519 +index 5c7f3a5..a7c1706 100644
520 +--- a/tools/hciattach_tialt.c
521 ++++ b/tools/hciattach_tialt.c
522 +@@ -35,8 +35,8 @@
523 + #include <syslog.h>
524 + #include <termios.h>
525 + #include <time.h>
526 ++#include <poll.h>
527 + #include <sys/time.h>
528 +-#include <sys/poll.h>
529 + #include <sys/param.h>
530 + #include <sys/ioctl.h>
531 + #include <sys/uio.h>
532 +diff --git a/tools/hcidump.c b/tools/hcidump.c
533 +index 37a9f00..8839eb0 100644
534 +--- a/tools/hcidump.c
535 ++++ b/tools/hcidump.c
536 +@@ -33,7 +33,7 @@
537 + #include <stdlib.h>
538 + #include <string.h>
539 + #include <getopt.h>
540 +-#include <sys/poll.h>
541 ++#include <poll.h>
542 + #include <sys/stat.h>
543 + #include <sys/types.h>
544 + #include <sys/ioctl.h>
545 +diff --git a/tools/l2ping.c b/tools/l2ping.c
546 +index 29fb3d0..3dd437e 100644
547 +--- a/tools/l2ping.c
548 ++++ b/tools/l2ping.c
549 +@@ -35,7 +35,7 @@
550 + #include <getopt.h>
551 + #include <signal.h>
552 + #include <sys/time.h>
553 +-#include <sys/poll.h>
554 ++#include <poll.h>
555 + #include <sys/socket.h>
556 +
557 + #include <bluetooth/bluetooth.h>
558 +diff --git a/tools/l2test.c b/tools/l2test.c
559 +index 67ca70a..71ad109 100644
560 +--- a/tools/l2test.c
561 ++++ b/tools/l2test.c
562 +@@ -38,7 +38,7 @@
563 + #include <syslog.h>
564 + #include <signal.h>
565 + #include <sys/time.h>
566 +-#include <sys/poll.h>
567 ++#include <poll.h>
568 + #include <sys/ioctl.h>
569 + #include <sys/socket.h>
570 +
571 +diff --git a/tools/rfcomm.c b/tools/rfcomm.c
572 +index b5bea38..659bbec 100644
573 +--- a/tools/rfcomm.c
574 ++++ b/tools/rfcomm.c
575 +@@ -34,7 +34,7 @@
576 + #include <getopt.h>
577 + #include <signal.h>
578 + #include <termios.h>
579 +-#include <sys/poll.h>
580 ++#include <poll.h>
581 + #include <sys/param.h>
582 + #include <sys/ioctl.h>
583 + #include <sys/socket.h>
584 +--
585 +2.0.4
586 +
587
588 diff --git a/net-wireless/bluez/files/0001-work-around-Logitech-diNovo-Edge-keyboard-firmware-i.patch b/net-wireless/bluez/files/0001-work-around-Logitech-diNovo-Edge-keyboard-firmware-i.patch
589 new file mode 100644
590 index 0000000..55d5af6
591 --- /dev/null
592 +++ b/net-wireless/bluez/files/0001-work-around-Logitech-diNovo-Edge-keyboard-firmware-i.patch
593 @@ -0,0 +1,29 @@
594 +From aa73bf5039dfd2cf0a52dd6fd22501d955cc1a00 Mon Sep 17 00:00:00 2001
595 +From: Tommy <mesilliac@×××××.com>
596 +Date: Thu, 10 Jan 2013 09:18:43 +0100
597 +Subject: [PATCH] work around Logitech diNovo Edge keyboard firmware issue
598 +
599 +https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/269851
600 +---
601 + tools/hid2hci.rules | 5 ++++-
602 + 1 files changed, 4 insertions(+), 1 deletions(-)
603 +
604 +diff --git a/tools/hid2hci.rules b/tools/hid2hci.rules
605 +index db6bb03..7db4572 100644
606 +--- a/tools/hid2hci.rules
607 ++++ b/tools/hid2hci.rules
608 +@@ -11,7 +11,10 @@ ATTR{bInterfaceClass}=="03", ATTR{bInterfaceSubClass}=="01", ATTR{bInterfaceProt
609 + RUN+="hid2hci --method=dell --devpath=%p", ENV{HID2HCI_SWITCH}="1"
610 +
611 + # Logitech devices
612 +-KERNEL=="hiddev*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c70[345abce]|c71[34bc]", \
613 ++KERNEL=="hiddev*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c70[5e]", \
614 ++ RUN+="hid2hci --method=logitech-hid --devpath=%p"
615 ++# Logitech, Inc. RAW communicating devices
616 ++KERNEL=="hidraw*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c70[34abc]|c71[34bc]", \
617 + RUN+="hid2hci --method=logitech-hid --devpath=%p"
618 +
619 + ENV{DEVTYPE}!="usb_device", GOTO="hid2hci_end"
620 +--
621 +1.8.0.1
622 +
623
624 diff --git a/net-wireless/bluez/files/0002-autopair-Don-t-handle-the-iCade.patch b/net-wireless/bluez/files/0002-autopair-Don-t-handle-the-iCade.patch
625 new file mode 100644
626 index 0000000..68751ae
627 --- /dev/null
628 +++ b/net-wireless/bluez/files/0002-autopair-Don-t-handle-the-iCade.patch
629 @@ -0,0 +1,47 @@
630 +From c16ae7041c7511d8d1ed8441f696716fa6a9117e Mon Sep 17 00:00:00 2001
631 +From: Bastien Nocera <hadess@××××××.net>
632 +Date: Tue, 19 Nov 2013 14:11:39 +0100
633 +Subject: [PATCH 2/5] autopair: Don't handle the iCade
634 +
635 +We can't easily enter digits other than 1 through 4 (inclusive)
636 +so leave it up to the agent to figure out a good passcode
637 +for the iCade.
638 +
639 +Note that we can not use the VID/PID of the device, as it is not
640 +yet known at that point.
641 +---
642 + plugins/autopair.c | 12 +++++++++++-
643 + 1 file changed, 11 insertions(+), 1 deletion(-)
644 +
645 +diff --git a/plugins/autopair.c b/plugins/autopair.c
646 +index 8c98c12..5d2f6f7 100644
647 +--- a/plugins/autopair.c
648 ++++ b/plugins/autopair.c
649 +@@ -57,13 +57,23 @@ static ssize_t autopair_pincb(struct btd_adapter *adapter,
650 + {
651 + char addr[18];
652 + char pinstr[7];
653 ++ char name[25];
654 + uint32_t class;
655 +
656 + ba2str(device_get_address(device), addr);
657 +
658 + class = btd_device_get_class(device);
659 +
660 +- DBG("device %s 0x%x", addr, class);
661 ++ device_get_name(device, name, sizeof(name));
662 ++ name[sizeof(name) - 1] = 0;
663 ++
664 ++ DBG("device %s (%s) 0x%x", addr, name, class);
665 ++
666 ++ g_message ("vendor 0x%X product: 0x%X", btd_device_get_vendor (device), btd_device_get_product (device));
667 ++
668 ++ /* The iCade shouldn't use random PINs like normal keyboards */
669 ++ if (name != NULL && strstr(name, "iCade") != NULL)
670 ++ return 0;
671 +
672 + /* This is a class-based pincode guesser. Ignore devices with an
673 + * unknown class.
674 +--
675 +1.8.4.2
676 +
677
678 diff --git a/net-wireless/bluez/files/0004-agent-Assert-possible-infinite-loop.patch b/net-wireless/bluez/files/0004-agent-Assert-possible-infinite-loop.patch
679 new file mode 100644
680 index 0000000..2746e0c
681 --- /dev/null
682 +++ b/net-wireless/bluez/files/0004-agent-Assert-possible-infinite-loop.patch
683 @@ -0,0 +1,25 @@
684 +From 67e5477687a2753d3f7b300bcfdc74464d8ad41f Mon Sep 17 00:00:00 2001
685 +From: Bastien Nocera <hadess@××××××.net>
686 +Date: Mon, 9 Dec 2013 18:04:56 +0100
687 +Subject: [PATCH 4/5] agent: Assert possible infinite loop
688 +
689 +---
690 + src/agent.c | 2 ++
691 + 1 file changed, 2 insertions(+)
692 +
693 +diff --git a/src/agent.c b/src/agent.c
694 +index bcba969..b292881 100644
695 +--- a/src/agent.c
696 ++++ b/src/agent.c
697 +@@ -203,6 +203,8 @@ void agent_unref(struct agent *agent)
698 + if (agent->ref > 0)
699 + return;
700 +
701 ++ g_assert (agent->ref == 0);
702 ++
703 + if (agent->request) {
704 + DBusError err;
705 + agent_pincode_cb pincode_cb;
706 +--
707 +1.8.4.2
708 +
709
710 diff --git a/net-wireless/bluez/files/bluetooth-init.d-r3 b/net-wireless/bluez/files/bluetooth-init.d-r3
711 new file mode 100644
712 index 0000000..f97fdb2
713 --- /dev/null
714 +++ b/net-wireless/bluez/files/bluetooth-init.d-r3
715 @@ -0,0 +1,21 @@
716 +#!/sbin/runscript
717 +# Copyright 1999-2014 Gentoo Foundation
718 +# Distributed under the terms of the GNU General Public License v2
719 +# $Header: /var/cvsroot/gentoo-x86/net-wireless/bluez/files/bluetooth-init.d-r3,v 1.2 2014/01/09 13:24:42 joker Exp $
720 +
721 +depend() {
722 + after coldplug
723 + need dbus localmount hostname
724 +}
725 +
726 +start() {
727 + ebegin "Starting ${SVCNAME}"
728 + start-stop-daemon --start --background --exec /usr/libexec/bluetooth/bluetoothd
729 + eend $?
730 +}
731 +
732 +stop() {
733 + ebegin "Shutting down ${SVCNAME}"
734 + start-stop-daemon --stop --quiet --exec /usr/libexec/bluetooth/bluetoothd
735 + eend $?
736 +}
737
738 diff --git a/net-wireless/bluez/files/bluez-5.23-use-posix_openpt.patch b/net-wireless/bluez/files/bluez-5.23-use-posix_openpt.patch
739 new file mode 100644
740 index 0000000..3630df6
741 --- /dev/null
742 +++ b/net-wireless/bluez/files/bluez-5.23-use-posix_openpt.patch
743 @@ -0,0 +1,20 @@
744 +diff -Naur bluez-5.23.orig/emulator/serial.c bluez-5.23/emulator/serial.c
745 +--- bluez-5.23.orig/emulator/serial.c 2014-08-06 17:25:36.000000000 +0000
746 ++++ bluez-5.23/emulator/serial.c 2014-10-04 13:02:38.081336391 +0000
747 +@@ -32,6 +32,7 @@
748 + #include <unistd.h>
749 + #include <stdlib.h>
750 + #include <string.h>
751 ++#include <fcntl.h>
752 + #include <sys/param.h>
753 + #include <sys/epoll.h>
754 +
755 +@@ -159,7 +160,7 @@
756 + {
757 + enum btdev_type uninitialized_var(type);
758 +
759 +- serial->fd = getpt();
760 ++ serial->fd = posix_openpt(O_RDWR | O_NOCTTY);
761 + if (serial->fd < 0) {
762 + perror("Failed to get master pseudo terminal");
763 + return;
764
765 diff --git a/net-wireless/bluez/files/bluez-plugdev.patch b/net-wireless/bluez/files/bluez-plugdev.patch
766 new file mode 100755
767 index 0000000..726838a
768 --- /dev/null
769 +++ b/net-wireless/bluez/files/bluez-plugdev.patch
770 @@ -0,0 +1,14 @@
771 +diff -Nurp bluez-4.39.orig/src/bluetooth.conf bluez-4.39/src/bluetooth.conf
772 +--- bluez-4.39.orig/src/bluetooth.conf 2008-12-20 20:18:10.000000000 +0100
773 ++++ bluez-4.39/src/bluetooth.conf 2009-09-05 13:30:34.411581498 +0200
774 +@@ -17,6 +17,10 @@
775 + <allow send_destination="org.bluez"/>
776 + </policy>
777 +
778 ++ <policy group="plugdev">
779 ++ <allow send_destination="org.bluez"/>
780 ++ </policy>
781 ++
782 + <policy context="default">
783 + <deny send_destination="org.bluez"/>
784 + </policy>
785
786 diff --git a/net-wireless/bluez/files/rfcomm-init.d-r2 b/net-wireless/bluez/files/rfcomm-init.d-r2
787 new file mode 100755
788 index 0000000..c564055
789 --- /dev/null
790 +++ b/net-wireless/bluez/files/rfcomm-init.d-r2
791 @@ -0,0 +1,35 @@
792 +#!/sbin/runscript
793 +# Copyright 1999-2014 Gentoo Foundation
794 +# Distributed under the terms of the GNU General Public License v2
795 +# $Header: /var/cvsroot/gentoo-x86/net-wireless/bluez/files/rfcomm-init.d-r2,v 1.1 2014/06/26 17:18:43 alonbl Exp $
796 +
797 +depend() {
798 + need bluetooth
799 +}
800 +
801 +checkconfig() {
802 + if [ -z "${ADDRESS}" ]; then
803 + eerror "ADDRESS must be set"
804 + return 1
805 + fi
806 +
807 + return 0
808 +}
809 +
810 +start() {
811 + local DEVICE=${RC_SVCNAME#*.}
812 +
813 + checkconfig || return 1
814 +
815 + ebegin "Starting ${RC_SVCNAME}"
816 + rfcomm bind "${DEVICE}" "${ADDRESS}" ${CHANNEL}
817 + eend $?
818 +}
819 +
820 +stop() {
821 + local DEVICE=${RC_SVCNAME#*.}
822 +
823 + ebegin "Shutting down ${RC_SVCNAME}"
824 + rfcomm release "${DEVICE}"
825 + eend $?
826 +}
827
828 diff --git a/net-wireless/bluez/metadata.xml b/net-wireless/bluez/metadata.xml
829 new file mode 100644
830 index 0000000..de19c8b
831 --- /dev/null
832 +++ b/net-wireless/bluez/metadata.xml
833 @@ -0,0 +1,21 @@
834 +<?xml version="1.0" encoding="UTF-8"?>
835 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
836 +<pkgmetadata>
837 + <maintainer>
838 + <email>pacho@g.o</email>
839 + <name>Pacho Ramos</name>
840 + </maintainer>
841 + <use>
842 + <flag name="test-programs">Install tools for testing of
843 + various Bluetooth functions</flag>
844 + <flag name="hid2hci">The HID proxying makes the keyboard / mouse show up
845 + as regular USB HID devices, but needs them to be
846 + paired before enabling this, otherwise they won't be
847 + detected</flag>
848 + <flag name="obex">Enable OBEX transfer support.</flag>
849 + </use>
850 + <upstream>
851 + <remote-id type="cpe">cpe:/a:bluez:bluez</remote-id>
852 + <remote-id type="cpe">cpe:/a:bluez:bluez-libs</remote-id>
853 + </upstream>
854 +</pkgmetadata>