#986836 Bluez should notify users when they need to reboot to apply changes on Raspberry Pi

Package:
bluez
Source:
bluez
Description:
Bluetooth tools and daemons
Submitter:
William Wilson
Date:
2021-04-12 16:57:04 UTC
Severity:
normal
#986836#5
Date:
2021-04-12 16:51:53 UTC
From:
To:
In the case of upgrading or installing bluez for the first time on certain
raspberry pi devices, a reboot may be required to apply the changes. We
should add a check for this scenario in the postinst script.

I have included a patch that fixes this:

diff -Nru bluez-5.50/debian/bluez.postinst bluez-5.50/debian/bluez.postinst
--- bluez-5.50/debian/bluez.postinst    2020-03-22 04:55:38.000000000 -0500
+++ bluez-5.50/debian/bluez.postinst    2021-04-12 11:32:41.000000000 -0500
@@ -38,6 +38,23 @@
             addgroup --quiet --system bluetooth
         fi

+        # If running on a raspberry pi and no bluetooth device is found
+        # a reboot will be required
+        if [ -f /proc/device-tree/model ] && grep -q 'Raspberry Pi'
/proc/device-tree/model; then
+            if ! ( /usr/bin/hcitool dev | grep -q -E
'\s(B8:27:EB:|DC:A6:32:)' ); then
+                echo "A reboot is required to re-intialize bluetooth
devices." >&2
+                echo "Please reboot the system when convenient." >&2
+
+                # trigger an update notification that recommends a reboot
+                # (used by unattended-upgrades etc.)
+                touch /var/run/reboot-required || true
+
+                if ! grep -Fqsx bluez /run/reboot-required.pkgs; then
+                    echo bluez >> /run/reboot-required.pkgs || true
+                fi
+            fi
+        fi
+
         # reload dbus config file
         if [ -x /etc/init.d/dbus ]; then
             invoke-rc.d dbus force-reload || true