1SUMMARY = "Linux Bluetooth Stack Userland V5"
2DESCRIPTION = "Linux Bluetooth stack V5 userland components.  These include a system configurations, daemons, tools and system libraries."
3HOMEPAGE = "http://www.bluez.org"
4SECTION = "libs"
5LICENSE = "GPLv2+ & LGPLv2.1+"
6LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e \
7                    file://COPYING.LIB;md5=fb504b67c50331fc78734fed90fb0e09 \
8                    file://src/main.c;beginline=1;endline=24;md5=9bc54b93cd7e17bf03f52513f39f926e"
9DEPENDS = "dbus glib-2.0"
10PROVIDES += "bluez-hcidump"
11RPROVIDES_${PN} += "bluez-hcidump"
12
13RCONFLICTS_${PN} = "bluez4"
14
15PACKAGECONFIG ??= "obex-profiles \
16    readline \
17    ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
18    a2dp-profiles \
19    avrcp-profiles \
20    network-profiles \
21    hid-profiles \
22    hog-profiles \
23    tools \
24    deprecated \
25    udev \
26"
27PACKAGECONFIG[obex-profiles] = "--enable-obex,--disable-obex,libical"
28PACKAGECONFIG[readline] = "--enable-client,--disable-client,readline,"
29PACKAGECONFIG[testing] = "--enable-testing,--disable-testing"
30PACKAGECONFIG[midi] = "--enable-midi,--disable-midi,alsa-lib"
31PACKAGECONFIG[systemd] = "--enable-systemd,--disable-systemd"
32PACKAGECONFIG[cups] = "--enable-cups,--disable-cups,,cups"
33PACKAGECONFIG[nfc] = "--enable-nfc,--disable-nfc"
34PACKAGECONFIG[sap-profiles] = "--enable-sap,--disable-sap"
35PACKAGECONFIG[a2dp-profiles] = "--enable-a2dp,--disable-a2dp"
36PACKAGECONFIG[avrcp-profiles] = "--enable-avrcp,--disable-avrcp"
37PACKAGECONFIG[network-profiles] = "--enable-network,--disable-network"
38PACKAGECONFIG[hid-profiles] = "--enable-hid,--disable-hid"
39PACKAGECONFIG[hog-profiles] = "--enable-hog,--disable-hog"
40PACKAGECONFIG[health-profiles] = "--enable-health,--disable-health"
41PACKAGECONFIG[sixaxis] = "--enable-sixaxis,--disable-sixaxis"
42PACKAGECONFIG[tools] = "--enable-tools,--disable-tools"
43PACKAGECONFIG[threads] = "--enable-threads,--disable-threads"
44PACKAGECONFIG[deprecated] = "--enable-deprecated,--disable-deprecated"
45PACKAGECONFIG[mesh] = "--enable-mesh,--disable-mesh, json-c ell"
46PACKAGECONFIG[btpclient] = "--enable-btpclient,--disable-btpclient, ell"
47PACKAGECONFIG[udev] = "--enable-udev,--disable-udev,udev"
48
49SRC_URI = "\
50    ${KERNELORG_MIRROR}/linux/bluetooth/bluez-${PV}.tar.xz \
51    file://out-of-tree.patch \
52    file://init \
53    file://run-ptest \
54    ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', 'file://0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch', d)} \
55    file://0001-tests-add-a-target-for-building-tests-without-runnin.patch \
56    file://0001-test-gatt-Fix-hung-issue.patch \
57    file://0001-Makefile.am-Fix-a-race-issue-for-tools.patch \
58    file://CVE-2018-10910.patch \
59    file://gcc9-fixes.patch \
60"
61S = "${WORKDIR}/bluez-${PV}"
62
63CVE_PRODUCT = "bluez"
64
65inherit autotools pkgconfig systemd update-rc.d distro_features_check ptest gobject-introspection-data
66
67EXTRA_OECONF = "\
68  --enable-test \
69  --enable-datafiles \
70  --enable-library \
71"
72
73# bluez5 builds a large number of useful utilities but does not
74# install them.  Specify which ones we want put into ${PN}-noinst-tools.
75NOINST_TOOLS_READLINE ??= ""
76NOINST_TOOLS_TESTING ??= ""
77NOINST_TOOLS_BT ??= ""
78NOINST_TOOLS = " \
79    ${@bb.utils.contains('PACKAGECONFIG', 'readline', '${NOINST_TOOLS_READLINE}', '', d)} \
80    ${@bb.utils.contains('PACKAGECONFIG', 'testing', '${NOINST_TOOLS_TESTING}', '', d)} \
81    ${@bb.utils.contains('PACKAGECONFIG', 'tools', '${NOINST_TOOLS_BT}', '', d)} \
82"
83
84do_install_append() {
85	install -d ${D}${INIT_D_DIR}
86	install -m 0755 ${WORKDIR}/init ${D}${INIT_D_DIR}/bluetooth
87
88	install -d ${D}${sysconfdir}/bluetooth/
89	if [ -f ${S}/profiles/network/network.conf ]; then
90		install -m 0644 ${S}/profiles/network/network.conf ${D}/${sysconfdir}/bluetooth/
91	fi
92	if [ -f ${S}/profiles/input/input.conf ]; then
93		install -m 0644 ${S}/profiles/input/input.conf ${D}/${sysconfdir}/bluetooth/
94	fi
95
96	if [ -f ${D}/${sysconfdir}/init.d/bluetooth ]; then
97		sed -i -e 's#@LIBEXECDIR@#${libexecdir}#g' ${D}/${sysconfdir}/init.d/bluetooth
98	fi
99
100	# Install desired tools that upstream leaves in build area
101	for f in ${NOINST_TOOLS} ; do
102		install -m 755 ${B}/$f ${D}/${bindir}
103	done
104
105	# Patch python tools to use Python 3; they should be source compatible, but
106	# still refer to Python 2 in the shebang
107	sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/bluez/test/*
108}
109
110PACKAGES =+ "${PN}-testtools ${PN}-obex ${PN}-noinst-tools"
111
112FILES_${PN} += " \
113    ${libdir}/bluetooth/plugins/*.so \
114    ${systemd_unitdir}/ ${datadir}/dbus-1 \
115    ${libdir}/cups \
116"
117FILES_${PN}-dev += " \
118    ${libdir}/bluetooth/plugins/*.la \
119"
120
121FILES_${PN}-obex = "${libexecdir}/bluetooth/obexd \
122                    ${exec_prefix}/lib/systemd/user/obex.service \
123                    ${systemd_system_unitdir}/obex.service \
124                    ${sysconfdir}/systemd/system/multi-user.target.wants/obex.service \
125                    ${datadir}/dbus-1/services/org.bluez.obex.service \
126                    ${sysconfdir}/dbus-1/system.d/obexd.conf \
127                   "
128SYSTEMD_SERVICE_${PN}-obex = "obex.service"
129
130FILES_${PN}-testtools = "${libdir}/bluez/test/*"
131
132def get_noinst_tools_paths (d, bb, tools):
133    s = list()
134    bindir = d.getVar("bindir")
135    for bdp in tools.split():
136        f = os.path.basename(bdp)
137        s.append("%s/%s" % (bindir, f))
138    return "\n".join(s)
139
140FILES_${PN}-noinst-tools = "${@get_noinst_tools_paths(d, bb, d.getVar('NOINST_TOOLS'))}"
141
142RDEPENDS_${PN}-testtools += "python3 python3-dbus"
143RDEPENDS_${PN}-testtools += "${@bb.utils.contains('GI_DATA_ENABLED', 'True', 'python3-pygobject', '', d)}"
144
145SYSTEMD_SERVICE_${PN} = "${@bb.utils.contains('PACKAGECONFIG', 'systemd', 'bluetooth.service', '', d)}"
146INITSCRIPT_PACKAGES = "${PN}"
147INITSCRIPT_NAME_${PN} = "bluetooth"
148
149do_compile_ptest() {
150	oe_runmake buildtests
151}
152
153do_install_ptest() {
154	cp -r ${B}/unit/ ${D}${PTEST_PATH}
155	rm -f ${D}${PTEST_PATH}/unit/*.o
156}
157