net-wireless/bluez: drop 5.62-r2, 5.62-r3, 5.63-r1

Bug: https://bugs.gentoo.org/835077
Signed-off-by: Pacho Ramos <pacho@gentoo.org>
This commit is contained in:
Pacho Ramos
2022-04-18 18:23:31 +02:00
parent 3cdda2a33f
commit ce2e1c7de4
8 changed files with 0 additions and 1751 deletions

View File

@@ -1,3 +1 @@
DIST bluez-5.62.tar.xz 2149348 BLAKE2B db99b36a230fc0be15275d2eda9864b686326ba50648f66b19087ea4309a76d234ab4f1dcb6975f1513a898978b1d5b9332542f5dcee22efd898b79658434a70 SHA512 8fb0b81e1d929d3eee3d70f457ce75dbcff4c2a8a728247fc950bbe11e84d83582345bfd433d2e2df7b5588eb0e42f286658a83c7332be84819d9df49a5707e8
DIST bluez-5.63.tar.xz 2169168 BLAKE2B 5393bb045a3cf05de164417ce7c98e271742ba752a58aa1ac43a758f2ad8608508e24ff59783d97aa6d5aebdc77e66d9aca94a6c8378cd3fd48fd22ce9d3b89d SHA512 1b8ce7b1bd9611873c27a762a60df580edeefe5424e8733a2067b9afb1a47915f9319849bc1eeee148f5b1f33977b7975e05867e8dbdf73d33cd68e6b99ca75b
DIST bluez-5.64.tar.xz 2175148 BLAKE2B 828c620330d1993d5c5c2a865f2d27a29425e3583aac01a1a782290a805ee0fd6456b6832c804ad323dd8714fa9329487b2616ed08f1f491ea29403ee05dba2d SHA512 f11f9974b29c5c6fce3890d7e42425c1cb02e42c1b8f49c5cc4b249234e67b64317d0e5e82721e2fbf1b53269c8569a9c869d59ce42b5e927f6622f0753e53cd

View File

