diff mbox series

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

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

Commit Message

Peter Kjellerstedt Aug. 22, 2025, 6:20 p.m. UTC
It is needed when support for both systemd and sysvinit are enabled.

This also adds a patch for systemctl to call systemd-sysv-install
without a hardcoded path and instead relies on finding it in $PATH. This
is needed when calling systemctl from a recipe sysroot.

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.
PATCHv6: Completely reworked the patch for systemctl.

 .../systemd/systemd-systemctl-native_257.8.bb | 11 ++++++
 ...ll-systemd-sysv-install-without-path.patch | 37 +++++++++++++++++++
 ...implment-systemd-sysv-install-for-OE.patch | 13 +++----
 3 files changed, 53 insertions(+), 8 deletions(-)
 create mode 100644 meta/recipes-core/systemd/systemd/0001-systemctl-Call-systemd-sysv-install-without-path.patch

Comments

Ross Burton Sept. 1, 2025, 5:07 p.m. UTC | #1
On 22 Aug 2025, at 19:20, Peter Kjellerstedt via lists.openembedded.org <peter.kjellerstedt=axis.com@lists.openembedded.org> wrote:
> +do_install:append() {
> + # Install systemd-sysv-install in /usr/bin rather than /usr/lib/systemd
> + # (where it is normally installed) so systemctl can find it in $PATH.
> + install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON ${D}${bindir}/systemd-sysv-install
> +}

To save future maintainers, I feel like this should have a comment saying that it’s expected that this patch will need to be reverted when systemd is upgraded to v259, as that will remove this functionality.

Ross
Peter Kjellerstedt Sept. 8, 2025, 4:06 p.m. UTC | #2
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-
> core@lists.openembedded.org> On Behalf Of Ross Burton via
> lists.openembedded.org
> Sent: den 1 september 2025 19:08
> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCHv6 1/2] systemd-systemctl-native: Install
> systemd-sysv-install
> 
> On 22 Aug 2025, at 19:20, Peter Kjellerstedt via lists.openembedded.org
> <peter.kjellerstedt=axis.com@lists.openembedded.org> wrote:
> > +do_install:append() {
> > + # Install systemd-sysv-install in /usr/bin rather than
> /usr/lib/systemd
> > + # (where it is normally installed) so systemctl can find it in $PATH.
> > + install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON
> ${D}${bindir}/systemd-sysv-install
> > +}
> 
> To save future maintainers, I feel like this should have a comment saying
> that it’s expected that this patch will need to be reverted when systemd
> is upgraded to v259, as that will remove this functionality.
> 
> Ross

Ok, I have sent an updated version with an added comment.

//Peter
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..4486edf651 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-Call-systemd-sysv-install-without-path.patch"
+SRC_URI += "file://0002-implment-systemd-sysv-install-for-OE.patch"
+
 inherit pkgconfig meson native
 
 MESON_TARGET = "systemctl:executable"
@@ -14,3 +19,9 @@  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() {
+	# Install systemd-sysv-install in /usr/bin rather than /usr/lib/systemd
+	# (where it is normally installed) so systemctl can find it in $PATH.
+	install -Dm 0755 ${S}/src/systemctl/systemd-sysv-install.SKELETON ${D}${bindir}/systemd-sysv-install
+}
diff --git a/meta/recipes-core/systemd/systemd/0001-systemctl-Call-systemd-sysv-install-without-path.patch b/meta/recipes-core/systemd/systemd/0001-systemctl-Call-systemd-sysv-install-without-path.patch
new file mode 100644
index 0000000000..bf08dbe9b0
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0001-systemctl-Call-systemd-sysv-install-without-path.patch
@@ -0,0 +1,37 @@ 
+From 34c8551a8b16bf235a1ebe8d9cb1a3474a7c975e Mon Sep 17 00:00:00 2001
+From: Peter Kjellerstedt <pkj@axis.com>
+Date: Fri, 22 Aug 2025 18:07:28 +0200
+Subject: [PATCH] systemctl: Call systemd-sysv-install without path
+
+Expect to find systemd-sysv-install in $PATH instead of hardcoding the
+path to it, as the latter does not work when running systemctl from a
+recipe sysroot.
+
+Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
+Upstream-Status: Inappropriate [OE specific]
+---
+ src/systemctl/systemctl-sysv-compat.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/systemctl/systemctl-sysv-compat.c b/src/systemctl/systemctl-sysv-compat.c
+index cb9c43e3dc..e44ef9f64e 100644
+--- a/src/systemctl/systemctl-sysv-compat.c
++++ b/src/systemctl/systemctl-sysv-compat.c
+@@ -140,7 +140,7 @@ int enable_sysv_units(const char *verb, char **args) {
+         while (args[f]) {
+ 
+                 const char *argv[] = {
+-                        LIBEXECDIR "/systemd-sysv-install",
++                        "systemd-sysv-install",
+                         NULL, /* --root= */
+                         NULL, /* verb */
+                         NULL, /* service */
+@@ -218,7 +218,7 @@ int enable_sysv_units(const char *verb, char **args) {
+                         return j;
+                 if (j == 0) {
+                         /* Child */
+-                        execv(argv[0], (char**) argv);
++                        execvp(argv[0], (char**) argv);
+                         log_error_errno(errno, "Failed to execute %s: %m", argv[0]);
+                         _exit(EXIT_FAILURE);
+                 }
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..98d050ceae 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 4a5602ede9881fd8e578a3c8bc40dd5df7c4d802 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
-