systemd-systemctl-native: Install systemd-sysv-install
PATCH v5 1/2 systemd-systemctl-native: Install systemd-sysv-install
It is needed when support for both systemd and sysvinit are enabled.
This also adds a patch for systemctl to allow the path to systemd-sysv-install to be specified in runtime. This is needed because the hardcoded path that is built into systemctl does not match the path to where it will eventually be executed.
---
PATCHv2: New.
PATCHv3: Change the Upstream-Status to Denied.
PATCHv4: Add a Signed-off-by to the new patch.
PATCHv5: Always install systemd-sysv-install.
.../systemd/systemd-systemctl-native_257.8.bb | 14 ++ ...sv-install-to-specify-path-to-system.patch | 145 ++++++++++++++++++ ...implment-systemd-sysv-install-for-OE.patch | 13 +- 3 files changed, 164 insertions(+), 8 deletions(-) create mode 100644 meta/recipes-core/systemd/systemd/0001-systemctl-Add-sysv-install-to-specify-path-to-system.patch
meta/recipes-core/systemd/systemd-systemctl-native_257.8.bb +14 -0
@@ -1,9 +1,14 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/systemd:" + SUMMARY = "Systemctl executable from systemd" require systemd.inc DEPENDS = "gperf-native libcap-native util-linux-native python3-jinja2-native" +SRC_URI += "file://0001-systemctl-Add-sysv-install-to-specify-path-to-system.patch" +SRC_URI += "file://0002-implment-systemd-sysv-install-for-OE.patch" + inherit pkgconfig meson native MESON_TARGET = "systemctl:executable"
@@ -14,3 +19,12 @@ EXTRA_OEMESON += "-Dlink-systemctl-shared=false" # determined at run-time, but rather set during configure # More details are here https://github.com/systemd/systemd/issues/35897#issuecomment-2665405887 EXTRA_OEMESON += "--sysconfdir ${sysconfdir_native}" + +do_install:append() { + # Use ${libdir}/systemd rather than ${systemd_unitdir} here + # because the latter is affected by whether the usrmerge distro + # feature is set _for native_ (which it typically isn't), and we + # need to know the path to systemd-sysv-install in the + # systemd.bbclass when building _for target_. + install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON ${D}${libdir}/systemd/systemd-sysv-install +}
meta/recipes-core/systemd/systemd/0001-systemctl-Add-sysv-install-to-specify-path-to-system.patch new file +145 -0
145 lines not on this page · raw message
meta/recipes-core/systemd/systemd/0002-implment-systemd-sysv-install-for-OE.patch +5 -8
@@ -1,7 +1,7 @@ -From fab8c573d06340868f070446118673b1c23584c5 Mon Sep 17 00:00:00 2001 +From b9fb0368fa54655eccb086b4152f3a2824d2ad53 Mon Sep 17 00:00:00 2001 From: Khem Raj <[email protected]> Date: Sat, 5 Sep 2015 06:31:47 +0000 -Subject: [PATCH 02/26] implment systemd-sysv-install for OE +Subject: [PATCH] implement systemd-sysv-install for OE Use update-rc.d for enabling/disabling and status command to check the status of the sysv service
@@ -14,7 +14,7 @@ Signed-off-by: Khem Raj <[email protected]> 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/systemctl/systemd-sysv-install.SKELETON b/src/systemctl/systemd-sysv-install.SKELETON -index cb58d8243b..000bdf6165 100755 +index cb58d8243b..eff3f5f579 100755 --- a/src/systemctl/systemd-sysv-install.SKELETON +++ b/src/systemctl/systemd-sysv-install.SKELETON @@ -34,17 +34,17 @@ case "$1" in
@@ -22,13 +22,13 @@ index cb58d8243b..000bdf6165 100755 # call the command to enable SysV init script $NAME here # (consider optional $ROOT) - echo "IMPLEMENT ME: enabling SysV init.d script $NAME" -+ update-rc.d -f $NAME defaults ++ update-rc.d ${ROOT:+-r $ROOT} -f $NAME defaults ;; disable) # call the command to disable SysV init script $NAME here # (consider optional $ROOT) - echo "IMPLEMENT ME: disabling SysV init.d script $NAME" -+ update-rc.d -f $NAME remove ++ update-rc.d ${ROOT:+-r $ROOT} -f $NAME remove ;; is-enabled) # exit with 0 if $NAME is enabled, non-zero if it is disabled
@@ -38,6 +38,3 @@ index cb58d8243b..000bdf6165 100755 ;; *) usage ;; --- -2.34.1 -
PATCH v5 2/2 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 argument (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.
---
PATCHv2: Add --sysv-install= to $OPTS to instruct systemctl where to
look for systemd-sysv-install.
PATCHv3: No changes.
PATCHv4: No changes.
PATCHv5: No changes.
meta/classes-recipe/systemd.bbclass | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
meta/classes-recipe/systemd.bbclass +10 -5
@@ -29,11 +29,16 @@ python __anonymous() { } systemd_postinst() { -if systemctl >/dev/null 2>/dev/null; then +if type systemctl >/dev/null 2>/dev/null; then OPTS="" if [ -n "$D" ]; then - OPTS="--root=$D" + # Use ${STAGING_LIBDIR_NATIVE}/systemd rather than + # ${STAGING_DIR_NATIVE}${systemd_unitdir} because the latter is + # affected by whether the usrmerge distro feature is set _for + # target_, and we need to know the path to systemd-sysv-install + # where it was installed _for native_. + OPTS="--root=$D --sysv-install=${STAGING_LIBDIR_NATIVE}/systemd/systemd-sysv-install" fi if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
@@ -46,7 +51,7 @@ if systemctl >/dev/null 2>/dev/null; then done fi - if [ -z "$D" ]; then + if [ -z "$D" ] && systemctl >/dev/null 2>/dev/null; then # Reload only system service manager # --global for daemon-reload is not supported: https://github.com/systemd/systemd/issues/19284 systemctl daemon-reload
@@ -66,8 +71,8 @@ fi } systemd_prerm() { -if systemctl >/dev/null 2>/dev/null; then - if [ -z "$D" ]; then +if type systemctl >/dev/null 2>/dev/null; then + if [ -z "$D" ] && systemctl >/dev/null 2>/dev/null; then if [ -n "${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}" ]; then systemctl stop ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)} systemctl disable ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}
Quoted 9 lines · Peter Kjellerstedt via lists.openembedded.org
It is needed when support for both systemd and sysvinit are enabled.
This also adds a patch for systemctl to allow the path to systemd-sysv-install to be specified in runtime. This is needed because the hardcoded path that is built into systemctl does not match the path to where it will eventually be executed.
Signed-off-by Peter Kjellerstedt <[email protected]>---
Hi Peter,
Sorry, but...
WARNING: core-image-full-cmdline-1.0-r0 do_rootfs: iptables.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0 do_rootfs: openssh-sshd.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0 do_rootfs: sysklogd.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0 do_rootfs: ostinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0 do_rootfs: at.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0 do_rootfs: cronie.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0 do_rootfs: logrotate.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0 do_rootfs: nfs-utils-client.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0 do_rootfs: nfs-utils.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0 do_rootfs: run-postinsts.postinst returned 1, marking as unpacked only, configuration required on target.
ERROR: core-image-full-cmdline-1.0-r0 do_rootfs: Postinstall scriptlets of ['iptables', 'openssh-sshd', 'sysklogd', 'ostinst returned 1, marking as unpacked only, configuration required on target', 'at', 'cronie', 'logrotate', 'nfs-utils-client', 'nfs-utils', 'run-postinsts'] have failed. If the intention is to defer them to first boot, then please place them into pkg_postinst_ontarget:${PN} ().
Deferring to first boot via 'exit 1' is no longer supported.
https://autobuilder.yoctoproject.org/valkyrie/#/builders/65/builds/2253
And lot of other builds in
https://autobuilder.yoctoproject.org/valkyrie/#/builders/29/builds/2246
Best regards,
Mathieu
Signature · 3 lines
Mathieu Dubois-Briand, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Quoted 35 lines
-----Original Message-----
From: Mathieu Dubois-Briand <[email protected]>
Sent: den 21 augusti 2025 08:38
To: Peter Kjellerstedt <[email protected]>; [email protected]
Subject: Re: [OE-core] [PATCHv5 1/2] systemd-systemctl-native: Install systemd-sysv-installQuoted 9 lines · Peter Kjellerstedt via lists.openembedded.org
It is needed when support for both systemd and sysvinit are enabled.
This also adds a patch for systemctl to allow the path to systemd-sysv-install to be specified in runtime. This is needed because the hardcoded path that is built into systemctl does not match the path to where it will eventually be executed.
Signed-off-by Peter Kjellerstedt <[email protected]>---
Hi Peter,
Sorry, but...
WARNING: core-image-full-cmdline-1.0-r0
do_rootfs: iptables.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: openssh-sshd.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: sysklogd.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: ostinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: at.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: cronie.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: logrotate.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: nfs-utils-client.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: nfs-utils.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: run-postinsts.postinst returned 1, marking as unpacked only, configuration required on target.
ERROR: core-image-full-cmdline-1.0-r0do_rootfs: Postinstall scriptlets of ['iptables', 'openssh-sshd', 'sysklogd', 'ostinst returned 1, marking as unpacked only, configuration required on target', 'at', 'cronie', 'logrotate', 'nfs-utils-client', 'nfs-utils', 'run-postinsts'] have failed. If the intention is to defer them to first boot, then please place them into pkg_postinst_ontarget:${PN} ().
Deferring to first boot via 'exit 1' is no longer supported.
Quoted 7 lines
https://autobuilder.yoctoproject.org/valkyrie/#/builders/65/builds/2253
And lot of other builds in
https://autobuilder.yoctoproject.org/valkyrie/#/builders/29/builds/2246Best regards,
Mathieu
I have failed to reproduce this. I fetched 15c8343c10751f16248ac1b5b5d1cad34b4e4917 that is used in the above builds, and used this configuration in my local.conf (to try to mimic the configuration used by the autobuilder):
DISTRO ?= "poky-altcfg"
EXTRA_IMAGE_FEATURES ?= "allow-empty-password empty-root-password allow-root-login"
USER_CLASSES ?= "buildstats"
MACHINE ?= "genericx86"
INHERIT += "image-buildinfo" IMAGE_BUILDINFO_VARS:append = " IMAGE_BASENAME IMAGE_NAME"
PACKAGE_CLASSES = "package_ipk package_rpm package_deb"
IMAGE_ROOTFS_EXTRA_SPACE:append = "${@bb.utils.contains('IMAGE_FEATURES', 'package-management', ' + 262144', '', d)}"
BB_HASHSERVE = "wss://hashserv-eu.yoctoproject.org/ws"
Do you have the log.do_rootfs from the failed build? Maybe it can shed some light on what went wrong...
//Peter
Quoted 60 lines · Peter Kjellerstedt via lists.openembedded.org
Quoted 35 lines
-----Original Message-----
From: Mathieu Dubois-Briand <[email protected]>
Sent: den 21 augusti 2025 08:38
To: Peter Kjellerstedt <[email protected]>; [email protected]
Subject: Re: [OE-core] [PATCHv5 1/2] systemd-systemctl-native: Install systemd-sysv-installQuoted 9 lines · Peter Kjellerstedt via lists.openembedded.org
It is needed when support for both systemd and sysvinit are enabled.
This also adds a patch for systemctl to allow the path to systemd-sysv-install to be specified in runtime. This is needed because the hardcoded path that is built into systemctl does not match the path to where it will eventually be executed.
Signed-off-by Peter Kjellerstedt <[email protected]>---
Hi Peter,
Sorry, but...
WARNING: core-image-full-cmdline-1.0-r0
do_rootfs: iptables.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: openssh-sshd.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: sysklogd.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: ostinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: at.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: cronie.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: logrotate.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: nfs-utils-client.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: nfs-utils.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: run-postinsts.postinst returned 1, marking as unpacked only, configuration required on target.
ERROR: core-image-full-cmdline-1.0-r0do_rootfs: Postinstall scriptlets of ['iptables', 'openssh-sshd', 'sysklogd', 'ostinst returned 1, marking as unpacked only, configuration required on target', 'at', 'cronie', 'logrotate', 'nfs-utils-client', 'nfs-utils', 'run-postinsts'] have failed. If the intention is to defer them to first boot, then please place them into pkg_postinst_ontarget:${PN} ().
Deferring to first boot via 'exit 1' is no longer supported.Quoted 7 lines
https://autobuilder.yoctoproject.org/valkyrie/#/builders/65/builds/2253
And lot of other builds in
https://autobuilder.yoctoproject.org/valkyrie/#/builders/29/builds/2246Best regards,
MathieuI have failed to reproduce this. I fetched
15c8343c10751f16248ac1b5b5d1cad34b4e4917that is used in the above builds, and used this configuration in my local.conf (to try to mimic the configuration used by the autobuilder):DISTRO ?= "poky-altcfg"
EXTRA_IMAGE_FEATURES?= "allow-empty-password empty-root-password allow-root-login"
USER_CLASSES?= "buildstats"MACHINE ?= "genericx86"
INHERIT += "image-buildinfo" IMAGE_BUILDINFO_VARS:append = "
IMAGE_BASENAMEIMAGE_NAME"
PACKAGE_CLASSES= "package_ipkpackage_rpmpackage_deb"
Quoted 8 lines
IMAGE_ROOTFS_EXTRA_SPACE:append = "${@bb.utils.contains('IMAGE_FEATURES', 'package-management', ' + 262144', '', d)}"
BB_HASHSERVE= "wss://hashserv-eu.yoctoproject.org/ws"Do you have the log.do_rootfs from the failed build? Maybe it can shed some light on what went wrong...
//Peter
I have to confess I'm having a hard time trying to reproduce this locally. I will try again in the coming days.
I've saved data of the following build and I'm attaching the log.do_rootfs.
https://autobuilder.yoctoproject.org/valkyrie/#/builders/93/builds/2263
Best regards,
Mathieu
Signature · 3 lines
Mathieu Dubois-Briand, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Quoted 80 lines
-----Original Message-----
From: Mathieu Dubois-Briand <[email protected]>
Sent: den 21 augusti 2025 21:19
To: Peter Kjellerstedt <[email protected]>
Cc: [email protected]
Subject: Re: [OE-core] [PATCHv5 1/2] systemd-systemctl-native: Install systemd-sysv-installQuoted 60 lines · Peter Kjellerstedt via lists.openembedded.org
Quoted 35 lines
-----Original Message-----
From: Mathieu Dubois-Briand <[email protected]>
Sent: den 21 augusti 2025 08:38
To: Peter Kjellerstedt <[email protected]>; [email protected]
Subject: Re: [OE-core] [PATCHv5 1/2] systemd-systemctl-native: Install systemd-sysv-installQuoted 9 lines · Peter Kjellerstedt via lists.openembedded.org
It is needed when support for both systemd and sysvinit are enabled.
This also adds a patch for systemctl to allow the path to systemd-sysv-install to be specified in runtime. This is needed because the hardcoded path that is built into systemctl does not match the path to where it will eventually be executed.
Signed-off-by Peter Kjellerstedt <[email protected]>---
Hi Peter,
Sorry, but...
WARNING: core-image-full-cmdline-1.0-r0
do_rootfs: iptables.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: openssh-sshd.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: sysklogd.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: ostinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: at.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: cronie.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: logrotate.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: nfs-utils-client.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: nfs-utils.postinst returned 1, marking as unpacked only, configuration required on target.
WARNING: core-image-full-cmdline-1.0-r0do_rootfs: run-postinsts.postinst returned 1, marking as unpacked only, configuration required on target.
ERROR: core-image-full-cmdline-1.0-r0do_rootfs: Postinstall scriptlets of ['iptables', 'openssh-sshd', 'sysklogd', 'ostinst returned 1, marking as unpacked only, configuration required on target', 'at', 'cronie', 'logrotate', 'nfs-utils-client', 'nfs-utils', 'run-postinsts'] have failed. If the intention is to defer them to first boot, then please place them into pkg_postinst_ontarget:${PN} ().
Deferring to first boot via 'exit 1' is no longer supported.Quoted 7 lines
https://autobuilder.yoctoproject.org/valkyrie/#/builders/65/builds/2253
And lot of other builds in
https://autobuilder.yoctoproject.org/valkyrie/#/builders/29/builds/2246Best regards,
MathieuI have failed to reproduce this. I fetched
15c8343c10751f16248ac1b5b5d1cad34b4e4917that is used in the above builds, and used this configuration in my local.conf (to try to mimic the configuration used by the autobuilder):DISTRO ?= "poky-altcfg"
EXTRA_IMAGE_FEATURES?= "allow-empty-password empty-root-password allow-root-login"
USER_CLASSES?= "buildstats"MACHINE ?= "genericx86"
INHERIT += "image-buildinfo" IMAGE_BUILDINFO_VARS:append = "
IMAGE_BASENAMEIMAGE_NAME"
PACKAGE_CLASSES= "package_ipkpackage_rpmpackage_deb"Quoted 8 lines
IMAGE_ROOTFS_EXTRA_SPACE:append = "${@bb.utils.contains('IMAGE_FEATURES', 'package-management', ' + 262144', '', d)}"
BB_HASHSERVE= "wss://hashserv-eu.yoctoproject.org/ws"Do you have the log.do_rootfs from the failed build? Maybe it can shed some light on what went wrong...
//Peter
I have to confess I'm having a hard time trying to reproduce this locally. I will try again in the coming days.
Quoted 7 lines
I've saved data of the following build and I'm attaching the log.do_rootfs.
https://autobuilder.yoctoproject.org/valkyrie/#/builders/93/builds/2263
Best regards,
Mathieu
I figured it out. It failed when building from sstate because even if I fixed so that the path to systemd-sysv-install wasn’t hardcoded into systemctl, it was still hardcoded into the RPM scripts. :(
I have sent updated versions of the patches that should not result in any hardcoded paths anywhere, and this time I have verified all combinations I could think of with and without sstate, and with and without sysvinit in DISTRO_FEATURES.
//Peter
Quoted 11 lines · Peter Kjellerstedt via lists.openembedded.org
I figured it out. It failed when building from sstate because even if I fixed so that the path to systemd-sysv-install wasn’t hardcoded into systemctl, it was still hardcoded into the RPM scripts. :(
I have sent updated versions of the patches that should not result in any hardcoded paths anywhere, and this time I have verified all combinations I could think of with and without sstate, and with and without sysvinit in
DISTRO_FEATURES.//Peter
Hi Peter,
I confirm the build went well with the new version of your series. Thanks!
Signature · 3 lines
Mathieu Dubois-Briand, Bootlin Embedded Linux and Kernel engineering https://bootlin.com