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
diff --git a/bin/bluetoothd-wrapper b/bin/bluetoothd-wrapper
0new file mode 1007550new file mode 100755
index 0000000..0d02e17
--- /dev/null
+++ b/bin/bluetoothd-wrapper
@@ -0,0 +1,22 @@
1#!/bin/sh -e
2#
3# Copyright (C) 2021 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17DEBUG=
18if [ -f "$SNAP_DATA"/.debug_enabled ]; then
19 DEBUG="-d"
20fi
21
22exec "$SNAP"/usr/lib/bluetooth/bluetoothd -E $DEBUG
diff --git a/snap/hooks/configure b/snap/hooks/configure
0new file mode 10075523new file mode 100755
index 0000000..a2a4359
--- /dev/null
+++ b/snap/hooks/configure
@@ -0,0 +1,32 @@
1#!/bin/sh -e
2#
3# Copyright (C) 2021 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17# $1 true/false for enabling/disabling debug log level
18switch_debug_enable() {
19 DEBUG_FILE=$SNAP_DATA/.debug_enabled
20 if [ "$1" = "true" ]; then
21 touch "$DEBUG_FILE"
22 else
23 rm -f "$DEBUG_FILE"
24 fi
25}
26
27value=$(snapctl get debug.enable)
28if [ -z "$value" ]; then
29 value="false"
30 snapctl set debug.enable="$value"
31fi
32switch_debug_enable "$value"
diff --git a/snapcraft.yaml b/snapcraft.yaml
index 85a4d30..9c2e4d2 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -26,7 +26,7 @@ apps:
26 command: bin/client-wrapper usr/bin/obexctl26 command: bin/client-wrapper usr/bin/obexctl
27 plugs: [client]27 plugs: [client]
28 bluez:28 bluez:
29 command: "usr/lib/bluetooth/bluetoothd -E"29 command: bin/bluetoothd-wrapper
30 daemon: simple30 daemon: simple
31 slots: [service]31 slots: [service]
32 plugs: [uhid, uinput, kernel-crypto-api]32 plugs: [uhid, uinput, kernel-crypto-api]
@@ -77,6 +77,7 @@ parts:
77 source: bin/77 source: bin/
78 organize:78 organize:
79 client-wrapper: bin/client-wrapper79 client-wrapper: bin/client-wrapper
80 bluetoothd-wrapper: bin/bluetoothd-wrapper
8081
81 changelog:82 changelog:
82 plugin: nil83 plugin: nil
diff --git a/tests/main/debug-log/task.yaml b/tests/main/debug-log/task.yaml
83new file mode 10064484new file mode 100644
index 0000000..9465408
--- /dev/null
+++ b/tests/main/debug-log/task.yaml
@@ -0,0 +1,20 @@
1summary: Verify that the debug traces can be enabled/disabled
2
3execute: |
4 . $TESTSLIB/utilities.sh
5
6 state=$(snap get bluez debug.enable)
7 test "$state" = false
8 pgrep --full "bluetoothd -E$"
9
10 snap set bluez debug.enable=true
11 state=$(snap get bluez debug.enable)
12 test "$state" = true
13 snap restart bluez
14 pgrep --full "bluetoothd -E -d$"
15
16 snap set bluez debug.enable=false
17 state=$(snap get bluez debug.enable)
18 test "$state" = false
19 snap restart bluez
20 pgrep --full "bluetoothd -E$"

Subscribers

People subscribed via source and target branches