diff mbox series

[PATCHv5,1/2] systemd-systemctl-native: Install systemd-sysv-install

Message ID 20250820134202.1412477-1-pkj@axis.com
State New
Headers show
Series [PATCHv5,1/2] systemd-systemctl-native: Install systemd-sysv-install | expand

Commit Message

Peter Kjellerstedt Aug. 20, 2025, 1:42 p.m. UTC
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 <peter.kjellerstedt@axis.com>
---

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

Comments

Mathieu Dubois-Briand Aug. 21, 2025, 6:38 a.m. UTC | #1
On Wed Aug 20, 2025 at 3:42 PM CEST, Peter Kjellerstedt via lists.openembedded.org wrote:
> 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 <peter.kjellerstedt@axis.com>
> ---

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
Peter Kjellerstedt Aug. 21, 2025, 3:11 p.m. UTC | #2
> -----Original Message-----
> From: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
> Sent: den 21 augusti 2025 08:38
> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>; openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCHv5 1/2] systemd-systemctl-native: Install systemd-sysv-install
> 
> On Wed Aug 20, 2025 at 3:42 PM CEST, Peter Kjellerstedt via lists.openembedded.org wrote:
> > 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 <peter.kjellerstedt@axis.com>
> > ---
> 
> 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

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
Mathieu Dubois-Briand Aug. 21, 2025, 7:19 p.m. UTC | #3
On Thu Aug 21, 2025 at 5:11 PM CEST, Peter Kjellerstedt via lists.openembedded.org wrote:
>> -----Original Message-----
>> From: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
>> Sent: den 21 augusti 2025 08:38
>> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>; openembedded-core@lists.openembedded.org
>> Subject: Re: [OE-core] [PATCHv5 1/2] systemd-systemctl-native: Install systemd-sysv-install
>> 
>> On Wed Aug 20, 2025 at 3:42 PM CEST, Peter Kjellerstedt via lists.openembedded.org wrote:
>> > 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 <peter.kjellerstedt@axis.com>
>> > ---
>> 
>> 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
>
> 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

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
Peter Kjellerstedt Aug. 22, 2025, 6:29 p.m. UTC | #4
> -----Original Message-----
> From: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
> Sent: den 21 augusti 2025 21:19
> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCHv5 1/2] systemd-systemctl-native: Install systemd-sysv-install
> 
> On Thu Aug 21, 2025 at 5:11 PM CEST, Peter Kjellerstedt via lists.openembedded.org wrote:
> >> -----Original Message-----
> >> From: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
> >> Sent: den 21 augusti 2025 08:38
> >> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>; openembedded-core@lists.openembedded.org
> >> Subject: Re: [OE-core] [PATCHv5 1/2] systemd-systemctl-native: Install systemd-sysv-install
> >>
> >> On Wed Aug 20, 2025 at 3:42 PM CEST, Peter Kjellerstedt via lists.openembedded.org wrote:
> >> > 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 <peter.kjellerstedt@axis.com>
> >> > ---
> >>
> >> 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
> >
> > 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
> 
> 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

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
Mathieu Dubois-Briand Aug. 24, 2025, 6:37 a.m. UTC | #5
On Fri Aug 22, 2025 at 8:29 PM CEST, Peter Kjellerstedt via lists.openembedded.org wrote:
>
> 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!
diff mbox series

Patch

