[packages/bluez] - fix path handling - add btattach service for BCM HCI devices - build and install BT emulator - rel
baggins
baggins at pld-linux.org
Mon Aug 24 11:28:59 CEST 2020
commit 477801c9c9364c27daa86463ddcb7eb0240c2a51
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Mon Aug 24 11:27:43 2020 +0200
- fix path handling
- add btattach service for BCM HCI devices
- build and install BT emulator
- rel 3
...-GLib-helper-function-to-manipulate-paths.patch | 38 ++++++++++++++++++++++
69-btattach-bcm.rules | 33 +++++++++++++++++++
bluez.spec | 29 +++++++++++++++--
btattach-bcm-service.sh | 30 +++++++++++++++++
btattach-bcm at .service | 6 ++++
5 files changed, 133 insertions(+), 3 deletions(-)
---
diff --git a/bluez.spec b/bluez.spec
index f91db33..39f3e50 100644
--- a/bluez.spec
+++ b/bluez.spec
@@ -9,18 +9,25 @@ Summary: Bluetooth utilities
Summary(pl.UTF-8): Narzędzia Bluetooth
Name: bluez
Version: 5.54
-Release: 2
+Release: 3
License: GPL v2+
Group: Applications/System
Source0: https://www.kernel.org/pub/linux/bluetooth/%{name}-%{version}.tar.xz
# Source0-md5: e637feb2dbb7582bbbff1708367a847c
Source1: %{name}.init
Source2: %{name}.sysconfig
+# Scripts for automatically btattach-ing serial ports connected to Broadcom HCIs
+# as found on some Atom based x86 hardware
+Source3: 69-btattach-bcm.rules
+Source4: btattach-bcm at .service
+Source5: btattach-bcm-service.sh
+Patch0: 0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
URL: http://www.bluez.org/
BuildRequires: alsa-lib-devel >= 1.0
BuildRequires: autoconf >= 2.60
BuildRequires: automake
BuildRequires: check-devel >= 0.9.6
+BuildRequires: cups-devel
BuildRequires: dbus-devel >= 1.6
BuildRequires: ell-devel >= 0.28
BuildRequires: glib2-devel >= 1:2.28
@@ -30,6 +37,7 @@ BuildRequires: libtool
BuildRequires: pkgconfig >= 1:0.9.0
BuildRequires: readline-devel
BuildRequires: rpmbuild(macros) >= 1.682
+BuildRequires: systemd-devel
BuildRequires: tar >= 1:1.22
BuildRequires: udev-devel >= 1:172
BuildRequires: xz
@@ -169,6 +177,7 @@ aplikacji Bluetooth.
%prep
%setup -q
+%patch0 -p1
# external ell is broken if ell/ell.h is in place due to deps generation and Makefile.am rules
%{__rm} -r ell
@@ -187,6 +196,9 @@ aplikacji Bluetooth.
--enable-external-ell \
--enable-health \
--enable-library \
+ --enable-tools \
+ --enable-cups \
+ --enable-testing \
--enable-mesh \
--enable-midi \
--enable-nfc \
@@ -212,15 +224,22 @@ install -d $RPM_BUILD_ROOT/etc/{rc.d/init.d,sysconfig} \
rulesdir=%{udevdir}/rules.d \
udevdir=%{udevdir}
-%{__rm} $RPM_BUILD_ROOT%{_libdir}/bluetooth/plugins/*.{la,a}
-
install %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/bluetooth
install %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/bluetooth
install profiles/input/*.conf $RPM_BUILD_ROOT%{_sysconfdir}/bluetooth
install profiles/network/*.conf $RPM_BUILD_ROOT%{_sysconfdir}/bluetooth
+#serial port connected Broadcom HCIs scripts
+install %{SOURCE3} $RPM_BUILD_ROOT/%{udevdir}/rules.d/
+install %{SOURCE4} $RPM_BUILD_ROOT/%{systemdunitdir}/
+install %{SOURCE5} $RPM_BUILD_ROOT/%{_libexecdir}/bluetooth/
+
+# Install the HCI emulator, useful for testing
+install emulator/btvirt ${RPM_BUILD_ROOT}/%{_libexecdir}/bluetooth/
+
%{__rm} $RPM_BUILD_ROOT%{_libdir}/libbluetooth.la
+%{__rm} $RPM_BUILD_ROOT%{_libdir}/bluetooth/plugins/*.{la,a}
%clean
rm -rf $RPM_BUILD_ROOT
@@ -279,6 +298,8 @@ fi
%endif
%attr(755,root,root) %{_libexecdir}/bluetooth/bluetooth-meshd
%attr(755,root,root) %{_libexecdir}/bluetooth/bluetoothd
+%attr(755,root,root) %{_libexecdir}/bluetooth/btattach-bcm-service.sh
+%attr(755,root,root) %{_libexecdir}/bluetooth/btvirt
%attr(755,root,root) %{_libexecdir}/bluetooth/obexd
%dir %{_libdir}/bluetooth
%dir %{_libdir}/bluetooth/plugins
@@ -294,11 +315,13 @@ fi
%config(noreplace) %verify(not md5 mtime size) /etc/dbus-1/system.d/bluetooth-mesh.conf
%{systemdunitdir}/bluetooth.service
%{systemdunitdir}/bluetooth-mesh.service
+%{systemdunitdir}/btattach-bcm at .service
%{systemduserunitdir}/obex.service
%{_datadir}/dbus-1/services/org.bluez.obex.service
%{_datadir}/dbus-1/system-services/org.bluez.service
%{_datadir}/dbus-1/system-services/org.bluez.mesh.service
%attr(755,root,root) %{udevdir}/hid2hci
+%{udevdir}/rules.d/69-btattach-bcm.rules
%{udevdir}/rules.d/97-hid2hci.rules
%{_mandir}/man1/bccmd.1*
%{_mandir}/man1/btattach.1*
diff --git a/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch b/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
new file mode 100644
index 0000000..f79d3ad
--- /dev/null
+++ b/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
@@ -0,0 +1,38 @@
+From 90b72b787a6ae6b9b0bf8ece238e108e8607a433 Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess at hadess.net>
+Date: Sat, 9 Nov 2013 18:13:43 +0100
+Subject: [PATCH 1/2] obex: Use GLib helper function to manipulate paths
+
+Instead of trying to do it by hand. This also makes sure that
+relative paths aren't used by the agent.
+---
+ obexd/src/manager.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/obexd/src/manager.c b/obexd/src/manager.c
+index f84384ae4..285c07c37 100644
+--- a/obexd/src/manager.c
++++ b/obexd/src/manager.c
+@@ -650,14 +650,14 @@ static void agent_reply(DBusPendingCall *call, void *user_data)
+ DBUS_TYPE_STRING, &name,
+ DBUS_TYPE_INVALID)) {
+ /* Splits folder and name */
+- const char *slash = strrchr(name, '/');
++ gboolean is_relative = !g_path_is_absolute(name);
+ DBG("Agent replied with %s", name);
+- if (!slash) {
+- agent->new_name = g_strdup(name);
++ if (is_relative) {
++ agent->new_name = g_path_get_basename(name);
+ agent->new_folder = NULL;
+ } else {
+- agent->new_name = g_strdup(slash + 1);
+- agent->new_folder = g_strndup(name, slash - name);
++ agent->new_name = g_path_get_basename(name);
++ agent->new_folder = g_path_get_dirname(name);
+ }
+ }
+
+--
+2.14.1
+
diff --git a/69-btattach-bcm.rules b/69-btattach-bcm.rules
new file mode 100644
index 0000000..dfe8d1e
--- /dev/null
+++ b/69-btattach-bcm.rules
@@ -0,0 +1,33 @@
+# Some devices have a bluetooth HCI connected to an uart, these needs to be
+# setup by calling btattach. The systemd btattach-bcm.service takes care of
+# this. These udev rules hardware-activate that service when necessary.
+#
+# For now this only suports ACPI enumerated Broadcom BT HCIs.
+# This has been tested on Bay and Cherry Trail devices with both ACPI and
+# PCI enumerated UARTs.
+
+# Note we check for the platform device not for the acpi device, because
+# some DSDTs list multiple bluetooth adapters, but only some (or none)
+# are enabled. Only enabled adapters get a platform device created.
+ACTION!="add", GOTO="btattach_bcm_rules_end"
+SUBSYSTEM!="platform", GOTO="btattach_bcm_rules_end"
+
+KERNEL=="BCM2E1A:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E39:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E3A:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E3D:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E3F:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E40:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E54:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E55:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E64:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E65:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E67:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E71:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E7B:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E7C:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E7E:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E95:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+KERNEL=="BCM2E96:00", TAG+="systemd", ENV{SYSTEMD_WANTS}="btattach-bcm@%k.service"
+
+LABEL="btattach_bcm_rules_end"
diff --git a/btattach-bcm-service.sh b/btattach-bcm-service.sh
new file mode 100644
index 0000000..507fa34
--- /dev/null
+++ b/btattach-bcm-service.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# Simple shell script to wait for the tty for an uart using BT HCI to show up
+# and then invoke btattach with the right parameters, this is intended to be
+# invoked from a hardware-activated systemd service
+#
+# For now this only suports ACPI enumerated Broadcom BT HCIs.
+# This has been tested on Bay and Cherry Trail devices with both ACPI and
+# PCI enumerated UARTs.
+#
+# Note the kernel bt developers are working on solving this entirely in the
+# kernel, so it is not worth the trouble to write something better then this.
+
+BT_DEV="/sys/bus/platform/devices/$1"
+BT_DEV="$(readlink -f $BT_DEV)"
+UART_DEV="$(dirname $BT_DEV)"
+
+# Stupid GPD-pocket has USB BT with id 0000:0000, but still claims to have
+# an uart attached bt
+if [ "$1" = "BCM2E7E:00" ] && lsusb | grep -q "ID 0000:0000"; then
+ exit 0
+fi
+
+while [ ! -d "$UART_DEV/tty" ]; do
+ sleep .2
+done
+
+TTY="$(ls $UART_DEV/tty)"
+
+exec btattach --bredr "/dev/$TTY" -P bcm
diff --git a/btattach-bcm at .service b/btattach-bcm at .service
new file mode 100644
index 0000000..1e7c7db
--- /dev/null
+++ b/btattach-bcm at .service
@@ -0,0 +1,6 @@
+[Unit]
+Description=btattach for Broadcom devices
+
+[Service]
+Type=simple
+ExecStart=/usr/libexec/bluetooth/btattach-bcm-service.sh %I
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/bluez.git/commitdiff/477801c9c9364c27daa86463ddcb7eb0240c2a51
More information about the pld-cvs-commit
mailing list