@@ -1,285 +0,0 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{8..10} )
inherit autotools linux-info python-single-r1 readme.gentoo-r1 systemd udev multilib-minimal
DESCRIPTION="Bluetooth Tools and System Daemons for Linux"
HOMEPAGE="http://www.bluez.org"
SRC_URI="https://www.kernel.org/pub/linux/bluetooth/${P}.tar.xz"
LICENSE="GPL-2+ LGPL-2.1+"
SLOT="0/3"
KEYWORDS="amd64 arm arm64 ~hppa ~mips ppc ppc64 ~riscv x86"
IUSE="btpclient cups doc debug deprecated extra-tools experimental +mesh midi +obex +readline selinux systemd test test-programs +udev"
# Since this release all remaining extra-tools need readline support, but this could
# change in the future, hence, this REQUIRED_USE constraint could be dropped
# again in the future.
REQUIRED_USE="
extra-tools? ( deprecated readline )
test? ( ${PYTHON_REQUIRED_USE} )
test-programs? ( ${PYTHON_REQUIRED_USE} )
"
TEST_DEPS="${PYTHON_DEPS}
$(python_gen_cond_dep '
>=dev-python/dbus-python-1[${PYTHON_USEDEP}]
dev-python/pygobject:3[${PYTHON_USEDEP}]
')
"
BDEPEND="
dev-python/docutils
virtual/pkgconfig
test? ( ${TEST_DEPS} )
"
DEPEND="
>=dev-libs/glib-2.28:2[${MULTILIB_USEDEP}]
btpclient? ( >=dev-libs/ell-0.39 )
cups? ( net-print/cups:= )
mesh? (
>=dev-libs/ell-0.39
>=dev-libs/json-c-0.13:=
sys-libs/readline:0=
)
midi? ( media-libs/alsa-lib )
obex? ( dev-libs/libical:= )
readline? ( sys-libs/readline:0= )
systemd? ( sys-apps/systemd )
>=sys-apps/dbus-1.6:=
udev? ( >=virtual/udev-172 )
"
RDEPEND="${DEPEND}
selinux? ( sec-policy/selinux-bluetooth )
test-programs? ( ${TEST_DEPS} )
"
RESTRICT="!test? ( test )"
PATCHES=(
# Try both udevadm paths to cover udev/systemd vs. eudev locations (#539844)
# http://www.spinics.net/lists/linux-bluetooth/msg58739.html
# https://bugs.gentoo.org/539844
"${FILESDIR}"/${PN}-udevadm-path-r1.patch
# Fedora patches
# http://www.spinics.net/lists/linux-bluetooth/msg40136.html
"${FILESDIR}"/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
)
pkg_setup() {
# From http://www.linuxfromscratch.org/blfs/view/svn/general/bluez.html
# to prevent bugs like:
# https://bugzilla.kernel.org/show_bug.cgi?id=196621
CONFIG_CHECK="~NET ~BT ~BT_RFCOMM ~BT_RFCOMM_TTY ~BT_BNEP ~BT_BNEP_MC_FILTER
~BT_BNEP_PROTO_FILTER ~BT_HIDP ~CRYPTO_USER_API_HASH ~CRYPTO_USER_API_SKCIPHER ~RFKILL"
# https://bugzilla.kernel.org/show_bug.cgi?id=196621
# https://bugzilla.kernel.org/show_bug.cgi?id=206815
if use mesh || use test; then
CONFIG_CHECK="${CONFIG_CHECK} ~CRYPTO_USER
~CRYPTO_USER_API ~CRYPTO_USER_API_AEAD ~CRYPTO_AES ~CRYPTO_CCM ~CRYPTO_AEAD ~CRYPTO_CMAC"
fi
linux-info_pkg_setup
if use test || use test-programs; then
python-single-r1_pkg_setup
fi
if ! use udev; then
ewarn
ewarn "You are installing ${PN} with USE=-udev. This means various bluetooth"
ewarn "devices and adapters from Apple, Dell, Logitech etc. will not work,"
ewarn "and hid2hci will not be available."
ewarn
fi
}
src_prepare() {
default
# http://www.spinics.net/lists/linux-bluetooth/msg38490.html
if ! use systemd; then
eapply "${FILESDIR}"/0001-Allow-using-obexd-without-systemd-in-the-user-session-r2.patch
fi
eautoreconf
if use cups; then
# Only not .am to not need to run eautoreconf only because of this
sed -i \
-e "s:cupsdir = \$(libdir)/cups:cupsdir = $(cups-config --serverbin):" \
Makefile.{in,tools} || die
fi
multilib_copy_sources
}
multilib_src_configure() {
local myconf=(
# readline is automagic when client is enabled
# --enable-client always needs readline, bug #504038
# --enable-mesh is handled in the same way
ac_cv_header_readline_readline_h=$(multilib_native_usex readline)
ac_cv_header_readline_readline_h=$(multilib_native_usex mesh)
)
if ! multilib_is_native_abi; then
myconf+=(
# deps not used for the library
{DBUS,GLIB}_{CFLAGS,LIBS}=' '
)
fi
econf \
--localstatedir=/var \
--disable-android \
--enable-datafiles \
--enable-optimization \
$(use_enable debug) \
--enable-pie \
--enable-threads \
--enable-library \
--enable-tools \
--enable-manpages \
--enable-monitor \
--with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
--with-systemduserunitdir="$(systemd_get_userunitdir)" \
$(multilib_native_use_enable btpclient) \
$(multilib_native_use_enable btpclient external-ell) \
$(multilib_native_use_enable cups) \
$(multilib_native_use_enable deprecated) \
$(multilib_native_use_enable experimental) \
$(multilib_native_use_enable mesh) \
$(multilib_native_use_enable mesh external-ell) \
$(multilib_native_use_enable midi) \
$(multilib_native_use_enable obex) \
$(multilib_native_use_enable readline client) \
$(multilib_native_use_enable systemd) \
$(multilib_native_use_enable test-programs test) \
$(multilib_native_use_enable udev) \
$(multilib_native_use_enable udev hid2hci) \
$(multilib_native_use_enable udev sixaxis)
}
multilib_src_compile() {
if multilib_is_native_abi; then
default
else
emake -f Makefile -f - libs \
<<<'libs: $(lib_LTLIBRARIES)'
fi
}
multilib_src_test() {
multilib_is_native_abi && default
}
multilib_src_install() {
if multilib_is_native_abi; then
emake DESTDIR="${D}" install
# Only install extra-tools when relevant USE flag is enabled
if use extra-tools; then
ewarn "Upstream doesn't support using this tools and their bugs are"
ewarn "likely to be ignored forever, also they can break without"
ewarn "previous announcement."
ewarn "Upstream also states all this tools are not really needed,"
ewarn "then, if you still need to rely on them, you must ask them"
ewarn "to either install that tool by default or add the needed"
ewarn "functionality to the existing 'official' tools."
ewarn "Please report this issues to:"
ewarn "http://www.bluez.org/development/lists/"
# Upstream doesn't install this, bug #524640
# http://permalink.gmane.org/gmane.linux.bluez.kernel/53115
# http://comments.gmane.org/gmane.linux.bluez.kernel/54564
dobin tools/btmgmt
# gatttool is only built with readline, bug #530776
# https://bugzilla.redhat.com/show_bug.cgi?id=1141909
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=720486
# https://bugs.archlinux.org/task/37686
dobin attrib/gatttool
# https://bugzilla.redhat.com/show_bug.cgi?id=1699680
dobin tools/avinfo
fi
# Not installed by default after being built, bug #666756
use btpclient && dobin tools/btpclient
# Unittests are not that useful once installed, so make them optional
if use test-programs; then
# Drop python2 only test tools
# https://bugzilla.kernel.org/show_bug.cgi?id=206819
rm "${ED}"/usr/$(get_libdir)/bluez/test/simple-player || die
# https://bugzilla.kernel.org/show_bug.cgi?id=206821
rm "${ED}"/usr/$(get_libdir)/bluez/test/test-hfp || die
# https://bugzilla.kernel.org/show_bug.cgi?id=206823
rm "${ED}"/usr/$(get_libdir)/bluez/test/test-sap-server || die
python_fix_shebang "${ED}"/usr/$(get_libdir)/bluez/test
for i in $(find "${ED}"/usr/$(get_libdir)/bluez/test -maxdepth 1 -type f ! -name "*.*"); do
dosym "${i}" /usr/bin/bluez-"${i##*/}"
done
fi
else
emake DESTDIR="${D}" \
install-pkgincludeHEADERS \
install-libLTLIBRARIES \
install-pkgconfigDATA
fi
}
multilib_src_install_all() {
# We need to ensure obexd can be spawned automatically by systemd
# when user-session is enabled:
# http://marc.info/?l=linux-bluetooth&m=148096094716386&w=2
# https://bugs.gentoo.org/show_bug.cgi?id=577842
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=804908
# https://bugs.archlinux.org/task/45816
# https://bugzilla.redhat.com/show_bug.cgi?id=1318441
# https://bugzilla.redhat.com/show_bug.cgi?id=1389347
if use systemd; then
dosym obex.service /usr/lib/systemd/user/dbus-org.bluez.obex.service
fi
find "${D}" -name '*.la' -type f -delete || die
keepdir /var/lib/bluetooth
# Upstream don't want people to play with them
# But we keep installing them due to 'historical' reasons
insinto /etc/bluetooth
local d
for d in input network; do
doins profiles/${d}/${d}.conf
done
# Setup auto enable as Fedora does for allowing to use
# keyboards/mouse as soon as possible
sed -i 's/#\[Policy\]$/\[Policy\]/; s/#AutoEnable=false/AutoEnable=true/' src/main.conf || die
doins src/main.conf
newinitd "${FILESDIR}"/bluetooth-init.d-r5 bluetooth
newconfd "${FILESDIR}"/bluetooth-conf.d bluetooth
einstalldocs
use doc && dodoc doc/*.txt
# Install .json files as examples to be used by meshctl
if use mesh; then
dodoc tools/mesh-gatt/*.json
local DOC_CONTENTS="Some example .json files were installed into
/usr/share/doc/${PF} to be used with meshctl. Feel free to
uncompress and copy them to ~/.config/meshctl to use them."
readme.gentoo_create_doc
fi
}
pkg_postinst() {
use udev && udev_reload
systemd_reenable bluetooth.service
has_version net-dialup/ppp || elog "To use dial up networking you must install net-dialup/ppp"
use mesh && readme.gentoo_print_elog
}

View File

@@ -1,295 +0,0 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{8..10} )
inherit autotools linux-info python-single-r1 readme.gentoo-r1 systemd udev multilib-minimal
DESCRIPTION="Bluetooth Tools and System Daemons for Linux"
HOMEPAGE="http://www.bluez.org"
SRC_URI="https://www.kernel.org/pub/linux/bluetooth/${P}.tar.xz"
LICENSE="GPL-2+ LGPL-2.1+"
SLOT="0/3"
KEYWORDS="amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~riscv x86"
IUSE="btpclient cups doc debug deprecated extra-tools experimental +mesh midi +obex +readline selinux systemd test test-programs +udev"
# Since this release all remaining extra-tools need readline support, but this could
# change in the future, hence, this REQUIRED_USE constraint could be dropped
# again in the future.
# btpclient needs mesh, bug #790587
REQUIRED_USE="
extra-tools? ( deprecated readline )
test? ( ${PYTHON_REQUIRED_USE} )
test-programs? ( ${PYTHON_REQUIRED_USE} )
"
TEST_DEPS="${PYTHON_DEPS}
$(python_gen_cond_dep '
>=dev-python/dbus-python-1[${PYTHON_USEDEP}]
dev-python/pygobject:3[${PYTHON_USEDEP}]
')
"
BDEPEND="
dev-python/docutils
virtual/pkgconfig
test? ( ${TEST_DEPS} )
"
DEPEND="
>=dev-libs/glib-2.28:2[${MULTILIB_USEDEP}]
btpclient? ( >=dev-libs/ell-0.39 )
cups? ( net-print/cups:= )
mesh? (
>=dev-libs/ell-0.39
>=dev-libs/json-c-0.13:=
sys-libs/readline:0=
)
midi? ( media-libs/alsa-lib )
obex? ( dev-libs/libical:= )
readline? ( sys-libs/readline:0= )
systemd? ( sys-apps/systemd )
>=sys-apps/dbus-1.6:=
udev? ( >=virtual/udev-172 )
"
RDEPEND="${DEPEND}
selinux? ( sec-policy/selinux-bluetooth )
test-programs? ( ${TEST_DEPS} )
"
RESTRICT="!test? ( test )"
PATCHES=(
# Try both udevadm paths to cover udev/systemd vs. eudev locations (#539844)
# http://www.spinics.net/lists/linux-bluetooth/msg58739.html
# https://bugs.gentoo.org/539844
"${FILESDIR}"/${PN}-udevadm-path-r1.patch
# Fedora patches
# http://www.spinics.net/lists/linux-bluetooth/msg40136.html
"${FILESDIR}"/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
# This reverts commit ac2c2e10b3adb432a572b618c6f53cabb6b3c80b. It
# causes problems with Logitech MX wireless input devices (see
# https://github.com/bluez/bluez/issues/220 )
"${FILESDIR}"/0001-Revert-attrib-Make-use-of-bt_att_resend.patch
# gatt-client: Fix disconnecting due to GattCharacteristic1.MTU
# (from 'master')
"${FILESDIR}"/${P}-fix-disconnecting.patch
)
pkg_setup() {
# From http://www.linuxfromscratch.org/blfs/view/svn/general/bluez.html
# to prevent bugs like:
# https://bugzilla.kernel.org/show_bug.cgi?id=196621
CONFIG_CHECK="~NET ~BT ~BT_RFCOMM ~BT_RFCOMM_TTY ~BT_BNEP ~BT_BNEP_MC_FILTER
~BT_BNEP_PROTO_FILTER ~BT_HIDP ~CRYPTO_USER_API_HASH ~CRYPTO_USER_API_SKCIPHER ~RFKILL"
# https://bugzilla.kernel.org/show_bug.cgi?id=196621
# https://bugzilla.kernel.org/show_bug.cgi?id=206815
if use mesh || use test; then
CONFIG_CHECK="${CONFIG_CHECK} ~CRYPTO_USER
~CRYPTO_USER_API ~CRYPTO_USER_API_AEAD ~CRYPTO_AES ~CRYPTO_CCM ~CRYPTO_AEAD ~CRYPTO_CMAC"
fi
linux-info_pkg_setup
if use test || use test-programs; then
python-single-r1_pkg_setup
fi
if ! use udev; then
ewarn
ewarn "You are installing ${PN} with USE=-udev. This means various bluetooth"
ewarn "devices and adapters from Apple, Dell, Logitech etc. will not work,"
ewarn "and hid2hci will not be available."
ewarn
fi
}
src_prepare() {
default
# http://www.spinics.net/lists/linux-bluetooth/msg38490.html
if ! use systemd; then
eapply "${FILESDIR}"/0001-Allow-using-obexd-without-systemd-in-the-user-session-r2.patch
fi
eautoreconf
if use cups; then
# Only not .am to not need to run eautoreconf only because of this
sed -i \
-e "s:cupsdir = \$(libdir)/cups:cupsdir = $(cups-config --serverbin):" \
Makefile.{in,tools} || die
fi
multilib_copy_sources
}
multilib_src_configure() {
local myconf=(
# readline is automagic when client is enabled
# --enable-client always needs readline, bug #504038
# --enable-mesh is handled in the same way
ac_cv_header_readline_readline_h=$(multilib_native_usex readline)
ac_cv_header_readline_readline_h=$(multilib_native_usex mesh)
)
if ! multilib_is_native_abi; then
myconf+=(
# deps not used for the library
{DBUS,GLIB}_{CFLAGS,LIBS}=' '
)
fi
econf \
--localstatedir=/var \
--disable-android \
--enable-datafiles \
--enable-optimization \
$(use_enable debug) \
--enable-pie \
--enable-threads \
--enable-library \
--enable-tools \
--enable-manpages \
--enable-monitor \
--with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
--with-systemduserunitdir="$(systemd_get_userunitdir)" \
$(multilib_native_use_enable btpclient) \
$(multilib_native_use_enable btpclient external-ell) \
$(multilib_native_use_enable cups) \
$(multilib_native_use_enable deprecated) \
$(multilib_native_use_enable experimental) \
$(multilib_native_use_enable mesh) \
$(multilib_native_use_enable mesh external-ell) \
$(multilib_native_use_enable midi) \
$(multilib_native_use_enable obex) \
$(multilib_native_use_enable readline client) \
$(multilib_native_use_enable systemd) \
$(multilib_native_use_enable test-programs test) \
$(multilib_native_use_enable udev) \
$(multilib_native_use_enable udev hid2hci) \
$(multilib_native_use_enable udev sixaxis)
}
multilib_src_compile() {
if multilib_is_native_abi; then
default
else
emake -f Makefile -f - libs \
<<<'libs: $(lib_LTLIBRARIES)'
fi
}
multilib_src_test() {
multilib_is_native_abi && default
}
multilib_src_install() {
if multilib_is_native_abi; then
emake DESTDIR="${D}" install
# Only install extra-tools when relevant USE flag is enabled
if use extra-tools; then
ewarn "Upstream doesn't support using this tools and their bugs are"
ewarn "likely to be ignored forever, also they can break without"
ewarn "previous announcement."
ewarn "Upstream also states all this tools are not really needed,"
ewarn "then, if you still need to rely on them, you must ask them"
ewarn "to either install that tool by default or add the needed"
ewarn "functionality to the existing 'official' tools."
ewarn "Please report this issues to:"
ewarn "http://www.bluez.org/development/lists/"
# Upstream doesn't install this, bug #524640
# http://permalink.gmane.org/gmane.linux.bluez.kernel/53115
# http://comments.gmane.org/gmane.linux.bluez.kernel/54564
dobin tools/btmgmt
# gatttool is only built with readline, bug #530776
# https://bugzilla.redhat.com/show_bug.cgi?id=1141909
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=720486
# https://bugs.archlinux.org/task/37686
dobin attrib/gatttool
# https://bugzilla.redhat.com/show_bug.cgi?id=1699680
dobin tools/avinfo
fi
# Not installed by default after being built, bug #666756
use btpclient && dobin tools/btpclient
# Unittests are not that useful once installed, so make them optional
if use test-programs; then
# Drop python2 only test tools
# https://bugzilla.kernel.org/show_bug.cgi?id=206819
rm "${ED}"/usr/$(get_libdir)/bluez/test/simple-player || die
# https://bugzilla.kernel.org/show_bug.cgi?id=206821
rm "${ED}"/usr/$(get_libdir)/bluez/test/test-hfp || die
# https://bugzilla.kernel.org/show_bug.cgi?id=206823
rm "${ED}"/usr/$(get_libdir)/bluez/test/test-sap-server || die
python_fix_shebang "${ED}"/usr/$(get_libdir)/bluez/test
for i in $(find "${ED}"/usr/$(get_libdir)/bluez/test -maxdepth 1 -type f ! -name "*.*"); do
dosym "${i}" /usr/bin/bluez-"${i##*/}"
done
fi
else
emake DESTDIR="${D}" \
install-pkgincludeHEADERS \
install-libLTLIBRARIES \
install-pkgconfigDATA
fi
}
multilib_src_install_all() {
# We need to ensure obexd can be spawned automatically by systemd
# when user-session is enabled:
# http://marc.info/?l=linux-bluetooth&m=148096094716386&w=2
# https://bugs.gentoo.org/show_bug.cgi?id=577842
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=804908
# https://bugs.archlinux.org/task/45816
# https://bugzilla.redhat.com/show_bug.cgi?id=1318441
# https://bugzilla.redhat.com/show_bug.cgi?id=1389347
if use systemd; then
dosym obex.service /usr/lib/systemd/user/dbus-org.bluez.obex.service
fi
find "${D}" -name '*.la' -type f -delete || die
keepdir /var/lib/bluetooth
# Upstream don't want people to play with them
# But we keep installing them due to 'historical' reasons
insinto /etc/bluetooth
local d
for d in input network; do
doins profiles/${d}/${d}.conf
done
# Setup auto enable as Fedora does for allowing to use
# keyboards/mouse as soon as possible
sed -i 's/#\[Policy\]$/\[Policy\]/; s/#AutoEnable=false/AutoEnable=true/' src/main.conf || die
doins src/main.conf
newinitd "${FILESDIR}"/bluetooth-init.d-r5 bluetooth
newconfd "${FILESDIR}"/bluetooth-conf.d bluetooth
einstalldocs
use doc && dodoc doc/*.txt
# Install .json files as examples to be used by meshctl
if use mesh; then
dodoc tools/mesh-gatt/*.json
local DOC_CONTENTS="Some example .json files were installed into
/usr/share/doc/${PF} to be used with meshctl. Feel free to
uncompress and copy them to ~/.config/meshctl to use them."
readme.gentoo_create_doc
fi
}
pkg_postinst() {
use udev && udev_reload
systemd_reenable bluetooth.service
has_version net-dialup/ppp || elog "To use dial up networking you must install net-dialup/ppp"
use mesh && readme.gentoo_print_elog
}

View File

@@ -1,295 +0,0 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{8..10} )
inherit autotools linux-info python-single-r1 readme.gentoo-r1 systemd udev multilib-minimal
DESCRIPTION="Bluetooth Tools and System Daemons for Linux"
HOMEPAGE="http://www.bluez.org"
SRC_URI="https://www.kernel.org/pub/linux/bluetooth/${P}.tar.xz"
LICENSE="GPL-2+ LGPL-2.1+"
SLOT="0/3"
KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~riscv ~x86"
IUSE="btpclient cups doc debug deprecated extra-tools experimental +mesh midi +obex +readline selinux systemd test test-programs +udev"
# Since this release all remaining extra-tools need readline support, but this could
# change in the future, hence, this REQUIRED_USE constraint could be dropped
# again in the future.
# btpclient needs mesh, bug #790587
REQUIRED_USE="
extra-tools? ( deprecated readline )
test? ( ${PYTHON_REQUIRED_USE} )
test-programs? ( ${PYTHON_REQUIRED_USE} )
"
TEST_DEPS="${PYTHON_DEPS}
$(python_gen_cond_dep '
>=dev-python/dbus-python-1[${PYTHON_USEDEP}]
dev-python/pygobject:3[${PYTHON_USEDEP}]
')
"
BDEPEND="
dev-python/docutils
virtual/pkgconfig
test? ( ${TEST_DEPS} )
"
DEPEND="
>=dev-libs/glib-2.28:2[${MULTILIB_USEDEP}]
btpclient? ( >=dev-libs/ell-0.39 )
cups? ( net-print/cups:= )
mesh? (
>=dev-libs/ell-0.39
>=dev-libs/json-c-0.13:=
sys-libs/readline:0=
)
midi? ( media-libs/alsa-lib )
obex? ( dev-libs/libical:= )
readline? ( sys-libs/readline:0= )
systemd? ( sys-apps/systemd )
>=sys-apps/dbus-1.6:=
udev? ( >=virtual/udev-172 )
"
RDEPEND="${DEPEND}
selinux? ( sec-policy/selinux-bluetooth )
test-programs? ( ${TEST_DEPS} )
"
RESTRICT="!test? ( test )"
PATCHES=(
# Try both udevadm paths to cover udev/systemd vs. eudev locations (#539844)
# http://www.spinics.net/lists/linux-bluetooth/msg58739.html
# https://bugs.gentoo.org/539844
# https://github.com/bluez/bluez/issues/268
"${FILESDIR}"/${PN}-udevadm-path-r1.patch
# https://github.com/bluez/bluez/issues/267
"${FILESDIR}"/${PN}-5.63-musl-limits.patch
# Fedora patches
# http://www.spinics.net/lists/linux-bluetooth/msg40136.html
"${FILESDIR}"/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
# https://github.com/bluez/bluez/issues/220
"${FILESDIR}"/0001-hog-Fix-read-order-of-attributes-rediffed.patch
"${FILESDIR}"/0002-hog-Add-input-queue-while-uhid-device-has-not-been-c-rediffed.patch
)
pkg_setup() {
# From http://www.linuxfromscratch.org/blfs/view/svn/general/bluez.html
# to prevent bugs like:
# https://bugzilla.kernel.org/show_bug.cgi?id=196621
CONFIG_CHECK="~NET ~BT ~BT_RFCOMM ~BT_RFCOMM_TTY ~BT_BNEP ~BT_BNEP_MC_FILTER
~BT_BNEP_PROTO_FILTER ~BT_HIDP ~CRYPTO_USER_API_HASH ~CRYPTO_USER_API_SKCIPHER ~RFKILL"
# https://bugzilla.kernel.org/show_bug.cgi?id=196621
# https://bugzilla.kernel.org/show_bug.cgi?id=206815
if use mesh || use test; then
CONFIG_CHECK="${CONFIG_CHECK} ~CRYPTO_USER
~CRYPTO_USER_API ~CRYPTO_USER_API_AEAD ~CRYPTO_AES ~CRYPTO_CCM ~CRYPTO_AEAD ~CRYPTO_CMAC
~CRYPTO_MD5 ~CRYPTO_SHA1 ~KEY_DH_OPERATIONS"
fi
linux-info_pkg_setup
if use test || use test-programs; then
python-single-r1_pkg_setup
fi
if ! use udev; then
ewarn
ewarn "You are installing ${PN} with USE=-udev. This means various bluetooth"
ewarn "devices and adapters from Apple, Dell, Logitech etc. will not work,"
ewarn "and hid2hci will not be available."
ewarn
fi
}
src_prepare() {
default
# http://www.spinics.net/lists/linux-bluetooth/msg38490.html
if ! use systemd; then
eapply "${FILESDIR}"/0001-Allow-using-obexd-without-systemd-in-the-user-session-r2.patch
fi
eautoreconf
if use cups; then
# Only not .am to not need to run eautoreconf only because of this
sed -i \
-e "s:cupsdir = \$(libdir)/cups:cupsdir = $(cups-config --serverbin):" \
Makefile.{in,tools} || die
fi
multilib_copy_sources
}
multilib_src_configure() {
local myconf=(
# readline is automagic when client is enabled
# --enable-client always needs readline, bug #504038
# --enable-mesh is handled in the same way
ac_cv_header_readline_readline_h=$(multilib_native_usex readline)
ac_cv_header_readline_readline_h=$(multilib_native_usex mesh)
)
if ! multilib_is_native_abi; then
myconf+=(
# deps not used for the library
{DBUS,GLIB}_{CFLAGS,LIBS}=' '
)
fi
econf \
--localstatedir=/var \
--disable-android \
--enable-datafiles \
--enable-optimization \
$(use_enable debug) \
--enable-pie \
--enable-threads \
--enable-library \
--enable-tools \
--enable-manpages \
--enable-monitor \
--with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
--with-systemduserunitdir="$(systemd_get_userunitdir)" \
$(multilib_native_use_enable btpclient) \
$(multilib_native_use_enable btpclient external-ell) \
$(multilib_native_use_enable cups) \
$(multilib_native_use_enable deprecated) \
$(multilib_native_use_enable experimental) \
$(multilib_native_use_enable mesh) \
$(multilib_native_use_enable mesh external-ell) \
$(multilib_native_use_enable midi) \
$(multilib_native_use_enable obex) \
$(multilib_native_use_enable readline client) \
$(multilib_native_use_enable systemd) \
$(multilib_native_use_enable test-programs test) \
$(multilib_native_use_enable udev) \
$(multilib_native_use_enable udev hid2hci) \
$(multilib_native_use_enable udev sixaxis)
}
multilib_src_compile() {
if multilib_is_native_abi; then
default
else
emake -f Makefile -f - libs \
<<<'libs: $(lib_LTLIBRARIES)'
fi
}
multilib_src_test() {
multilib_is_native_abi && default
}
multilib_src_install() {
if multilib_is_native_abi; then
emake DESTDIR="${D}" install
# Only install extra-tools when relevant USE flag is enabled
if use extra-tools; then
ewarn "Upstream doesn't support using this tools and their bugs are"
ewarn "likely to be ignored forever, also they can break without"
ewarn "previous announcement."
ewarn "Upstream also states all this tools are not really needed,"
ewarn "then, if you still need to rely on them, you must ask them"
ewarn "to either install that tool by default or add the needed"
ewarn "functionality to the existing 'official' tools."
ewarn "Please report this issues to:"
ewarn "http://www.bluez.org/development/lists/"
# Upstream doesn't install this, bug #524640
# http://permalink.gmane.org/gmane.linux.bluez.kernel/53115
# http://comments.gmane.org/gmane.linux.bluez.kernel/54564
dobin tools/btmgmt
# gatttool is only built with readline, bug #530776
# https://bugzilla.redhat.com/show_bug.cgi?id=1141909
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=720486
# https://bugs.archlinux.org/task/37686
dobin attrib/gatttool
# https://bugzilla.redhat.com/show_bug.cgi?id=1699680
dobin tools/avinfo
fi
# Not installed by default after being built, bug #666756
use btpclient && dobin tools/btpclient
# Unittests are not that useful once installed, so make them optional
if use test-programs; then
# Drop python2 only test tools
# https://bugzilla.kernel.org/show_bug.cgi?id=206819
rm "${ED}"/usr/$(get_libdir)/bluez/test/simple-player || die
# https://bugzilla.kernel.org/show_bug.cgi?id=206821
rm "${ED}"/usr/$(get_libdir)/bluez/test/test-hfp || die
# https://bugzilla.kernel.org/show_bug.cgi?id=206823
rm "${ED}"/usr/$(get_libdir)/bluez/test/test-sap-server || die
python_fix_shebang "${ED}"/usr/$(get_libdir)/bluez/test
for i in $(find "${ED}"/usr/$(get_libdir)/bluez/test -maxdepth 1 -type f ! -name "*.*"); do
dosym "${i}" /usr/bin/bluez-"${i##*/}"
done
fi
else
emake DESTDIR="${D}" \
install-pkgincludeHEADERS \
install-libLTLIBRARIES \
install-pkgconfigDATA
fi
}
multilib_src_install_all() {
# We need to ensure obexd can be spawned automatically by systemd
# when user-session is enabled:
# http://marc.info/?l=linux-bluetooth&m=148096094716386&w=2
# https://bugs.gentoo.org/show_bug.cgi?id=577842
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=804908
# https://bugs.archlinux.org/task/45816
# https://bugzilla.redhat.com/show_bug.cgi?id=1318441
# https://bugzilla.redhat.com/show_bug.cgi?id=1389347
if use systemd; then
dosym obex.service /usr/lib/systemd/user/dbus-org.bluez.obex.service
fi
find "${D}" -name '*.la' -type f -delete || die
keepdir /var/lib/bluetooth
# Upstream don't want people to play with them
# But we keep installing them due to 'historical' reasons
insinto /etc/bluetooth
local d
for d in input network; do
doins profiles/${d}/${d}.conf
done
# Setup auto enable as Fedora does for allowing to use
# keyboards/mouse as soon as possible
sed -i 's/#\[Policy\]$/\[Policy\]/; s/#AutoEnable=false/AutoEnable=true/' src/main.conf || die
doins src/main.conf
newinitd "${FILESDIR}"/bluetooth-init.d-r5 bluetooth
newconfd "${FILESDIR}"/bluetooth-conf.d bluetooth
einstalldocs
use doc && dodoc doc/*.txt
# Install .json files as examples to be used by meshctl
if use mesh; then
dodoc tools/mesh-gatt/*.json
local DOC_CONTENTS="Some example .json files were installed into
/usr/share/doc/${PF} to be used with meshctl. Feel free to
uncompress and copy them to ~/.config/meshctl to use them."
readme.gentoo_create_doc
fi
}
pkg_postinst() {
use udev && udev_reload
systemd_reenable bluetooth.service
has_version net-dialup/ppp || elog "To use dial up networking you must install net-dialup/ppp"
use mesh && readme.gentoo_print_elog
}

View File

@@ -1,188 +0,0 @@
From 697866e210e4e2dce14c95f7a7243e9b9128d01f Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Sun, 7 Nov 2021 15:10:53 -0800
Subject: [PATCH] Revert "attrib: Make use of bt_att_resend"
This reverts commit ac2c2e10b3adb432a572b618c6f53cabb6b3c80b. It
causes problems with Logitech MX wireless input devices (see
https://github.com/bluez/bluez/issues/220 and
https://bugzilla.redhat.com/show_bug.cgi?id=2019970 ).
---
attrib/gattrib.c | 95 +++++++++++++++++++++++++++++++++++++-----------
1 file changed, 73 insertions(+), 22 deletions(-)
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 270a37ebe..bc7d4f22c 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -41,8 +41,13 @@ struct _GAttrib {
struct queue *track_ids;
};
+struct id_pair {
+ unsigned int org_id;
+ unsigned int pend_id;
+};
+
struct attrib_callbacks {
- unsigned int id;
+ struct id_pair *id;
GAttribResultFunc result_func;
GAttribNotifyFunc notify_func;
GDestroyNotify destroy_func;
@@ -51,6 +56,32 @@ struct attrib_callbacks {
uint16_t notify_handle;
};
+static bool find_with_org_id(const void *data, const void *user_data)
+{
+ const struct id_pair *p = data;
+ unsigned int orig_id = PTR_TO_UINT(user_data);
+
+ return (p->org_id == orig_id);
+}
+
+static struct id_pair *store_id(GAttrib *attrib, unsigned int org_id,
+ unsigned int pend_id)
+{
+ struct id_pair *t;
+
+ t = new0(struct id_pair, 1);
+ if (!t)
+ return NULL;
+
+ t->org_id = org_id;
+ t->pend_id = pend_id;
+
+ if (queue_push_tail(attrib->track_ids, t))
+ return t;
+
+ return NULL;
+}
+
GAttrib *g_attrib_new(GIOChannel *io, guint16 mtu, bool ext_signed)
{
gint fd;
@@ -119,6 +150,9 @@ static void attrib_callbacks_destroy(void *data)
if (cb->destroy_func)
cb->destroy_func(cb->user_data);
+ if (queue_remove(cb->parent->track_ids, cb->id))
+ free(cb->id);
+
free(data);
}
@@ -148,7 +182,7 @@ void g_attrib_unref(GAttrib *attrib)
bt_att_unref(attrib->att);
queue_destroy(attrib->callbacks, attrib_callbacks_destroy);
- queue_destroy(attrib->track_ids, NULL);
+ queue_destroy(attrib->track_ids, free);
free(attrib->buf);
@@ -261,6 +295,7 @@ guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
struct attrib_callbacks *cb = NULL;
bt_att_response_func_t response_cb = NULL;
bt_att_destroy_func_t destroy_cb = NULL;
+ unsigned int pend_id;
if (!attrib)
return 0;
@@ -282,47 +317,62 @@ guint g_attrib_send(GAttrib *attrib, guint id, const guint8 *pdu, guint16 len,
}
- if (id == 0)
- id = bt_att_send(attrib->att, pdu[0], (void *) pdu + 1,
- len - 1, response_cb, cb, destroy_cb);
- else {
- int err;
-
- err = bt_att_resend(attrib->att, id, pdu[0], (void *) pdu + 1,
- len - 1, response_cb, cb, destroy_cb);
- if (err)
- return 0;
- }
+ pend_id = bt_att_send(attrib->att, pdu[0], (void *) pdu + 1, len - 1,
+ response_cb, cb, destroy_cb);
- if (!id)
- return id;
+ /*
+ * We store here pair as it is easier to handle it in response and in
+ * case where user request us to use specific id request - see below.
+ */
+ if (id == 0)
+ id = pend_id;
/*
* If user what us to use given id, lets keep track on that so we give
* user a possibility to cancel ongoing request.
*/
- if (cb) {
- cb->id = id;
- queue_push_tail(attrib->track_ids, UINT_TO_PTR(id));
- }
+ if (cb)
+ cb->id = store_id(attrib, id, pend_id);
return id;
}
gboolean g_attrib_cancel(GAttrib *attrib, guint id)
{
+ struct id_pair *p;
+
if (!attrib)
return FALSE;
+ /*
+ * If request belongs to gattrib and is not yet done it has to be on
+ * the tracking id queue
+ *
+ * FIXME: It can happen that on the queue there is id_pair with
+ * given id which was provided by the user. In the same time it might
+ * happen that other attrib user got dynamic allocated req_id with same
+ * value as the one provided by the other user.
+ * In such case there are two clients having same request id and in
+ * this point of time we don't know which one calls cancel. For
+ * now we cancel request in which id was specified by the user.
+ */
+ p = queue_remove_if(attrib->track_ids, find_with_org_id,
+ UINT_TO_PTR(id));
+ if (!p)
+ return FALSE;
+
+ id = p->pend_id;
+ free(p);
+
return bt_att_cancel(attrib->att, id);
}
static void cancel_request(void *data, void *user_data)
{
- unsigned int id = PTR_TO_UINT(data);
+ struct id_pair *p = data;
GAttrib *attrib = user_data;
- bt_att_cancel(attrib->att, id);
+ bt_att_cancel(attrib->att, p->pend_id);
}
gboolean g_attrib_cancel_all(GAttrib *attrib)
@@ -330,8 +380,9 @@ gboolean g_attrib_cancel_all(GAttrib *attrib)
if (!attrib)
return FALSE;
+ /* Cancel only request which belongs to gattrib */
queue_foreach(attrib->track_ids, cancel_request, attrib);
- queue_remove_all(attrib->track_ids, NULL, NULL, NULL);
+ queue_remove_all(attrib->track_ids, NULL, NULL, free);
return TRUE;
}
--
2.33.1

