Handle user units in a manner similar to system units where possible.
Not everything is supported by systemd, but systemd limitations only
affect runtime package management - during update user services are not
reloaded/restart and each user must re-login or manually restart
services.

Signed-off-by: Artur Kowalski <arturkow2...@gmail.com>
---
 meta/classes-recipe/systemd.bbclass | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/meta/classes-recipe/systemd.bbclass 
b/meta/classes-recipe/systemd.bbclass
index 177ee5d974..4c9f51d33d 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -40,14 +40,24 @@ if systemctl >/dev/null 2>/dev/null; then
                for service in 
${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}; do
                        systemctl ${OPTS} enable "$service"
                done
+
+               for service in 
${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}; do
+                       systemctl --global ${OPTS} enable "$service"
+               done
        fi
 
        if [ -z "$D" ]; then
+               # Reload only system service manager
+               # --global for daemon-reload is not supported: 
https://github.com/systemd/systemd/issues/19284
                systemctl daemon-reload
                [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", 
False, d)}" ] && \
                        systemctl preset 
${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
 
+               [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", 
True, d)}" ] && \
+                       systemctl --global preset 
${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}
+
                if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
+                       # --global flag for restart is not supported by systemd 
(see above)
                        [ -n 
"${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}" ] && \
                                systemctl --no-block restart 
${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
                fi
@@ -62,6 +72,10 @@ if systemctl >/dev/null 2>/dev/null; then
                        systemctl stop 
${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
                        systemctl disable 
${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
                fi
+
+               # same as above, --global flag is not supported for stop so do 
disable only
+               [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", 
True, d)}" ] && \
+                       systemctl --global disable 
${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}
        fi
 fi
 }
@@ -111,6 +125,9 @@ def systemd_service_exists(service, user, d):
 
     return path != ''
 
+def systemd_filter_services(services, user, d):
+    return ' '.join(service for service in services.split() if 
systemd_service_exists(service, user, d))
+
 python systemd_populate_packages() {
     import re
     import shlex
-- 
2.47.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#209799): 
https://lists.openembedded.org/g/openembedded-core/message/209799
Mute This Topic: https://lists.openembedded.org/mt/110606435/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to