bluez: Upgrade for using BLE features 45/7545/2
authorStephane Desneux <stephane.desneux@iot.bzh>
Mon, 5 Dec 2016 14:00:00 +0000 (15:00 +0100)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Tue, 13 Dec 2016 10:30:30 +0000 (10:30 +0000)
This version of bluez, a little forward of 5.43,s
includes working features for using BLE GATT services
and attributes.

This is needed for a demo that uses DIGIPASS SecureClick
of Vasco.

To be removed when yocto upgrades to bluez 5.44 or higher.

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
meta-agl/recipes-connectivity/bluez5/bluez5.inc [new file with mode: 0644]
meta-agl/recipes-connectivity/bluez5/bluez5/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch [new file with mode: 0644]
meta-agl/recipes-connectivity/bluez5/bluez5/0001-tests-add-a-target-for-building-tests-without-runnin.patch [new file with mode: 0644]
meta-agl/recipes-connectivity/bluez5/bluez5/init [new file with mode: 0644]
meta-agl/recipes-connectivity/bluez5/bluez5/out-of-tree.patch [new file with mode: 0644]
meta-agl/recipes-connectivity/bluez5/bluez5/run-ptest [new file with mode: 0644]
meta-agl/recipes-connectivity/bluez5/bluez5_5.43.bb [new file with mode: 0644]

