[oe] Fwd: Improving systemd.bbclass to support systemd user services

Pau Espin Pedrol pespin.shar at gmail.com
Mon Jun 1 15:18:55 UTC 2015


Hi everybody,

A few days ago I started playing with systemd user sessions[1] for a
distribution I'm setting up. I noticed that for system services
everything is setup correctly by using "inherit systemd", but there's
currently no much support for systemd user session services to be
installed easily.

As far as I understood and tested in my old (yocto-1.6) env, those
services files are supposed to be installed in /usr/lib/systemd/user/
instead of /lib/systemd/system/. Also, to enable or disable them with
systemctl one must explicitly declare so by using "--global"
parameter.

That means both FILES and postinst/prerm parts should be updated to
have that into account. After doing some tests, I arrived to the
conclusion that the best way to do that would be defining another env
var called SYSTEMD_USER_SERVICE used in recipes which does the same as
SYSTEMD_SERVICE, but meant to be used for user session systemd
services.

I did all the changes which should be needed and tested it with
pulseaudio, which is supposed to be used as a user session service. In
order to do that, I also needed to enable systemd support on the
recipe, which was not there.

I attach two patches implementing those changes, based on master-next.
Those patches are still not perfect though, and I need some advise on
that. It seems there's a problem currently with systemctl failing when
run with both "--root" and "--global" parameters at the same time. It
looks like usually the postinst script is run inside the OE env while
building, so the --root=$D is used, and so systemctl fails with
Invalid Argument. If I try to install the generated package once the
system is running, it works fine, because --root is not used.

I tried asking for help on #systemd IRC channel but I got no response so far.

I also opened a bug report in yocto related to this problem [2][3].

Any comments on this would be welcome.

By the way, if you try to run pulseaudio as user session you will
probably need also a session service to create a dbus session, as well
as some more black magic. If someone needs help on that please ask.
You may also want to check [1].

[1] https://wiki.archlinux.org/index.php/Systemd/User
[2] https://bugzilla.yoctoproject.org/show_bug.cgi?id=7800
[3] https://bugzilla.yoctoproject.org/show_bug.cgi?id=7801


Pau Espin Pedrol
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-systemd.bbclass-Add-code-to-enable-user-systemd-serv.patch
Type: text/x-patch
Size: 7862 bytes
Desc: not available
URL: <http://lists.openembedded.org/pipermail/openembedded-devel/attachments/20150601/a9d6d4dc/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-pulseaudio.inc-enable-systemd-support-if-set-in-DIST.patch
Type: text/x-patch
Size: 2010 bytes
Desc: not available
URL: <http://lists.openembedded.org/pipermail/openembedded-devel/attachments/20150601/a9d6d4dc/attachment-0005.bin>


More information about the Openembedded-devel mailing list