Merge ~sylvain-pineau/checkbox-core-snap:add-udisk-services into checkbox-core-snap:master

Proposed by Sylvain Pineau
Status: Rejected
Rejected by: Sylvain Pineau
Proposed branch: ~sylvain-pineau/checkbox-core-snap:add-udisk-services
Merge into: checkbox-core-snap:master
Diff against target: 134 lines (+90/-0)
3 files modified
services/udiskie.sh (+25/-0)
services/udisksd.sh (+11/-0)
snap/snapcraft.yaml (+54/-0)
Reviewer Review Type Date Requested Status
Jonathan Cave (community) Needs Information
Review via email: mp+386839@code.launchpad.net

Description of the change

New udisks services for our checkbox core snaps

Why we need them?

- on UC and US, there's no udisks2 service and no file manager to mount removable storage
- w/o udisks2 it's almost impossible to test usb2 and usb3 separately at their expected speeds

Tested so far on classic desktop (amd64/focal), classic US (arm64/focal), core20 (amd64). all with good results.

On classic US, the checkbox core snap must be installed with --devmode since the udisks2 interface was not meant to be used on classic, support is not the same as on UC (e.g. missing permissions).
The checkbox-project-classic snap will have to install a polkit file along with the traditional sudoer rule to make it work (and restart the two checkbox services).

On classic desktop, with an already running udisks service, ours won't run and udiskie won't start. Both services will stay in a failed state, that's expected.

On core, checkbox core snaps are automatically installed via the content interface and the udisks2 interface should do its job. So no devmode required for those snaps. Similarly to the bluez/MM jobs requiring the invoking user to be root (and not via sudo) getting access to the Udisks2 system bus will only be possible from the checkbox slave (it runs as root). other option for local runs, start checkbox with sudo checkbox-snappy.checkbox-cli (but it's not something we'll promote).

I haven't tested yet older core releases. Ideally I'd prefer to land this MR, get series16/18 rebased and check edge jobs in our CI.

To post a comment you must log in.
Revision history for this message
Jonathan Cave (jocave) wrote :

"Both services will stay in a failed state, that's expected" - I don't like this result as it implies something is broken - could the service files / wrappers or something be modified so the result is not "failed"? We have tests that run in some circumstances to test explicitly that there are no failed services, we can't cause our own tests to fail.

I'm not sure how I feel about declaring the services on the checkbox-core-snap - so far this has only been a source of content shared in to the checkbox-<project> snap. It does not run anything and has no need to worry about other plugs etc and whether they are connected. So this is quite a change to the features of the snap.

Some thought is also needed about how the connection of the plugs actually happens. This could mean changing documentation, it could also raise the point about whether the plugs can be autoconnected.

review: Needs Information
Revision history for this message
Jonathan Cave (jocave) wrote :

The question occurs to me, why do we have to maintain these services in the checkbox snap at all? To some extent they are just making our testing snap more complicated. Could they just not go back in to a separate snap?

Basically what is happening is we are maintaining a udisk2 snap of our own, so why not just do that - maybe we could ask for it to be unlisted in the store if we don't want the burden of maintaining it for anyone but us to use. It could join "test-snapd-tools-*" as a snap we need available.

Unmerged commits

950d076... by Sylvain Pineau

Add udisksd and udiskie services

Udisksd is using the existing udisks2 interface.
Both udisks2 and udiskie are added as stage packages.

The shell wrappers ensure that:
1. There's no udidksd service already running
2. udiskie automount for removable storage is only started if our own udisksd
   service is up and running.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/services/udiskie.sh b/services/udiskie.sh
