]> git.pld-linux.org Git - packages/bluez.git/commitdiff
- fix path handling auto/th/bluez-5.54-3
authorJan Rękorajski <baggins@pld-linux.org>
Mon, 24 Aug 2020 09:27:43 +0000 (11:27 +0200)
committerJan Rękorajski <baggins@pld-linux.org>
Mon, 24 Aug 2020 09:27:43 +0000 (11:27 +0200)
- add btattach service for BCM HCI devices
- build and install BT emulator
- rel 3

0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch [new file with mode: 0644]
69-btattach-bcm.rules [new file with mode: 0644]
bluez.spec
btattach-bcm-service.sh [new file with mode: 0644]
btattach-bcm@.service [new file with mode: 0644]

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 (file)
index 0000000..f79d3ad
--- /dev/null
@@ -0,0 +1,38 @@
+From 90b72b787a6ae6b9b0bf8ece238e108e8607a433 Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess@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 (file)
index 0000000..dfe8d1e
--- /dev/null
@@ -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"
index f91db33a4cec2522b9834b6763f99b1561f204c1..39f3e5092b28d3d2b29cb9e6a7e9c24a89e9d6f0 100644 (file)
@@ -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@.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@.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/btattach-bcm-service.sh b/btattach-bcm-service.sh
new file mode 100644 (file)
index 0000000..507fa34
--- /dev/null
@@ -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@.service b/btattach-bcm@.service
new file mode 100644 (file)
index 0000000..1e7c7db
--- /dev/null
@@ -0,0 +1,6 @@
+[Unit]
+Description=btattach for Broadcom devices
+
+[Service]
+Type=simple
+ExecStart=/usr/libexec/bluetooth/btattach-bcm-service.sh %I
This page took 0.072126 seconds and 4 git commands to generate.