mirror of
https://anongit.gentoo.org/git/repo/gentoo.git
synced 2026-05-06 07:27:03 -04:00
net-wireless/bluez: Fix multiple bugs
big-endian issues, sink after connection and bluetoothctl with upstreamed patches. Thanks-to: gentoo at fictx dot com Closes: https://bugs.gentoo.org/973371 Signed-off-by: Pacho Ramos <pacho@gentoo.org>
This commit is contained in:
@@ -0,0 +1,275 @@
|
||||
# Copyright 1999-2026 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=8
|
||||
PYTHON_COMPAT=( python3_{11..14} )
|
||||
|
||||
inherit autotools flag-o-matic linux-info optfeature python-single-r1 systemd udev multilib-minimal #readme.gentoo-r1
|
||||
|
||||
DESCRIPTION="Bluetooth Tools and System Daemons for Linux"
|
||||
HOMEPAGE="https://www.bluez.org https://github.com/bluez/bluez"
|
||||
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 ~loong ~mips ~ppc ~ppc64 ~riscv ~x86"
|
||||
IUSE="btpclient cups doc debug deprecated extra-tools experimental man +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="
|
||||
btpclient? ( mesh )
|
||||
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="
|
||||
virtual/pkgconfig
|
||||
man? ( dev-python/docutils )
|
||||
test? ( ${TEST_DEPS} )
|
||||
"
|
||||
DEPEND="
|
||||
>=dev-libs/glib-2.36:2[${MULTILIB_USEDEP}]
|
||||
>=sys-apps/dbus-1.6:=[${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 )
|
||||
udev? ( >=virtual/udev-196 )
|
||||
"
|
||||
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/1650
|
||||
"${FILESDIR}"/${PN}-udevadm-path-r1.patch
|
||||
|
||||
# Upstream fixes included in the next release.
|
||||
"${FILESDIR}"/${P}-a2dp-connect-sink.patch
|
||||
"${FILESDIR}"/${P}-big-endian.patch
|
||||
"${FILESDIR}"/${P}-bluetoothctl-shell.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
|
||||
~UHID ~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
|
||||
|
||||
eautoreconf
|
||||
|
||||
multilib_copy_sources
|
||||
}
|
||||
|
||||
multilib_src_configure() {
|
||||
# unit/test-vcp test fails with LTO (bug #925745)
|
||||
filter-lto
|
||||
|
||||
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 \
|
||||
--enable-datafiles \
|
||||
--enable-optimization \
|
||||
$(use_enable debug) \
|
||||
--enable-pie \
|
||||
--enable-threads \
|
||||
--enable-library \
|
||||
--enable-tools \
|
||||
--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 man manpages) \
|
||||
$(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
|
||||
|
||||
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#${ED}}" /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
|
||||
|
||||
# Setup auto enable as Fedora does for allowing to use
|
||||
# keyboards/mouse as soon as possible
|
||||
insinto /etc/bluetooth
|
||||
doins src/main.conf
|
||||
|
||||
newinitd "${FILESDIR}"/bluetooth-init.d-r5 bluetooth
|
||||
newconfd "${FILESDIR}"/bluetooth-conf.d bluetooth
|
||||
|
||||
einstalldocs
|
||||
use doc && dodoc doc/*.txt
|
||||
|
||||
# https://bugs.gentoo.org/929017
|
||||
# https://github.com/bluez/bluez/issues/329#issuecomment-1102459104
|
||||
fperms 0555 /etc/bluetooth
|
||||
|
||||
# https://bugs.gentoo.org/932172
|
||||
if ! use systemd; then
|
||||
keepdir /var/lib/bluetooth
|
||||
fperms 0700 /var/lib/bluetooth
|
||||
fi
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
use udev && udev_reload
|
||||
systemd_reenable bluetooth.service
|
||||
|
||||
optfeature "Dial-up networking" net-dialup/ppp
|
||||
}
|
||||
|
||||
pkg_postrm() {
|
||||
use udev && udev_reload
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
From 066a164a524e4983b850f5659b921cb42f84a0e0 Mon Sep 17 00:00:00 2001
|
||||
From: Pauli Virtanen <pav@iki.fi>
|
||||
Date: Mon, 16 Feb 2026 18:17:08 +0200
|
||||
Subject: [PATCH] a2dp: connect source profile after sink
|
||||
|
||||
Since cdcd845f87ee the order in which profiles with the same priority
|
||||
are connected is the same order as btd_profile_register() is called,
|
||||
instead of being the opposite order. When initiating connections, we
|
||||
want to prefer a2dp-sink profile over a2dp-source, as connecting both at
|
||||
the same time does not work currently.
|
||||
|
||||
Add .after_services to specify the order.
|
||||
|
||||
Fixes: https://github.com/bluez/bluez/issues/1898
|
||||
---
|
||||
profiles/audio/a2dp.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
|
||||
index 7a37003a2b25..c7e0fc75c09e 100644
|
||||
--- a/profiles/audio/a2dp.c
|
||||
+++ b/profiles/audio/a2dp.c
|
||||
@@ -3769,6 +3769,9 @@ static struct btd_profile a2dp_source_profile = {
|
||||
|
||||
.adapter_probe = a2dp_sink_server_probe,
|
||||
.adapter_remove = a2dp_sink_server_remove,
|
||||
+
|
||||
+ /* Connect source after sink, to prefer sink when conflicting */
|
||||
+ .after_services = BTD_PROFILE_UUID_CB(NULL, A2DP_SINK_UUID),
|
||||
};
|
||||
|
||||
static struct btd_profile a2dp_sink_profile = {
|
||||
--
|
||||
2.53.0
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
From 3a5c4d311755910f07e60fd30d4736ac98bea8eb Mon Sep 17 00:00:00 2001
|
||||
From: Bastien Nocera <hadess@hadess.net>
|
||||
Date: Tue, 10 Feb 2026 10:06:28 +0100
|
||||
Subject: [PATCH] emulator: Fix compilation on big endian systems
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This fixes the build on big endian systems like s390x:
|
||||
|
||||
Remove the "static" so the array doesn't need to be initialised
|
||||
with constants.
|
||||
|
||||
emulator/bthost.c: In function ‘bthost_setup_sco’:
|
||||
./src/shared/util.h:43:26: error: initializer element is not constant
|
||||
43 | #define cpu_to_le32(val) bswap_32(val)
|
||||
| ^~~~~~~~
|
||||
etc.
|
||||
|
||||
Fixes: 85888a8357ea ("bthost: add bthost_setup_sco() and accept
|
||||
incoming eSCO")
|
||||
---
|
||||
emulator/bthost.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/emulator/bthost.c b/emulator/bthost.c
|
||||
index d09ad1e76c50..53b12f828675 100644
|
||||
--- a/emulator/bthost.c
|
||||
+++ b/emulator/bthost.c
|
||||
@@ -3560,7 +3560,7 @@ void bthost_hci_disconnect(struct bthost *bthost, uint16_t handle,
|
||||
int bthost_setup_sco(struct bthost *bthost, uint16_t acl_handle,
|
||||
uint16_t setting)
|
||||
{
|
||||
- static const struct bt_hci_cmd_setup_sync_conn settings[] = {
|
||||
+ const struct bt_hci_cmd_setup_sync_conn settings[] = {
|
||||
{
|
||||
.tx_bandwidth = cpu_to_le32(0x00001f40),
|
||||
.rx_bandwidth = cpu_to_le32(0x00001f40),
|
||||
--
|
||||
2.52.0
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
From 33dd33a23ff250902eafa94fce5ea8178de50112 Mon Sep 17 00:00:00 2001
|
||||
From: Bastien Nocera <hadess@hadess.net>
|
||||
Date: Fri, 27 Feb 2026 12:07:14 +0100
|
||||
Subject: [PATCH 1/2] Revert "shared/shell: Don't init input for
|
||||
non-interactive shells"
|
||||
|
||||
This reverts commit e73bf582dae60356641a32fc27ae03d359ec4c47.
|
||||
|
||||
The fix caused "bluetoothctl list" to not output any text, breaking
|
||||
a lot of existing scripts.
|
||||
|
||||
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2440346
|
||||
---
|
||||
src/shared/shell.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/shared/shell.c b/src/shared/shell.c
|
||||
index 78d58c513d3e..b061f8001414 100644
|
||||
--- a/src/shared/shell.c
|
||||
+++ b/src/shared/shell.c
|
||||
@@ -1642,13 +1642,13 @@ static bool shell_quit(void *data)
|
||||
|
||||
bool bt_shell_attach(int fd)
|
||||
{
|
||||
- if (data.mode == MODE_INTERACTIVE) {
|
||||
- struct input *input;
|
||||
+ struct input *input;
|
||||
|
||||
- input = input_new(fd);
|
||||
- if (!input)
|
||||
- return false;
|
||||
+ input = input_new(fd);
|
||||
+ if (!input)
|
||||
+ return false;
|
||||
|
||||
+ if (data.mode == MODE_INTERACTIVE) {
|
||||
io_set_read_handler(input->io, input_read, input, NULL);
|
||||
io_set_disconnect_handler(input->io, input_hup, input, NULL);
|
||||
|
||||
--
|
||||
2.53.0
|
||||
|
||||
|
||||
From 0178bc8bda31cf60837fcce91b33e009bc3f7d7d Mon Sep 17 00:00:00 2001
|
||||
From: Bastien Nocera <hadess@hadess.net>
|
||||
Date: Fri, 27 Feb 2026 12:24:13 +0100
|
||||
Subject: [PATCH 2/2] tools: Work-around broken stdin handling in home-made
|
||||
mainloop
|
||||
|
||||
bluetoothd has 3 mainloop implementations, one relying on ell, one
|
||||
relying on glib, and another home-made.
|
||||
|
||||
The home-made mainloop handler use epoll() without any fallbacks, and
|
||||
will hang if one tries to epoll() an stdin that redirects from
|
||||
/dev/null.
|
||||
|
||||
Closes: https://github.com/bluez/bluez/issues/700
|
||||
---
|
||||
Makefile.tools | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Makefile.tools b/Makefile.tools
|
||||
index 589f7c94f9df..7c52e053ffee 100644
|
||||
--- a/Makefile.tools
|
||||
+++ b/Makefile.tools
|
||||
@@ -531,8 +531,8 @@ tools_obexctl_LDADD = gdbus/libgdbus-internal.la src/libshared-glib.la \
|
||||
|
||||
tools_btmgmt_SOURCES = tools/btmgmt.c src/uuid-helper.c client/display.c \
|
||||
client/mgmt.c
|
||||
-tools_btmgmt_LDADD = lib/libbluetooth-internal.la src/libshared-mainloop.la \
|
||||
- -lreadline
|
||||
+tools_btmgmt_LDADD = lib/libbluetooth-internal.la src/libshared-glib.la \
|
||||
+ $(GLIB_LIBS) -lreadline
|
||||
if DEPRECATED
|
||||
noinst_PROGRAMS += attrib/gatttool
|
||||
|
||||
--
|
||||
2.53.0
|
||||
|
||||
Reference in New Issue
Block a user