Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/bluez:add-debug-option into ~snappy-hwe-team/snappy-hwe-snaps/+git/bluez:snap-20

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: d7c0d484b481d72d7cc714e55b84ffa29d23c0b7
Merged at revision: ba9f48696463f66f9dff6c4c12dcc820a361126e
Proposed branch: ~alfonsosanchezbeato/snappy-hwe-snaps/+git/bluez:add-debug-option
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/bluez:snap-20
Diff against target: 113 lines (+76/-1)
4 files modified
bin/bluetoothd-wrapper (+22/-0)
snap/hooks/configure (+32/-0)
snapcraft.yaml (+2/-1)
tests/main/debug-log/task.yaml (+20/-0)
Reviewer Review Type Date Requested Status
Philip Meulengracht Approve
System Enablement Bot continuous-integration Approve
Review via email: mp+413625@code.launchpad.net

Commit message

Add wrapper script for bluetoothd

Add wrapper script for bluetoothd so we can enable debug traces if the
debug.enable snap option is set.

Description of the change

Add wrapper script for bluetoothd

Add wrapper script for bluetoothd so we can enable debug traces if the
debug.enable snap option is set.

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: d7c0d484b481d72d7cc714e55b84ffa29d23c0b7

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/1447/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Philip Meulengracht (the-meulengracht) wrote :

Looks fine to me, approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/bluetoothd-wrapper b/bin/bluetoothd-wrapper
2new file mode 100755
3index 0000000..0d02e17
4--- /dev/null
5+++ b/bin/bluetoothd-wrapper
6@@ -0,0 +1,22 @@
7+#!/bin/sh -e
8+#
9+# Copyright (C) 2021 Canonical Ltd
10+#
11+# This program is free software: you can redistribute it and/or modify
12+# it under the terms of the GNU General Public License version 3 as
13+# published by the Free Software Foundation.
14+#
15+# This program is distributed in the hope that it will be useful,
16+# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+# GNU General Public License for more details.
19+#
20+# You should have received a copy of the GNU General Public License
21+# along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
23+DEBUG=
24+if [ -f "$SNAP_DATA"/.debug_enabled ]; then
25+ DEBUG="-d"
26+fi
27+
28+exec "$SNAP"/usr/lib/bluetooth/bluetoothd -E $DEBUG
29diff --git a/snap/hooks/configure b/snap/hooks/configure
30new file mode 100755
31index 0000000..a2a4359
32--- /dev/null
33+++ b/snap/hooks/configure
34@@ -0,0 +1,32 @@
35+#!/bin/sh -e
36+#
37+# Copyright (C) 2021 Canonical Ltd
38+#
39+# This program is free software: you can redistribute it and/or modify
40+# it under the terms of the GNU General Public License version 3 as
41+# published by the Free Software Foundation.
42+#
43+# This program is distributed in the hope that it will be useful,
44+# but WITHOUT ANY WARRANTY; without even the implied warranty of
45+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46+# GNU General Public License for more details.
47+#
48+# You should have received a copy of the GNU General Public License
49+# along with this program. If not, see <http://www.gnu.org/licenses/>.
50+
51+# $1 true/false for enabling/disabling debug log level
52+switch_debug_enable() {
53+ DEBUG_FILE=$SNAP_DATA/.debug_enabled
54+ if [ "$1" = "true" ]; then
55+ touch "$DEBUG_FILE"
56+ else
57+ rm -f "$DEBUG_FILE"
58+ fi
59+}
60+
61+value=$(snapctl get debug.enable)
62+if [ -z "$value" ]; then
63+ value="false"
64+ snapctl set debug.enable="$value"
65+fi
66+switch_debug_enable "$value"
67diff --git a/snapcraft.yaml b/snapcraft.yaml
68index 85a4d30..9c2e4d2 100644
69--- a/snapcraft.yaml
70+++ b/snapcraft.yaml
71@@ -26,7 +26,7 @@ apps:
72 command: bin/client-wrapper usr/bin/obexctl
73 plugs: [client]
74 bluez:
75- command: "usr/lib/bluetooth/bluetoothd -E"
76+ command: bin/bluetoothd-wrapper
77 daemon: simple
78 slots: [service]
79 plugs: [uhid, uinput, kernel-crypto-api]
80@@ -77,6 +77,7 @@ parts:
81 source: bin/
82 organize:
83 client-wrapper: bin/client-wrapper
84+ bluetoothd-wrapper: bin/bluetoothd-wrapper
85
86 changelog:
87 plugin: nil
88diff --git a/tests/main/debug-log/task.yaml b/tests/main/debug-log/task.yaml
89new file mode 100644
90index 0000000..9465408
91--- /dev/null
92+++ b/tests/main/debug-log/task.yaml
93@@ -0,0 +1,20 @@
94+summary: Verify that the debug traces can be enabled/disabled
95+
96+execute: |
97+ . $TESTSLIB/utilities.sh
98+
99+ state=$(snap get bluez debug.enable)
100+ test "$state" = false
101+ pgrep --full "bluetoothd -E$"
102+
103+ snap set bluez debug.enable=true
104+ state=$(snap get bluez debug.enable)
105+ test "$state" = true
106+ snap restart bluez
107+ pgrep --full "bluetoothd -E -d$"
108+
109+ snap set bluez debug.enable=false
110+ state=$(snap get bluez debug.enable)
111+ test "$state" = false
112+ snap restart bluez
113+ pgrep --full "bluetoothd -E$"

Subscribers

People subscribed via source and target branches