View File

@@ -1,542 +0,0 @@
From 7fe38a17f6bee713fde587487fc224b0ae390e8f Mon Sep 17 00:00:00 2001
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date: Mon, 10 Jan 2022 17:35:15 -0800
Subject: [PATCH 1/2] hog: Fix read order of attributes
The Report Map must be read after all other attributes otherwise the
Kernel driver may start using UHID_SET_REPORT which requires the
report->id to be known in order to resolve the attribute to send to.
Fixes: https://github.com/bluez/bluez/issues/220
---
profiles/input/hog-lib.c | 191 ++++++++++++++++++++++++---------------
1 file changed, 119 insertions(+), 72 deletions(-)
diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
index d37caa1f1..beb19af70 100644
--- a/profiles/input/hog-lib.c
+++ b/profiles/input/hog-lib.c
@@ -90,6 +90,7 @@ struct bt_hog {
uint16_t getrep_id;
unsigned int setrep_att;
uint16_t setrep_id;
+ unsigned int report_map_id;
struct bt_scpp *scpp;
struct bt_dis *dis;
struct queue *bas;
@@ -146,13 +147,34 @@ static bool set_and_store_gatt_req(struct bt_hog *hog,
return queue_push_head(hog->gatt_op, req);
}
-static void destroy_gatt_req(struct gatt_request *req)
+static void destroy_gatt_req(void *data)
{
- queue_remove(req->hog->gatt_op, req);
+ struct gatt_request *req = data;
+
bt_hog_unref(req->hog);
free(req);
}
+static void read_report_map(struct bt_hog *hog);
+
+static void remove_gatt_req(struct gatt_request *req, uint8_t status)
+{
+ struct bt_hog *hog = req->hog;
+
+ queue_remove(hog->gatt_op, req);
+
+ if (!status && queue_isempty(hog->gatt_op)) {
+ /* Report Map must be read last since that can result
+ * in uhid being created and the driver may start to
+ * use UHID_SET_REPORT which requires the report->id to
+ * be known what attribute to send to.
+ */
+ read_report_map(hog);
+ }
+
+ destroy_gatt_req(req);
+}
+
static void write_char(struct bt_hog *hog, GAttrib *attrib, uint16_t handle,
const uint8_t *value, size_t vlen,
GAttribResultFunc func,
@@ -178,27 +200,31 @@ static void write_char(struct bt_hog *hog, GAttrib *attrib, uint16_t handle,
}
}
-static void read_char(struct bt_hog *hog, GAttrib *attrib, uint16_t handle,
- GAttribResultFunc func, gpointer user_data)
+static unsigned int read_char(struct bt_hog *hog, GAttrib *attrib,
+ uint16_t handle, GAttribResultFunc func,
+ gpointer user_data)
{
struct gatt_request *req;
unsigned int id;
req = create_request(hog, user_data);
if (!req)
- return;
+ return 0;
id = gatt_read_char(attrib, handle, func, req);
if (!id) {
error("hog: Could not read char");
- return;
+ return 0;
}
if (!set_and_store_gatt_req(hog, req, id)) {
error("hog: Failed to queue read char req");
g_attrib_cancel(attrib, id);
free(req);
+ return 0;
}
+
+ return id;
}
static void discover_desc(struct bt_hog *hog, GAttrib *attrib,
@@ -343,16 +369,14 @@ static void report_ccc_written_cb(guint8 status, const guint8 *pdu,
struct report *report = req->user_data;
struct bt_hog *hog = report->hog;
- destroy_gatt_req(req);
-
if (status != 0) {
error("Write report characteristic descriptor failed: %s",
att_ecode2str(status));
- return;
+ goto remove;
}
if (report->notifyid)
- return;
+ goto remove;
report->notifyid = g_attrib_register(hog->attrib,
ATT_OP_HANDLE_NOTIFY,
@@ -360,6 +384,9 @@ static void report_ccc_written_cb(guint8 status, const guint8 *pdu,
report_value_cb, report, NULL);
DBG("Report characteristic descriptor written: notifications enabled");
+
+remove:
+ remove_gatt_req(req, status);
}
static void write_ccc(struct bt_hog *hog, GAttrib *attrib, uint16_t handle,
@@ -379,14 +406,15 @@ static void ccc_read_cb(guint8 status, const guint8 *pdu, guint16 len,
struct gatt_request *req = user_data;
struct report *report = req->user_data;
- destroy_gatt_req(req);
-
if (status != 0) {
error("Error reading CCC value: %s", att_ecode2str(status));
- return;
+ goto remove;
}
write_ccc(report->hog, report->hog->attrib, report->ccc_handle, report);
+
+remove:
+ remove_gatt_req(req, status);
}
static const char *type_to_string(uint8_t type)
@@ -409,17 +437,15 @@ static void report_reference_cb(guint8 status, const guint8 *pdu,
struct gatt_request *req = user_data;
struct report *report = req->user_data;
- destroy_gatt_req(req);
-
if (status != 0) {
error("Read Report Reference descriptor failed: %s",
att_ecode2str(status));
- return;
+ goto remove;
}
if (plen != 3) {
error("Malformed ATT read response");
- return;
+ goto remove;
}
report->id = pdu[1];
@@ -432,6 +458,9 @@ static void report_reference_cb(guint8 status, const guint8 *pdu,
if (report->type == HOG_REPORT_TYPE_INPUT)
read_char(report->hog, report->hog->attrib, report->ccc_handle,
ccc_read_cb, report);
+
+remove:
+ remove_gatt_req(req, status);
}
static void external_report_reference_cb(guint8 status, const guint8 *pdu,
@@ -442,12 +471,10 @@ static void discover_external_cb(uint8_t status, GSList *descs, void *user_data)
struct gatt_request *req = user_data;
struct bt_hog *hog = req->user_data;
- destroy_gatt_req(req);
-
if (status != 0) {
error("Discover external descriptors failed: %s",
att_ecode2str(status));
- return;
+ goto remove;
}
for ( ; descs; descs = descs->next) {
@@ -457,6 +484,9 @@ static void discover_external_cb(uint8_t status, GSList *descs, void *user_data)
external_report_reference_cb,
hog);
}
+
+remove:
+ remove_gatt_req(req, status);
}
static void discover_external(struct bt_hog *hog, GAttrib *attrib,
@@ -480,12 +510,10 @@ static void discover_report_cb(uint8_t status, GSList *descs, void *user_data)
struct report *report = req->user_data;
struct bt_hog *hog = report->hog;
- destroy_gatt_req(req);
-
if (status != 0) {
error("Discover report descriptors failed: %s",
att_ecode2str(status));
- return;
+ goto remove;
}
for ( ; descs; descs = descs->next) {
@@ -501,6 +529,9 @@ static void discover_report_cb(uint8_t status, GSList *descs, void *user_data)
break;
}
}
+
+remove:
+ remove_gatt_req(req, status);
}
static void discover_report(struct bt_hog *hog, GAttrib *attrib,
@@ -519,11 +550,9 @@ static void report_read_cb(guint8 status, const guint8 *pdu, guint16 len,
struct gatt_request *req = user_data;
struct report *report = req->user_data;
- destroy_gatt_req(req);
-
if (status != 0) {
error("Error reading Report value: %s", att_ecode2str(status));
- return;
+ goto remove;
}
if (report->value)
@@ -531,6 +560,9 @@ static void report_read_cb(guint8 status, const guint8 *pdu, guint16 len,
report->value = g_memdup2(pdu, len);
report->len = len;
+
+remove:
+ remove_gatt_req(req, status);
}
static int report_chrc_cmp(const void *data, const void *user_data)
@@ -572,12 +604,11 @@ static void external_service_char_cb(uint8_t status, GSList *chars,
struct report *report;
GSList *l;
- destroy_gatt_req(req);
-
if (status != 0) {
const char *str = att_ecode2str(status);
+
DBG("Discover external service characteristic failed: %s", str);
- return;
+ goto remove;
}
for (l = chars; l; l = g_slist_next(l)) {
@@ -595,6 +626,9 @@ static void external_service_char_cb(uint8_t status, GSList *chars,
end = (next ? next->handle - 1 : primary->range.end);
discover_report(hog, hog->attrib, start, end, report);
}
+
+remove:
+ remove_gatt_req(req, status);
}
static void external_report_reference_cb(guint8 status, const guint8 *pdu,
@@ -605,17 +639,15 @@ static void external_report_reference_cb(guint8 status, const guint8 *pdu,
uint16_t uuid16;
bt_uuid_t uuid;
- destroy_gatt_req(req);
-
if (status != 0) {
error("Read External Report Reference descriptor failed: %s",
att_ecode2str(status));
- return;
+ goto remove;
}
if (plen != 3) {
error("Malformed ATT read response");
- return;
+ goto remove;
}
uuid16 = get_le16(&pdu[1]);
@@ -624,11 +656,14 @@ static void external_report_reference_cb(guint8 status, const guint8 *pdu,
/* Do not discover if is not a Report */
if (uuid16 != HOG_REPORT_UUID)
- return;
+ goto remove;
bt_uuid16_create(&uuid, uuid16);
discover_char(hog, hog->attrib, 0x0001, 0xffff, &uuid,
external_service_char_cb, hog);
+
+remove:
+ remove_gatt_req(req, status);
}
static int report_cmp(gconstpointer a, gconstpointer b)
@@ -687,12 +722,10 @@ static void output_written_cb(guint8 status, const guint8 *pdu,
{
struct gatt_request *req = user_data;
- destroy_gatt_req(req);
-
- if (status != 0) {
+ if (status != 0)
error("Write output report failed: %s", att_ecode2str(status));
- return;
- }
+
+ remove_gatt_req(req, status);
}
static void forward_report(struct uhid_event *ev, void *user_data)
@@ -1056,7 +1089,7 @@ static void report_map_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
uint8_t value[HOG_REPORT_MAP_MAX_SIZE];
ssize_t vlen;
- destroy_gatt_req(req);
+ remove_gatt_req(req, status);
DBG("HoG inspecting report map");
@@ -1081,6 +1114,19 @@ static void report_map_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
}
}
+static void read_report_map(struct bt_hog *hog)
+{
+ uint16_t handle;
+
+ if (!hog->report_map_attr || hog->uhid_created || hog->report_map_id)
+ return;
+
+ handle = gatt_db_attribute_get_handle(hog->report_map_attr);
+
+ hog->report_map_id = read_char(hog, hog->attrib, handle,
+ report_map_read_cb, hog);
+}
+
static void info_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
gpointer user_data)
{
@@ -1089,18 +1135,16 @@ static void info_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
uint8_t value[HID_INFO_SIZE];
ssize_t vlen;
- destroy_gatt_req(req);
-
if (status != 0) {
error("HID Information read failed: %s",
att_ecode2str(status));
- return;
+ goto remove;
}
vlen = dec_read_resp(pdu, plen, value, sizeof(value));
if (vlen != 4) {
error("ATT protocol error");
- return;
+ goto remove;
}
hog->bcdhid = get_le16(&value[0]);
@@ -1109,6 +1153,9 @@ static void info_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
DBG("bcdHID: 0x%04X bCountryCode: 0x%02X Flags: 0x%02X",
hog->bcdhid, hog->bcountrycode, hog->flags);
+
+remove:
+ remove_gatt_req(req, status);
}
static void proto_mode_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
@@ -1119,18 +1166,16 @@ static void proto_mode_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
uint8_t value;
ssize_t vlen;
- destroy_gatt_req(req);
-
if (status != 0) {
error("Protocol Mode characteristic read failed: %s",
att_ecode2str(status));
- return;
+ goto remove;
}
vlen = dec_read_resp(pdu, plen, &value, sizeof(value));
if (vlen < 0) {
error("ATT protocol error");
- return;
+ goto remove;
}
if (value == HOG_PROTO_MODE_BOOT) {
@@ -1142,6 +1187,9 @@ static void proto_mode_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
sizeof(nval), NULL, NULL);
} else if (value == HOG_PROTO_MODE_REPORT)
DBG("HoG is operating in Report Protocol Mode");
+
+remove:
+ remove_gatt_req(req, status);
}
static void char_discovered_cb(uint8_t status, GSList *chars, void *user_data)
@@ -1155,14 +1203,12 @@ static void char_discovered_cb(uint8_t status, GSList *chars, void *user_data)
GSList *l;
uint16_t info_handle = 0, proto_mode_handle = 0;
- destroy_gatt_req(req);
-
DBG("HoG inspecting characteristics");
if (status != 0) {
- const char *str = att_ecode2str(status);
- DBG("Discover all characteristics failed: %s", str);
- return;
+ DBG("Discover all characteristics failed: %s",
+ att_ecode2str(status));
+ goto remove;
}
bt_uuid16_create(&report_uuid, HOG_REPORT_UUID);
@@ -1211,6 +1257,9 @@ static void char_discovered_cb(uint8_t status, GSList *chars, void *user_data)
if (info_handle)
read_char(hog, hog->attrib, info_handle, info_read_cb, hog);
+
+remove:
+ remove_gatt_req(req, status);
}
static void report_free(void *data)
@@ -1221,10 +1270,12 @@ static void report_free(void *data)
g_free(report);
}
-static void cancel_gatt_req(struct gatt_request *req)
+static bool cancel_gatt_req(const void *data, const void *user_data)
{
- if (g_attrib_cancel(req->hog->attrib, req->id))
- destroy_gatt_req(req);
+ struct gatt_request *req = (void *) data;
+ const struct bt_hog *hog = user_data;
+
+ return g_attrib_cancel(hog->attrib, req->id);
}
static void hog_free(void *data)
@@ -1386,13 +1437,9 @@ static void foreach_hog_chrc(struct gatt_db_attribute *attr, void *user_data)
* UHID to optimize reconnection.
*/
uhid_create(hog, report_map.value, report_map.length);
- } else {
- read_char(hog, hog->attrib, value_handle,
- report_map_read_cb, hog);
}
gatt_db_service_foreach_desc(attr, foreach_hog_external, hog);
- return;
}
bt_uuid16_create(&info_uuid, HOG_INFO_UUID);
@@ -1552,12 +1599,9 @@ static void find_included_cb(uint8_t status, GSList *services, void *user_data)
DBG("");
- destroy_gatt_req(req);
-
if (status) {
- const char *str = att_ecode2str(status);
- DBG("Find included failed: %s", str);
- return;
+ DBG("Find included failed: %s", att_ecode2str(status));
+ goto remove;
}
for (l = services; l; l = l->next) {
@@ -1566,6 +1610,9 @@ static void find_included_cb(uint8_t status, GSList *services, void *user_data)
DBG("included: handle %x, uuid %s",
include->handle, include->uuid);
}
+
+remove:
+ remove_gatt_req(req, status);
}
static void hog_attach_scpp(struct bt_hog *hog, struct gatt_primary *primary)
@@ -1640,17 +1687,14 @@ static void primary_cb(uint8_t status, GSList *services, void *user_data)
DBG("");
- destroy_gatt_req(req);
-
if (status) {
- const char *str = att_ecode2str(status);
- DBG("Discover primary failed: %s", str);
- return;
+ DBG("Discover primary failed: %s", att_ecode2str(status));
+ goto remove;
}
if (!services) {
DBG("No primary service found");
- return;
+ goto remove;
}
for (l = services; l; l = l->next) {
@@ -1674,6 +1718,9 @@ static void primary_cb(uint8_t status, GSList *services, void *user_data)
if (strcmp(primary->uuid, HOG_UUID) == 0)
hog_attach_hog(hog, primary);
}
+
+remove:
+ remove_gatt_req(req, status);
}
bool bt_hog_attach(struct bt_hog *hog, void *gatt)
@@ -1790,7 +1837,7 @@ void bt_hog_detach(struct bt_hog *hog)
if (hog->dis)
bt_dis_detach(hog->dis);
- queue_foreach(hog->gatt_op, (void *) cancel_gatt_req, NULL);
+ queue_remove_all(hog->gatt_op, cancel_gatt_req, hog, destroy_gatt_req);
g_attrib_unref(hog->attrib);
hog->attrib = NULL;
uhid_destroy(hog);
--
2.34.1

