diff options
| author | Artur Kowalski <arturkow2000@gmail.com> | 2025-01-20 13:46:04 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-01-21 12:07:56 +0000 |
| commit | db861568758e91e0634bd1e267157e00da842468 (patch) | |
| tree | a16a1474c33bfab34e11d5c8fef68aa8bbfbaf35 | |
| parent | 284450ed971fc34085824b4c51f879d4f8cfac2d (diff) | |
| download | poky-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.bbclass | 18 |
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 |
| 53 | fi | 55 | fi |
| @@ -56,9 +58,10 @@ fi | |||
| 56 | systemd_prerm() { | 58 | systemd_prerm() { |
| 57 | if systemctl >/dev/null 2>/dev/null; then | 59 | if 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 |
| 63 | fi | 66 | fi |
| 64 | } | 67 | } |
| @@ -108,6 +111,9 @@ def systemd_service_exists(service, user, d): | |||
| 108 | 111 | ||
| 109 | return path != '' | 112 | return path != '' |
| 110 | 113 | ||
| 114 | def systemd_filter_services(services, user, d): | ||
| 115 | return ' '.join(service for service in services.split() if systemd_service_exists(service, user, d)) | ||
| 116 | |||
| 111 | python systemd_populate_packages() { | 117 | python systemd_populate_packages() { |
| 112 | import re | 118 | import re |
| 113 | import shlex | 119 | import shlex |
