summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kjellerstedt <pkj@axis.com>2025-09-08 18:05:04 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-09-11 11:31:57 +0100
commit46455d3025592aa0254844348d3b0ad4301d2e2a (patch)
tree895501c1b47186491db533fa17aaaf45e26c3eb4
parent7bd05107409c926155f9b582075644b55ce2db8e (diff)
downloadpoky-46455d3025592aa0254844348d3b0ad4301d2e2a.tar.gz
systemd.bbclass: Make systemd_postinst run as intended
After the switch from using a systemctl written in Python to using the official version of systemctl from the systemd project, the systemd_postinst function has effectively not been executed during the rootfs creation. The reason is that systemctl provided by systemctl-native fails if run without arguments (as systemd_postinst does): Failed to connect to system scope bus via local transport: Operation not permitted (consider using --machine=<user>@.host --user to connect to bus of other user) This is not seen in the logs since stderr is sent to /dev/null, and the only way to tell that there is a problem is because systemd services that are expected to be enabled aren't running. The reason this has gone unnoticed is because systemd_handle_machine_id in rootfs-postcommands.bbclass will call systemctl preset-all, which in most cases will create the missing links to enable the systemd services. This change effectively reverts commit a52e66762c0c51918b1ba3d4622759637b6e920a (systemd.bbclass: update command to check systemctl available) and instead only runs systemctl without arguments (to determine that it can communicate with systemd) when executed on target. (From OE-Core rev: 5b86efb5c9ca782fd0f8ff306f82583ec1e5e909) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-recipe/systemd.bbclass8
1 files changed, 4 insertions, 4 deletions
diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 0e9f7cfa33..4e687135f1 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -29,7 +29,7 @@ python __anonymous() {
29} 29}
30 30
31systemd_postinst() { 31systemd_postinst() {
32if systemctl >/dev/null 2>/dev/null; then 32if type systemctl >/dev/null 2>/dev/null; then
33 OPTS="" 33 OPTS=""
34 34
35 if [ -n "$D" ]; then 35 if [ -n "$D" ]; then
@@ -46,7 +46,7 @@ if systemctl >/dev/null 2>/dev/null; then
46 done 46 done
47 fi 47 fi
48 48
49 if [ -z "$D" ]; then 49 if [ -z "$D" ] && systemctl >/dev/null 2>/dev/null; then
50 # Reload only system service manager 50 # Reload only system service manager
51 # --global for daemon-reload is not supported: https://github.com/systemd/systemd/issues/19284 51 # --global for daemon-reload is not supported: https://github.com/systemd/systemd/issues/19284
52 systemctl daemon-reload 52 systemctl daemon-reload
@@ -66,8 +66,8 @@ fi
66} 66}
67 67
68systemd_prerm() { 68systemd_prerm() {
69if systemctl >/dev/null 2>/dev/null; then 69if type systemctl >/dev/null 2>/dev/null; then
70 if [ -z "$D" ]; then 70 if [ -z "$D" ] && systemctl >/dev/null 2>/dev/null; then
71 if [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}" ]; then 71 if [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}" ]; then
72 systemctl stop ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)} 72 systemctl stop ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
73 systemctl disable ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)} 73 systemctl disable ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}