diff --git a/meta-agl/recipes-connectivity/bluez5/bluez5.inc b/meta-agl/recipes-connectivity/bluez5/bluez5.inc
new file mode 100644 (file)
index 0000000..8189dc8
--- /dev/null
@@ -0,0 +1,118 @@
+SUMMARY = "Linux Bluetooth Stack Userland V5"
+DESCRIPTION = "Linux Bluetooth stack V5 userland components.  These include a system configurations, daemons, tools and system libraries."
+HOMEPAGE = "http://www.bluez.org"
+SECTION = "libs"
+LICENSE = "GPLv2+ & LGPLv2.1+"
+LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e \
+                    file://COPYING.LIB;md5=fb504b67c50331fc78734fed90fb0e09 \
+                    file://src/main.c;beginline=1;endline=24;md5=9bc54b93cd7e17bf03f52513f39f926e"
+DEPENDS = "udev libusb dbus-glib glib-2.0 libcheck readline"
+PROVIDES += "bluez-hcidump"
+RPROVIDES_${PN} += "bluez-hcidump"
+
+RCONFLICTS_${PN} = "bluez4"
+
+PACKAGECONFIG ??= "obex-profiles"
+PACKAGECONFIG[obex-profiles] = "--enable-obex,--disable-obex,libical"
+PACKAGECONFIG[experimental] = "--enable-experimental,--disable-experimental,"
+
+SRC_URI = "\
+    git://git.kernel.org/pub/scm/bluetooth/bluez.git;protocol=https;branch=master \
+    file://out-of-tree.patch \
+    file://init \
+    file://run-ptest \
+    ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', 'file://0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch', d)} \
+    file://0001-tests-add-a-target-for-building-tests-without-runnin.patch \
+"
+SRCREV = "c64b4d9e8dc3e36672061f39a9dba19ad0fb1ef1"
+S = "${WORKDIR}/git"
+
+inherit autotools pkgconfig systemd update-rc.d distro_features_check ptest
+
+EXTRA_OECONF = "\
+  --enable-tools \
+  --disable-cups \
+  --enable-test \
+  --enable-datafiles \
+  ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '--enable-systemd', '--disable-systemd', d)} \
+  --enable-library \
+"
+
+# bluez5 builds a large number of useful utilities but does not
+# install them.  Specify which ones we want put into ${PN}-noinst-tools.
+NOINST_TOOLS_READLINE ??= ""
+NOINST_TOOLS_EXPERIMENTAL ??= ""
+NOINST_TOOLS = " \
+    ${NOINST_TOOLS_READLINE} \
+    ${@bb.utils.contains('PACKAGECONFIG', 'experimental', '${NOINST_TOOLS_EXPERIMENTAL}', '', d)} \
+"
+
+do_install_append() {
+       install -d ${D}${INIT_D_DIR}
+       install -m 0755 ${WORKDIR}/init ${D}${INIT_D_DIR}/bluetooth
+
+       install -d ${D}${sysconfdir}/bluetooth/
+       if [ -f ${S}/profiles/audio/audio.conf ]; then
+           install -m 0644 ${S}/profiles/audio/audio.conf ${D}/${sysconfdir}/bluetooth/
+       fi
+       if [ -f ${S}/profiles/network/network.conf ]; then
+           install -m 0644 ${S}/profiles/network/network.conf ${D}/${sysconfdir}/bluetooth/
+       fi
+       if [ -f ${S}/profiles/input/input.conf ]; then
+           install -m 0644 ${S}/profiles/input/input.conf ${D}/${sysconfdir}/bluetooth/
+       fi
+
+  if [ -f ${D}/${sysconfdir}/init.d/bluetooth ]; then
+    sed -i -e 's#@LIBEXECDIR@#${libexecdir}#g' ${D}/${sysconfdir}/init.d/bluetooth
+  fi
+
+       # Install desired tools that upstream leaves in build area
+        for f in ${NOINST_TOOLS} ; do
+           install -m 755 ${B}/$f ${D}/${bindir}
+       done
+}
+
+ALLOW_EMPTY_libasound-module-bluez = "1"
+PACKAGES =+ "libasound-module-bluez ${PN}-testtools ${PN}-obex ${PN}-noinst-tools"
+
+FILES_libasound-module-bluez = "${libdir}/alsa-lib/lib*.so ${datadir}/alsa"
+FILES_${PN} += "${libdir}/bluetooth/plugins/*.so ${base_libdir}/udev/ ${nonarch_base_libdir}/udev/ ${systemd_unitdir}/ ${datadir}/dbus-1"
+FILES_${PN}-dev += "\
+  ${libdir}/bluetooth/plugins/*.la \
+  ${libdir}/alsa-lib/*.la \
+"
+
+FILES_${PN}-obex = "${libexecdir}/bluetooth/obexd \
+                    ${exec_prefix}/lib/systemd/user/obex.service \
+                    ${datadir}/dbus-1/services/org.bluez.obex.service \
+                   "
+SYSTEMD_SERVICE_${PN}-obex = "obex.service"
+
+FILES_${PN}-testtools = "${libdir}/bluez/test/*"
+
+def get_noinst_tools_paths (d, bb, tools):
+    s = list()
+    bindir = d.getVar("bindir", True)
+    for bdp in tools.split():
+        f = os.path.basename(bdp)
+        s.append("%s/%s" % (bindir, f))
+    return "\n".join(s)
+
+FILES_${PN}-noinst-tools = "${@get_noinst_tools_paths(d, bb, d.getVar('NOINST_TOOLS', True))}"
+
+RDEPENDS_${PN}-testtools += "python python-dbus python-pygobject"
+
+SYSTEMD_SERVICE_${PN} = "bluetooth.service"
+INITSCRIPT_PACKAGES = "${PN}"
+INITSCRIPT_NAME_${PN} = "bluetooth"
+
+EXCLUDE_FROM_WORLD = "1"
+
+do_compile_ptest() {
+        oe_runmake buildtests
+}
+
+do_install_ptest() {
+        cp -r ${B}/unit/ ${D}${PTEST_PATH}
+        rm -f ${D}${PTEST_PATH}/unit/*.o
+}
diff --git a/meta-agl/recipes-connectivity/bluez5/bluez5/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch b/meta-agl/recipes-connectivity/bluez5/bluez5/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch
new file mode 100644 (file)
index 0000000..2fde7bc
--- /dev/null
@@ -0,0 +1,63 @@
+From: Giovanni Campagna <gcampagna-cNUdlRotFMnNLxjTenLetw@public.gmane.org>
+Date: Sat, 12 Oct 2013 17:45:25 +0200
+Subject: [PATCH] Allow using obexd without systemd in the user session
+
+Not all sessions run systemd --user (actually, the majority
+doesn't), so the dbus daemon must be able to spawn obexd
+directly, and to do so it needs the full path of the daemon.
+
+Upstream-Status: Denied
+
+Not accepted by upstream maintainer for being a distro specific
+configuration. See thread:
+
+http://thread.gmane.org/gmane.linux.bluez.kernel/38725/focus=38843
+
+Signed-off-by: Javier Viguera <javier.viguera@digi.com>
+---
+ Makefile.obexd                      | 4 ++--
+ obexd/src/org.bluez.obex.service    | 4 ----
+ obexd/src/org.bluez.obex.service.in | 4 ++++
+ 3 files changed, 6 insertions(+), 6 deletions(-)
+ delete mode 100644 obexd/src/org.bluez.obex.service
+ create mode 100644 obexd/src/org.bluez.obex.service.in
+
+diff --git a/Makefile.obexd b/Makefile.obexd
+index 2e33cbc72f2b..d5d858c857b4 100644
+--- a/Makefile.obexd
++++ b/Makefile.obexd
+@@ -2,12 +2,12 @@
+ if SYSTEMD
+ systemduserunitdir = @SYSTEMD_USERUNITDIR@
+ systemduserunit_DATA = obexd/src/obex.service
++endif
+ dbussessionbusdir = @DBUS_SESSIONBUSDIR@
+ dbussessionbus_DATA = obexd/src/org.bluez.obex.service
+-endif
+-EXTRA_DIST += obexd/src/obex.service.in obexd/src/org.bluez.obex.service
++EXTRA_DIST += obexd/src/obex.service.in obexd/src/org.bluez.obex.service.in
+ obex_plugindir = $(libdir)/obex/plugins
+diff --git a/obexd/src/org.bluez.obex.service b/obexd/src/org.bluez.obex.service
+deleted file mode 100644
+index a53808884554..000000000000
+--- a/obexd/src/org.bluez.obex.service
++++ /dev/null
+@@ -1,4 +0,0 @@
+-[D-BUS Service]
+-Name=org.bluez.obex
+-Exec=/bin/false
+-SystemdService=dbus-org.bluez.obex.service
+diff --git a/obexd/src/org.bluez.obex.service.in b/obexd/src/org.bluez.obex.service.in
+new file mode 100644
+index 000000000000..9c815f246b77
+--- /dev/null
++++ b/obexd/src/org.bluez.obex.service.in
+@@ -0,0 +1,4 @@
++[D-BUS Service]
++Name=org.bluez.obex
++Exec=@libexecdir@/obexd
++SystemdService=dbus-org.bluez.obex.service
diff --git a/meta-agl/recipes-connectivity/bluez5/bluez5/0001-tests-add-a-target-for-building-tests-without-runnin.patch b/meta-agl/recipes-connectivity/bluez5/bluez5/0001-tests-add-a-target-for-building-tests-without-runnin.patch
new file mode 100644 (file)
index 0000000..24ddae6
--- /dev/null
@@ -0,0 +1,28 @@
+From 4bdf0f96dcaa945fd29f26d56e5b36d8c23e4c8b Mon Sep 17 00:00:00 2001
+From: Alexander Kanavin <alex.kanavin@gmail.com>
+Date: Fri, 1 Apr 2016 17:07:34 +0300
+Subject: [PATCH] tests: add a target for building tests without running them
+
+Upstream-Status: Inappropriate [oe specific]
+Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
+---
+ Makefile.am | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/Makefile.am b/Makefile.am
+index 1a48a71..ba3b92f 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -425,6 +425,9 @@ endif
+ TESTS = $(unit_tests)
+ AM_TESTS_ENVIRONMENT = MALLOC_CHECK_=3 MALLOC_PERTURB_=69
++# This allows building tests without running them
++buildtests: $(TESTS)
++
+ if DBUS_RUN_SESSION
+ AM_TESTS_ENVIRONMENT += dbus-run-session --
+ endif
+-- 
+2.8.0.rc3
+
diff --git a/meta-agl/recipes-connectivity/bluez5/bluez5/init b/meta-agl/recipes-connectivity/bluez5/bluez5/init
new file mode 100644 (file)
index 0000000..489e9b9
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+DESC=bluetooth
+
+DAEMON=@LIBEXECDIR@/bluetooth/bluetoothd
+
+# If you want to be ignore error of "org.freedesktop.hostname1",
+# please enable NOPLUGIN_OPTION.
+# NOPLUGIN_OPTION="--noplugin=hostname"
+NOPLUGIN_OPTION=""
+SSD_OPTIONS="--oknodo --quiet --exec $DAEMON -- $NOPLUGIN_OPTION"
+
+test -f $DAEMON || exit 0
+
+# FIXME: any of the sourced files may fail if/with syntax errors
+test -f /etc/default/bluetooth && . /etc/default/bluetooth
+test -f /etc/default/rcS && . /etc/default/rcS
+
+set -e
+
+case $1 in
+  start)
+       echo "Starting $DESC"
+
+       if test "$BLUETOOTH_ENABLED" = 0; then
+               echo "disabled. see /etc/default/bluetooth"
+               exit 0
+       fi
+
+       start-stop-daemon --start --background $SSD_OPTIONS
+       echo "${DAEMON##*/}"
+
+  ;;
+  stop)
+       echo "Stopping $DESC"
+       if test "$BLUETOOTH_ENABLED" = 0; then
+               echo "disabled."
+               exit 0
+       fi
+       start-stop-daemon --stop $SSD_OPTIONS
+       echo "${DAEMON}"
+  ;;
+  restart|force-reload)
+       $0 stop
+       sleep 1
+       $0 start
+  ;;
+  status)
+        pidof ${DAEMON} >/dev/null
+        status=$?
+        if [ $status -eq 0 ]; then
+                 echo "bluetooth is running."
+        else
+                echo "bluetooth is not running"
+        fi
+        exit $status
+   ;;
+   *)
+       N=/etc/init.d/bluetooth
+       echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
+       exit 1
+       ;;
+esac
+
+exit 0
+
+# vim:noet
diff --git a/meta-agl/recipes-connectivity/bluez5/bluez5/out-of-tree.patch b/meta-agl/recipes-connectivity/bluez5/bluez5/out-of-tree.patch
new file mode 100644 (file)
index 0000000..3ee79d7
--- /dev/null
@@ -0,0 +1,26 @@
+From ed55b49a226ca3909f52416be2ae5ce1c5ca2cb2 Mon Sep 17 00:00:00 2001
+From: Ross Burton <ross.burton@intel.com>
+Date: Fri, 22 Apr 2016 15:40:37 +0100
+Subject: [PATCH] Makefile.obexd: add missing mkdir in builtin.h generation
+
+In parallel out-of-tree builds it's possible that obexd/src/builtin.h is
+generated before the target directory has been implicitly created. Solve this by
+creating the directory before writing into it.
+
+Upstream-Status: Submitted
+Signed-off-by: Ross Burton <ross.burton@intel.com>
+---
+ Makefile.obexd | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/Makefile.obexd b/Makefile.obexd
+index 2e33cbc..c8286f0 100644
+--- a/Makefile.obexd
++++ b/Makefile.obexd
+@@ -105,2 +105,3 @@ obexd/src/plugin.$(OBJEXT): obexd/src/builtin.h
+ obexd/src/builtin.h: obexd/src/genbuiltin $(obexd_builtin_sources)
++      $(AM_V_at)$(MKDIR_P) $(dir $@)
+       $(AM_V_GEN)$(srcdir)/obexd/src/genbuiltin $(obexd_builtin_modules) > $@
+-- 
+2.8.0.rc3
+
diff --git a/meta-agl/recipes-connectivity/bluez5/bluez5/run-ptest b/meta-agl/recipes-connectivity/bluez5/bluez5/run-ptest
new file mode 100644 (file)
index 0000000..21df00c
--- /dev/null
@@ -0,0 +1,31 @@
+#! /bin/sh
+
+cd unit
+
+failed=0
+all=0
+
+for f in test-*; do
+    "./$f"
+    case "$?" in
+        0)
+            echo "PASS: $f"
+            all=$((all + 1))
+            ;;
+        77)
+            echo "SKIP: $f"
+            ;;
+        *)
+            echo "FAIL: $f"
+            failed=$((failed + 1))
+            all=$((all + 1))
+            ;;
+    esac
+done
+
+if [ "$failed" -eq 0 ] ; then
+  echo "All $all tests passed"
+else
+  echo "$failed of $all tests failed"
+fi
+
diff --git a/meta-agl/recipes-connectivity/bluez5/bluez5_5.43.bb b/meta-agl/recipes-connectivity/bluez5/bluez5_5.43.bb
new file mode 100644 (file)
index 0000000..e10b82d
--- /dev/null
@@ -0,0 +1,55 @@
+require bluez5.inc
+
+REQUIRED_DISTRO_FEATURES = "bluez5"
+
+SRC_URI[md5sum] = "698def88df96840dfbb0858bb6d73350"
+SRC_URI[sha256sum] = "16c9c05d2a1da644ce3570d975ada3643d2e60c007a955bac09c0a0efeb58d15"
+
+# noinst programs in Makefile.tools that are conditional on READLINE
+# support
+NOINST_TOOLS_READLINE ?= " \
+    attrib/gatttool \
+    tools/obex-client-tool \
+    tools/obex-server-tool \
+    tools/bluetooth-player \
+    tools/obexctl \
+    tools/btmgmt \
+"
+
+# noinst programs in Makefile.tools that are conditional on EXPERIMENTAL
+# support
+NOINST_TOOLS_EXPERIMENTAL ?= " \
+    emulator/btvirt \
+    emulator/b1ee \
+    emulator/hfp \
+    tools/3dsp \
+    tools/mgmt-tester \
+    tools/gap-tester \
+    tools/l2cap-tester \
+    tools/sco-tester \
+    tools/smp-tester \
+    tools/hci-tester \
+    tools/rfcomm-tester \
+    tools/bdaddr \
+    tools/avinfo \
+    tools/avtest \
+    tools/scotest \
+    tools/amptest \
+    tools/hwdb \
+    tools/hcieventmask \
+    tools/hcisecfilter \
+    tools/btinfo \
+    tools/btattach \
+    tools/btsnoop \
+    tools/btproxy \
+    tools/btiotest \
+    tools/mcaptest \
+    tools/cltest \
+    tools/oobtest \
+    tools/seq2bseq \
+    tools/ibeacon \
+    tools/btgatt-client \
+    tools/btgatt-server \
+    tools/gatt-service \
+    profiles/iap/iapd \
+"