summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorArtur Kowalski <arturkow2000@gmail.com>2025-01-20 13:46:05 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-01-21 12:07:56 +0000
commit2ff2277ba3e08f4d486f20e3565c9c43d1e239a1 (patch)
treeff2eb01cd5877f5511ede95690e48031cc2de60b /meta
parentdb861568758e91e0634bd1e267157e00da842468 (diff)
downloadpoky-2ff2277ba3e08f4d486f20e3565c9c43d1e239a1.tar.gz
systemd.bbclass: support user units in postinst and prerm hooks
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. (From OE-Core rev: ce62b88d8f71368e356b6409ada46a34a6017ddf) Signed-off-by: Artur Kowalski <arturkow2000@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes-recipe/systemd.bbclass14
1 files changed, 14 insertions, 0 deletions
diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 0bce015509..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
40 for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}; do 40 for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}; do
41 systemctl ${OPTS} enable "$service" 41 systemctl ${OPTS} enable "$service"
42 done 42 done
43
44 for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}; do
45 systemctl --global ${OPTS} enable "$service"
46 done
43 fi 47 fi
44 48
45 if [ -z "$D" ]; then 49 if [ -z "$D" ]; then
50 # Reload only system service manager
51 # --global for daemon-reload is not supported: https://github.com/systemd/systemd/issues/19284
46 systemctl daemon-reload 52 systemctl daemon-reload
47 [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}" ] && \ 53 [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}" ] && \
48 systemctl preset ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)} 54 systemctl preset ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
49 55
56 [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}" ] && \
57 systemctl --global preset ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}
58
50 if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then 59 if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
60 # --global flag for restart is not supported by systemd (see above)
51 [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}" ] && \ 61 [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}" ] && \
52 systemctl --no-block restart ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)} 62 systemctl --no-block restart ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
53 fi 63 fi
@@ -62,6 +72,10 @@ if systemctl >/dev/null 2>/dev/null; then
62 systemctl stop ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)} 72 systemctl stop ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
63 systemctl disable ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)} 73 systemctl disable ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
64 fi 74 fi
75
76 # same as above, --global flag is not supported for stop so do disable only
77 [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}" ] && \
78 systemctl --global disable ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}
65 fi 79 fi
66fi 80fi
67} 81}