All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] systemd.bbclass: fix postinst for real systemd-systemctl-native
@ 2025-05-28  3:56 Patrick Williams
  2025-05-28  9:07 ` [OE-core] " Alexander Kanavin
  2025-05-28 12:33 ` Mathieu Dubois-Briand
  0 siblings, 2 replies; 6+ messages in thread
From: Patrick Williams @ 2025-05-28  3:56 UTC (permalink / raw)
  To: openembedded-core; +Cc: Patrick Williams

The commit 7a580800db39 switched from a small Python implementation
of `systemctl` to using the real systemctl executable from the
systemd package.  In the systemd.bbclass, systemd-systemctl-native
is used to default-enable services, based on the SYSTEMD_SERVICES
variable, but this was only done if `systemctl` can be executed
without error.  The problem is that the real systemctl executable
treats a zero argument call as if `systemctl list-units` were ran.
This cannot be done when cross-compiling and yields:

```
    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)
```

The end result is that the `systemd_postinst` effectively turns into
a silent no-op and services are not correctly enabled.

Switch the systemd.bbclass to use `systemctl --help` instead, which
does not require any dbus access to be functional.

Fixes: 7a580800db39 ("systemd: Build the systemctl executable")
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
---
 meta/classes-recipe/systemd.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 4c9f51d33d..e1fe4ed072 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -29,7 +29,7 @@ python __anonymous() {
 }
 
 systemd_postinst() {
-if systemctl >/dev/null 2>/dev/null; then
+if systemctl --help >/dev/null 2>/dev/null; then
 	OPTS=""
 
 	if [ -n "$D" ]; then
@@ -66,7 +66,7 @@ fi
 }
 
 systemd_prerm() {
-if systemctl >/dev/null 2>/dev/null; then
+if systemctl --help >/dev/null 2>/dev/null; then
 	if [ -z "$D" ]; then
 		if [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}" ]; then
 			systemctl stop ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-05-30 13:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-28  3:56 [PATCH] systemd.bbclass: fix postinst for real systemd-systemctl-native Patrick Williams
2025-05-28  9:07 ` [OE-core] " Alexander Kanavin
2025-05-28 19:47   ` Patrick Williams
2025-05-30 11:19     ` Alexander Kanavin
2025-05-30 13:04       ` Patrick Williams
2025-05-28 12:33 ` Mathieu Dubois-Briand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.