diff --git a/meta/recipes-core/systemd/systemd-systemctl-native_257.8.bb b/meta/recipes-core/systemd/systemd-systemctl-native_257.8.bb
index 041a040a26..c0aed809dc 100644
--- a/meta/recipes-core/systemd/systemd-systemctl-native_257.8.bb
+++ b/meta/recipes-core/systemd/systemd-systemctl-native_257.8.bb
@@ -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
+}
diff --git a/meta/recipes-core/systemd/systemd/0001-systemctl-Add-sysv-install-to-specify-path-to-system.patch b/meta/recipes-core/systemd/systemd/0001-systemctl-Add-sysv-install-to-specify-path-to-system.patch
new file mode 100644
index 0000000000..38dfdb47a6
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0001-systemctl-Add-sysv-install-to-specify-path-to-system.patch
@@ -0,0 +1,145 @@ 
+From eb02a1bf3bfcc73302c7849cedfa756799168c5d Mon Sep 17 00:00:00 2001
+From: Peter Kjellerstedt <pkj@axis.com>
+Date: Thu, 14 Aug 2025 22:48:00 +0200
+Subject: [PATCH] systemctl: Add --sysv-install to specify the path to
+ systemd-sysv-install
+
+This allows the path to systemd-sysv-install to be specified in runtime.
+
+The hardcoded path to systemd-sysv-install in systemctl causes problems
+when they need to be run from some other location than the expected,
+e.g., when used in a sysroot.
+
+Upstream-Status: Denied [https://github.com/systemd/systemd/pull/38614]
+Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
+---
+ man/systemctl.xml                     | 13 +++++++++++++
+ src/systemctl/systemctl-sysv-compat.c |  6 +++++-
+ src/systemctl/systemctl.c             | 11 +++++++++++
+ src/systemctl/systemctl.h             |  1 +
+ 4 files changed, 30 insertions(+), 1 deletion(-)
+
+diff --git a/man/systemctl.xml b/man/systemctl.xml
+index be9fa4803c..ad1bbaf1a1 100644
+--- a/man/systemctl.xml
++++ b/man/systemctl.xml
+@@ -2885,6 +2885,19 @@ EOF
+         </listitem>
+       </varlistentry>
+ 
++      <varlistentry>
++        <term><option>--sysv-install=</option></term>
++
++        <listitem>
++          <para>When used with
++          <command>enable</command>/<command>disable</command>/<command>is-enabled</command>
++          on a unit that is a SysV init.d script, use the specified path instead of
++          <filename>/usr/lib/systemd/systemd-sysv-install</filename> to call the
++          distribution's mechanism for enabling/disabling it.</para>
++        </listitem>
++
++      </varlistentry>
++
+       <xi:include href="user-system-options.xml" xpointer="host" />
+       <xi:include href="user-system-options.xml" xpointer="machine" />
+       <xi:include href="user-system-options.xml" xpointer="capsule" />
+diff --git a/src/systemctl/systemctl-sysv-compat.c b/src/systemctl/systemctl-sysv-compat.c
+index cb9c43e3dc..96b3c451f0 100644
+--- a/src/systemctl/systemctl-sysv-compat.c
++++ b/src/systemctl/systemctl-sysv-compat.c
+@@ -3,6 +3,7 @@
+ #include <fcntl.h>
+ #include <sys/stat.h>
+ #include <sys/types.h>
++#include <unistd.h>
+ 
+ #include "env-util.h"
+ #include "fd-util.h"
+@@ -132,6 +133,9 @@ int enable_sysv_units(const char *verb, char **args) {
+                         "is-enabled"))
+                 return 0;
+ 
++        if (arg_sysv_install && access(arg_sysv_install, X_OK) < 0)
++                return log_error_errno(errno, "%s is not executable: %m", arg_sysv_install);
++
+         r = lookup_paths_init_or_warn(&paths, arg_runtime_scope, LOOKUP_PATHS_EXCLUDE_GENERATED, arg_root);
+         if (r < 0)
+                 return r;
+@@ -140,7 +144,7 @@ int enable_sysv_units(const char *verb, char **args) {
+         while (args[f]) {
+ 
+                 const char *argv[] = {
+-                        LIBEXECDIR "/systemd-sysv-install",
++                        arg_sysv_install ?: LIBEXECDIR "/systemd-sysv-install",
+                         NULL, /* --root= */
+                         NULL, /* verb */
+                         NULL, /* service */
+diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
+index 8c9fcb69f2..1e718e7d87 100644
+--- a/src/systemctl/systemctl.c
++++ b/src/systemctl/systemctl.c
+@@ -126,6 +126,7 @@ bool arg_mkdir = false;
+ bool arg_marked = false;
+ const char *arg_drop_in = NULL;
+ ImagePolicy *arg_image_policy = NULL;
++char *arg_sysv_install = NULL;
+ 
+ STATIC_DESTRUCTOR_REGISTER(arg_types, strv_freep);
+ STATIC_DESTRUCTOR_REGISTER(arg_states, strv_freep);
+@@ -141,6 +142,7 @@ STATIC_DESTRUCTOR_REGISTER(arg_boot_loader_entry, unsetp);
+ STATIC_DESTRUCTOR_REGISTER(arg_clean_what, strv_freep);
+ STATIC_DESTRUCTOR_REGISTER(arg_drop_in, unsetp);
+ STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep);
++STATIC_DESTRUCTOR_REGISTER(arg_sysv_install, freep);
+ 
+ static int systemctl_help(void) {
+         _cleanup_free_ char *link = NULL;
+@@ -348,6 +350,7 @@ static int systemctl_help(void) {
+                "     --when=TIME         Schedule halt/power-off/reboot/kexec action after\n"
+                "                         a certain timestamp\n"
+                "     --stdin             Read new contents of edited file from stdin\n"
++               "     --sysv-install=PATH The path to systemd-sysv-install\n"
+                "\nSee the %2$s for details.\n",
+                program_invocation_short_name,
+                link,
+@@ -475,6 +478,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
+                 ARG_DROP_IN,
+                 ARG_WHEN,
+                 ARG_STDIN,
++                ARG_SYSV_INSTALL,
+         };
+ 
+         static const struct option options[] = {
+@@ -543,6 +547,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
+                 { "drop-in",             required_argument, NULL, ARG_DROP_IN             },
+                 { "when",                required_argument, NULL, ARG_WHEN                },
+                 { "stdin",               no_argument,       NULL, ARG_STDIN               },
++                { "sysv-install",        required_argument, NULL, ARG_SYSV_INSTALL        },
+                 {}
+         };
+ 
+@@ -1052,6 +1057,12 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
+                         arg_stdin = true;
+                         break;
+ 
++                case ARG_SYSV_INSTALL:
++                        r = parse_path_argument(optarg, false, &arg_sysv_install);
++                        if (r < 0)
++                                return r;
++                        break;
++
+                 case '.':
+                         /* Output an error mimicking getopt, and print a hint afterwards */
+                         log_error("%s: invalid option -- '.'", program_invocation_name);
+diff --git a/src/systemctl/systemctl.h b/src/systemctl/systemctl.h
+index 00405f4705..1db16d0183 100644
+--- a/src/systemctl/systemctl.h
++++ b/src/systemctl/systemctl.h
+@@ -105,6 +105,7 @@ extern bool arg_mkdir;
+ extern bool arg_marked;
+ extern const char *arg_drop_in;
+ extern ImagePolicy *arg_image_policy;
++extern char *arg_sysv_install;
+ 
+ static inline const char* arg_job_mode(void) {
+         return _arg_job_mode ?: "replace";
diff --git a/meta/recipes-core/systemd/systemd/0002-implment-systemd-sysv-install-for-OE.patch b/meta/recipes-core/systemd/systemd/0002-implment-systemd-sysv-install-for-OE.patch
index d8bb572261..20a2f01317 100644
--- a/meta/recipes-core/systemd/systemd/0002-implment-systemd-sysv-install-for-OE.patch
+++ b/meta/recipes-core/systemd/systemd/0002-implment-systemd-sysv-install-for-OE.patch
@@ -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 <raj.khem@gmail.com>
 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 <raj.khem@gmail.com>
  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
-