summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Kowalski <arturkow2000@gmail.com>2025-01-20 13:46:04 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-01-21 12:07:56 +0000
commitdb861568758e91e0634bd1e267157e00da842468 (patch)
treea16a1474c33bfab34e11d5c8fef68aa8bbfbaf35
parent284450ed971fc34085824b4c51f879d4f8cfac2d (diff)
downloadpoky-db861568758e91e0634bd1e267157e00da842468.tar.gz
systemd.bbclass: update postinst and prerm hooks
Since SYSTEMD_SERVICE_ESCAPED may contain both system and user services we need to filter out user services in call to systemctl. Introduce helper systemd_filter_services() which takes space-separated list of services and returns services of requested type. (From OE-Core rev: ec548b274d56b2c7a2663b70200df95a49e7452c) Signed-off-by: Artur Kowalski <arturkow2000@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-recipe/systemd.bbclass18
1 files changed, 12 insertions, 6 deletions
diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 592f15a4b7..0bce015509 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -37,17 +37,19 @@ if systemctl >/dev/null 2>/dev/null; then
37 fi 37 fi
38 38
39 if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then 39 if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
40 for service in ${SYSTEMD_SERVICE_ESCAPED}; 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 fi 43 fi
44 44
45 if [ -z "$D" ]; then 45 if [ -z "$D" ]; then
46 systemctl daemon-reload 46 systemctl daemon-reload
47 systemctl preset ${SYSTEMD_SERVICE_ESCAPED} 47 [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}" ] && \
48 systemctl preset ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
48 49
49 if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then 50 if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
50 systemctl --no-block restart ${SYSTEMD_SERVICE_ESCAPED} 51 [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}" ] && \
52 systemctl --no-block restart ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
51 fi 53 fi
52 fi 54 fi
53fi 55fi
@@ -56,9 +58,10 @@ fi
56systemd_prerm() { 58systemd_prerm() {
57if systemctl >/dev/null 2>/dev/null; then 59if systemctl >/dev/null 2>/dev/null; then
58 if [ -z "$D" ]; then 60 if [ -z "$D" ]; then
59 systemctl stop ${SYSTEMD_SERVICE_ESCAPED} 61 if [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}" ]; then
60 62 systemctl stop ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
61 systemctl disable ${SYSTEMD_SERVICE_ESCAPED} 63 systemctl disable ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
64 fi
62 fi 65 fi
63fi 66fi
64} 67}
@@ -108,6 +111,9 @@ def systemd_service_exists(service, user, d):
108 111
109 return path != '' 112 return path != ''
110 113
114def systemd_filter_services(services, user, d):
115 return ' '.join(service for service in services.split() if systemd_service_exists(service, user, d))
116
111python systemd_populate_packages() { 117python systemd_populate_packages() {
112 import re 118 import re
113 import shlex 119 import shlex