2new file mode 100755
3index 0000000..f1a1a58
4--- /dev/null
5+++ b/services/udiskie.sh
6@@ -0,0 +1,25 @@
7+#!/bin/bash
8+
9+if [ ! -f "$SNAP_COMMON/.automount_enabled" ]; then
10+ exit 1
11+fi
12+
13+case "$SNAP_ARCH" in
14+ "amd64") ARCH='x86_64-linux-gnu'
15+ ;;
16+ "i386") ARCH='i386-linux-gnu'
17+ ;;
18+ "arm64") ARCH='aarch64-linux-gnu'
19+ ;;
20+ "armhf") ARCH='arm-linux-gnueabihf'
21+ ;;
22+ *)
23+ echo "Unsupported architecture: $SNAP_ARCH"
24+ ;;
25+esac
26+
27+export GI_TYPELIB_PATH=$SNAP/usr/lib/girepository-1.0:$SNAP/usr/lib/$ARCH/girepository-1.0
28+export PATH="$PATH:$SNAP/usr/sbin:$SNAP/sbin:/snap/bin"
29+export PYTHONPATH="$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH"
30+
31+exec $SNAP/usr/bin/udiskie -N -T
32diff --git a/services/udisksd.sh b/services/udisksd.sh
33new file mode 100755
34index 0000000..16bcb83
35--- /dev/null
36+++ b/services/udisksd.sh
37@@ -0,0 +1,11 @@
38+#!/bin/bash
39+
40+if pgrep -x udisksd >/dev/null
41+then
42+ echo "ERROR: udisksd is already running"
43+ rm -f "$SNAP_COMMON/.automount_enabled"
44+ exit 1
45+fi
46+
47+touch "$SNAP_COMMON/.automount_enabled"
48+exec $SNAP/usr/lib/udisks2/udisksd
49diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
50index 8a04a6d..c4bbf6e 100644
51--- a/snap/snapcraft.yaml
52+++ b/snap/snapcraft.yaml
53@@ -6,6 +6,38 @@ grade: stable
54
55 base: core20
56
57+apps:
58+ udisksd:
59+ command: bin/udisksd.sh
60+ daemon: simple
61+ slots:
62+ - service
63+ - dbus-udisks2
64+ plugs:
65+ - hardware-observe
66+ - mount-observe
67+ udiskie:
68+ command: bin/udiskie.sh
69+ daemon: simple
70+ after: [ udisksd ]
71+ plugs:
72+ - client
73+ - dbus-udisks2-client
74+
75+layout:
76+ /var/lib/udisks2:
77+ bind: $SNAP_DATA/var/lib/udisks2
78+ /etc/udisks2/udisks2.conf:
79+ bind-file: $SNAP/etc/udisks2/udisks2.conf
80+ /etc/libblockdev/conf.d:
81+ bind: $SNAP/etc/libblockdev/conf.d
82+ /usr/share/dbus-1/system.d/org.freedesktop.UDisks2.conf:
83+ bind-file: $SNAP/usr/share/dbus-1/system.d/org.freedesktop.UDisks2.conf
84+ /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy:
85+ bind-file: $SNAP/usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy
86+ /usr/share/dbus-1/system-services/org.freedesktop.UDisks2.service:
87+ bind-file: $SNAP/usr/share/dbus-1/system-services/org.freedesktop.UDisks2.service
88+
89 # Don't forget to add a new slot if a new provider part is added in the parts
90 # section below.
91 slots:
92@@ -49,6 +81,20 @@ slots:
93 interface: content
94 read:
95 - /
96+ service:
97+ interface: udisks2
98+ dbus-udisks2:
99+ interface: dbus
100+ bus: system
101+ name: org.freedesktop.UDisks2
102+
103+plugs:
104+ client:
105+ interface: udisks2
106+ dbus-udisks2-client:
107+ bus: system
108+ interface: dbus
109+ name: org.freedesktop.UDisks2
110
111 parts:
112 ################################################################################
113@@ -276,6 +322,8 @@ parts:
114 - qml-module-qtquick-layouts
115 - qmlscene
116 - smartmontools
117+ - udiskie
118+ - udisks2
119 - usbutils
120 - util-linux
121 - uuid-runtime
122@@ -476,6 +524,12 @@ parts:
123 gcc lk-boot-env.c -I/usr/include/ -Iapp/aboot -o ${SNAPCRAFT_PART_INSTALL}/bin/lk-boot-env
124 fi
125 ################################################################################
126+ services:
127+ source: services/
128+ plugin: dump
129+ organize:
130+ '*': bin/
131+################################################################################
132 parts-meta-info:
133 plugin: nil
134 override-build: |

Subscribers

People subscribed via source and target branches