View File

@@ -1,90 +0,0 @@
From 33d13bbc5703185ab3f15e4429df324987f3f225 Mon Sep 17 00:00:00 2001
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date: Wed, 12 Jan 2022 14:07:36 -0800
Subject: [PATCH 2/2] hog: Add input queue while uhid device has not been
created
Since report map is only read after all reports it is possible to start
receiving notifications before uhid has been created, so this adds a
queue to store the events while the report map is pending and once uhid
has been created dequeue the events.
---
profiles/input/hog-lib.c | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
index beb19af70..0b375feb8 100644
--- a/profiles/input/hog-lib.c
+++ b/profiles/input/hog-lib.c
@@ -98,6 +98,7 @@ struct bt_hog {
struct queue *gatt_op;
struct gatt_db *gatt_db;
struct gatt_db_attribute *report_map_attr;
+ struct queue *input;
};
struct report_map {
@@ -355,11 +356,18 @@ static void report_value_cb(const guint8 *pdu, guint16 len, gpointer user_data)
ev.u.input.size = len;
}
- err = bt_uhid_send(hog->uhid, &ev);
- if (err < 0) {
- error("bt_uhid_send: %s (%d)", strerror(-err), -err);
+ /* If uhid had not been created yet queue up the input */
+ if (!hog->uhid_created) {
+ if (!hog->input)
+ hog->input = queue_new();
+
+ queue_push_tail(hog->input, g_memdup(&ev, sizeof(ev)));
return;
}
+
+ err = bt_uhid_send(hog->uhid, &ev);
+ if (err < 0)
+ error("bt_uhid_send: %s (%d)", strerror(-err), -err);
}
static void report_ccc_written_cb(guint8 status, const guint8 *pdu,
@@ -993,6 +1001,21 @@ static char *item2string(char *str, uint8_t *buf, uint8_t len)
return str;
}
+static bool input_dequeue(const void *data, const void *match_data)
+{
+ const struct uhid_event *ev = data;
+ const struct bt_hog *hog = match_data;
+ int err;
+
+ err = bt_uhid_send(hog->uhid, ev);
+ if (err < 0) {
+ error("bt_uhid_send: %s (%d)", strerror(-err), -err);
+ return false;
+ }
+
+ return true;
+}
+
static void uhid_create(struct bt_hog *hog, uint8_t *report_map,
ssize_t report_map_len)
{
@@ -1072,6 +1095,8 @@ static void uhid_create(struct bt_hog *hog, uint8_t *report_map,
hog->uhid_created = true;
DBG("HoG created uHID device");
+
+ queue_remove_all(hog->input, input_dequeue, hog, free);
}
static void db_report_map_write_value_cb(struct gatt_db_attribute *attr,
@@ -1284,6 +1309,7 @@ static void hog_free(void *data)
bt_hog_detach(hog);
+ queue_destroy(hog->input, free);
queue_destroy(hog->bas, (void *) bt_bas_unref);
g_slist_free_full(hog->instances, hog_free);
--
2.34.1

View File

@@ -1,54 +0,0 @@
From ebf2d7935690c00c7fd12768177e2023fc63c9fe Mon Sep 17 00:00:00 2001
From: Javier de San Pedro <dev.git@javispedro.com>
Date: Sat, 27 Nov 2021 23:21:36 +0100
Subject: gatt-client: Fix disconnecting due to GattCharacteristic1.MTU
After the MTU dbus property patches in 5.62 we are seeing bluetoothd
terminate frequently with "Disconnected from D-Bus. Exiting." msgs.
Apparently this is because bluetoothd sent an invalid reply to a D-Bus
Property Get (for GattCharacteristic1's MTU).
Multiple issues in bluez Github.com project reported similar behavior;
at least #235 (see Fixes:), #219, and likely #238.
When the Characteristic1 object is still cached/alive, but the
underlying att connection is not (e.g. someone just called Disconnect),
the property getter (characteristic_get_mtu) right now returns false.
However, gdbus seems to ignore the return value and sends the empty reply
message anyway (rather than a dbus error?), and this seems to cause
the dbus connection to be terminated (due to the ill-formed reply?).
bluetoothd then aborts.
This patch makes the property value BT_ATT_DEFAULT_LE_MTU if the
underlying att object does not exist, rather than returning an invalid
message. This is consistent with the existing PropertyChanged signal
behavior (we will emit a PropertyChange only if a larger MTU is
exchanged), and fixes the issue on my machines.
An alternative could be to change gdbus behavior, but I'm not sure if we
are allowed to return an error here anyway without causing problems in
other dbus libraries/wrappers.
Fixes: aaa0c4996ae9 ("gatt: Add implementation of GattCharacteristic1.MTU")
Fixes: https://github.com/bluez/bluez/issues/235
---
src/gatt-client.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/gatt-client.c b/src/gatt-client.c
index de18bea97..6ee984db9 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -883,10 +883,7 @@ static gboolean characteristic_get_mtu(const GDBusPropertyTable *property,
uint16_t mtu;
att = bt_gatt_client_get_att(gatt);
- if (!att)
- return FALSE;
-
- mtu = bt_att_get_mtu(att);
+ mtu = att ? bt_att_get_mtu(att) : BT_ATT_DEFAULT_LE_MTU;
dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &mtu);
--
cgit 1.2.3-1.el7