Skip to contentSkip to conversation

package/systemd: add option to enable SysV and utmp compatibility

PATCH New Norbert Lange 4 participants 10 messages Jul 10, 2020 – Nov 3, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 package/systemd: add option to enable SysV and utmp compatibility

The option BR2_PACKAGE_SYSTEMD_SYSV enables compatibility with SysV services-

BR2_PACKAGE_SYSTEMD_UTMP adds support for the utmp Database, which is only used by tools like 'who' and 'last' nowadays AFAIK.

---
 package/systemd/Config.in  | 12 ++++++++++++
 package/systemd/systemd.mk | 12 ++++++++++++
 2 files changed, 24 insertions(+)
package/systemd/Config.in +12 -0
index dd3b8c534d..5cc22b4b95 100644
@@ -112,6 +112,18 @@ config BR2_PACKAGE_SYSTEMD_BOOT
 
 	  https://www.freedesktop.org/wiki/Software/systemd/systemd-boot/
 
+config BR2_PACKAGE_SYSTEMD_SYSV
+	bool "Enable compatibility for sysvinit services"
+	help
+	  Enable buildtime options for compatibility with sysv
+	  services, and install tools and services needed.
+
+config BR2_PACKAGE_SYSTEMD_UTMP
+	bool "Enable compatibility for utmp"
+	help
+	  Enable buildtime options for compatibility with
+	  services depending on utmp.
+
 config BR2_PACKAGE_SYSTEMD_BOOT_EFI_ARCH
 	string
 	default "ia32"  if BR2_i386
package/systemd/systemd.mk +12 -0
index 05c1d1ff9a..05d8cb4934 100644
@@ -199,6 +199,18 @@ else
 SYSTEMD_CONF_OPTS += -Dpcre2=false
 endif
 
+ifeq ($(BR2_PACKAGE_SYSTEMD_SYSV),y)
+SYSTEMD_CONF_OPTS += -Dsysvinit-path=/etc/init.d -Dsysvrcnd-path=/etc/rc.d
+else
+SYSTEMD_CONF_OPTS += -Dsysvinit-path= -Dsysvrcnd-path=
+endif
+
+ifeq ($(BR2_PACKAGE_SYSTEMD_UTMP),y)
+SYSTEMD_CONF_OPTS += -Dutmp=true
+else
+SYSTEMD_CONF_OPTS += -Dutmp=false
+endif
+
 ifeq ($(BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY),y)
 SYSTEMD_DEPENDENCIES += libmicrohttpd
 SYSTEMD_CONF_OPTS += -Dmicrohttpd=true
Signature · 1 line
2.27.0
#1 lore raw

PATCH 2/3 package/systemd: fix telinit-path and add missing pat options

If paths are not set, then meson will search the host system for the binaries (or the target, where those binaries are not yet installed). So add the missing paths.

Also fixup the path to telinit (nice way to get a build path into the binary).

---
 package/systemd/systemd.mk | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
package/systemd/systemd.mk +5 -1
index 05d8cb4934..176adb434a 100644
@@ -32,12 +32,16 @@ SYSTEMD_CONF_OPTS += \
 	-Dsplit-usr=false \
 	-Dsystem-uid-max=999 \
 	-Dsystem-gid-max=999 \
-	-Dtelinit-path=$(TARGET_DIR)/sbin/telinit \
+	-Dquotaon-path=/usr/sbin/quotaon \
+	-Dquotacheck-path=/usr/sbin/quotacheck \
 	-Dkmod-path=/usr/bin/kmod \
 	-Dkexec-path=/usr/sbin/kexec \
 	-Dsulogin-path=/usr/sbin/sulogin \
 	-Dmount-path=/usr/bin/mount \
 	-Dumount-path=/usr/bin/umount \
+	-Dloadkeys-path=/usr/bin/loadkeys \
+	-Dsetfont-path=/usr/bin/setfont \
+	-Dtelinit-path=/sbin/telinit \
 	-Dnobody-group=nogroup \
 	-Didn=true \
 	-Dnss-systemd=true
Signature · 1 line
2.27.0
#2 lore raw

PATCH 2/3 package/systemd: fix telinit-path and add missing pat options

All:

Quoted 37 lines · Norbert Lange

If paths are not set, then meson will search the host system for the binaries (or the target, where those binaries are not yet installed). So add the missing paths.

Also fixup the path to telinit (nice way to get a build path into the binary).

---
 package/systemd/systemd.mk | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
package/systemd/systemd.mk +5 -2
index 05d8cb4934..176adb434a 100644
@@ -32,12 +32,16 @@ SYSTEMD_CONF_OPTS += \
        -Dsplit-usr=false \
        -Dsystem-uid-max=999 \
        -Dsystem-gid-max=999 \
-       -Dtelinit-path=$(TARGET_DIR)/sbin/telinit \
+       -Dquotaon-path=/usr/sbin/quotaon \
+       -Dquotacheck-path=/usr/sbin/quotacheck \
        -Dkmod-path=/usr/bin/kmod \
        -Dkexec-path=/usr/sbin/kexec \
        -Dsulogin-path=/usr/sbin/sulogin \
        -Dmount-path=/usr/bin/mount \
        -Dumount-path=/usr/bin/umount \
+       -Dloadkeys-path=/usr/bin/loadkeys \
+       -Dsetfont-path=/usr/bin/setfont \
+       -Dtelinit-path=/sbin/telinit \
        -Dnobody-group=nogroup \
        -Didn=true \
        -Dnss-systemd=true
--

2.27.0

#3 lore raw

PATCH 2/3 package/systemd: fix telinit-path and add missing pat options

In reply to Norbert Lange

Hi Norbert,

Quoted 3 lines · Norbert Lange

If paths are not set, then meson will search the host system for the binaries (or the target, where those binaries are not yet installed). So add the missing paths.

Applied to master, thanks, except:

Quoted 2 lines

Also fixup the path to telinit (nice way to get a build path into the binary).

... since in the end we explicitly removed sysv support from the config,
keeping telinit makes no sense.

So, in a separate patch, I set telinit_path to nothing (like it's done for the
other sysv stuff).

I also pushed a follow-up patch that sorts the options.

Regards,
Arnout

Quoted 29 lines
---
 package/systemd/systemd.mk | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
package/systemd/systemd.mk +5 -1
index 05d8cb4934..176adb434a 100644
@@ -32,12 +32,16 @@ SYSTEMD_CONF_OPTS += \
 	-Dsplit-usr=false \
 	-Dsystem-uid-max=999 \
 	-Dsystem-gid-max=999 \
-	-Dtelinit-path=$(TARGET_DIR)/sbin/telinit \
+	-Dquotaon-path=/usr/sbin/quotaon \
+	-Dquotacheck-path=/usr/sbin/quotacheck \
 	-Dkmod-path=/usr/bin/kmod \
 	-Dkexec-path=/usr/sbin/kexec \
 	-Dsulogin-path=/usr/sbin/sulogin \
 	-Dmount-path=/usr/bin/mount \
 	-Dumount-path=/usr/bin/umount \
+	-Dloadkeys-path=/usr/bin/loadkeys \
+	-Dsetfont-path=/usr/bin/setfont \
+	-Dtelinit-path=/sbin/telinit \
 	-Dnobody-group=nogroup \
 	-Didn=true \
 	-Dnss-systemd=true
#4 lore raw

PATCH 3/3 package/systemd: make a couple dependencies optional

In reply to Norbert Lange

Remove BR2_PACKAGE_UTIL_LINUX_BINARIES, as none
of the tools is necessary.

Remove BR2_PACKAGE_UTIL_LINUX_LIBBLKID, as this is optional. Aslong as MOUNT or FSCK are enabled, it will end up enabled anyway, but this seems more clear and correct.

Remove BR2_PACKAGE_UTIL_LINUX_NOLOGIN, if this option is not enabled then fall back to using /bin/false instead.

---
 package/systemd/Config.in  |  4 +---
 package/systemd/systemd.mk | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 4 deletions(-)
package/systemd/Config.in +1 -3
index 5cc22b4b95..f6738ae287 100644
@@ -28,12 +28,9 @@ menuconfig BR2_PACKAGE_SYSTEMD
 	select BR2_PACKAGE_DBUS # runtime dependency only
 	select BR2_PACKAGE_LIBCAP
 	select BR2_PACKAGE_UTIL_LINUX
-	select BR2_PACKAGE_UTIL_LINUX_LIBBLKID
 	select BR2_PACKAGE_UTIL_LINUX_LIBMOUNT
-	select BR2_PACKAGE_UTIL_LINUX_BINARIES
 	select BR2_PACKAGE_UTIL_LINUX_AGETTY
 	select BR2_PACKAGE_UTIL_LINUX_MOUNT
-	select BR2_PACKAGE_UTIL_LINUX_NOLOGIN
 	select BR2_PACKAGE_UTIL_LINUX_FSCK
 	select BR2_PACKAGE_KMOD
 	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # kmod-tools
@@ -361,6 +358,7 @@ config BR2_PACKAGE_SYSTEMD_REPART
 	bool "enable repart support"
 	select BR2_PACKAGE_OPENSSL
 	select BR2_PACKAGE_UTIL_LINUX_LIBFDISK
+	select BR2_PACKAGE_UTIL_LINUX_LIBBLKID
 	help
 	  systemd-repart grows and adds partitions to a partition table,
 	  based on the configuration files described in repart.d.
package/systemd/systemd.mk +12 -1
index 176adb434a..8f57cd6466 100644
@@ -22,7 +22,6 @@ SYSTEMD_PROVIDES = udev
 
 SYSTEMD_CONF_OPTS += \
 	-Drootlibdir='/usr/lib' \
-	-Dblkid=true \
 	-Dman=false \
 	-Dima=false \
 	-Dldconfig=false \
@@ -203,6 +202,18 @@ else
 SYSTEMD_CONF_OPTS += -Dpcre2=false
 endif
 
+ifeq ($(BR2_PACKAGE_UTIL_LINUX_LIBBLKID),y)
+SYSTEMD_CONF_OPTS += -Dblkid=true
+else
+SYSTEMD_CONF_OPTS += -Dblkid=false
+endif
+
+ifeq ($(BR2_PACKAGE_UTIL_LINUX_NOLOGIN),y)
+SYSTEMD_CONF_OPTS += -Dnologin-path=/usr/sbin/nologin
+else
+SYSTEMD_CONF_OPTS += -Dnologin-path=/bin/false
+endif
+
 ifeq ($(BR2_PACKAGE_SYSTEMD_SYSV),y)
 SYSTEMD_CONF_OPTS += -Dsysvinit-path=/etc/init.d -Dsysvrcnd-path=/etc/rc.d
 else
Signature · 1 line
2.27.0
#5 lore raw

PATCH 1/3 package/systemd: add option to enable SysV and utmp compatibility

In reply to Norbert Lange

package/systemd/systemd.mk else · line 203

Quoted 10 lines · On Sat, 11 Jul 2020 01:41:47 +0200 Norbert Lange <[email protected]> wrote:
package/systemd/systemd.mk +2 -0
index 05c1d1ff9a..05d8cb4934 100644
@@ -199,6 +199,18 @@ else
 SYSTEMD_CONF_OPTS += -Dpcre2=false
 endif
 
+ifeq ($(BR2_PACKAGE_SYSTEMD_SYSV),y)
+SYSTEMD_CONF_OPTS += -Dsysvinit-path=/etc/init.d -Dsysvrcnd-path=/etc/rc.d

We don't have any /etc/rc.d directory in Buildroot, and when systemd is selected as the init system, we don't install init scripts in /etc/init.d. So I'm wondering what is the use case for this option ?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw

PATCH 1/3 package/systemd: add option to enable SysV and utmp compatibility

Thomas Petazzoni <[email protected]> schrieb am Sa., 11. Juli 2020, 12:56:

Quoted 11 lines
Quoted 8 lines · On Sat, 11 Jul 2020 01:41:47 +0200 Norbert Lange <[email protected]> wrote:
package/systemd/systemd.mk +0 -0
index 05c1d1ff9a..05d8cb4934 100644
@@ -199,6 +199,18 @@ else
 SYSTEMD_CONF_OPTS += -Dpcre2=false
 endif
 
Quoted 8 lines

package/systemd/systemd.mk else · line 203

Quoted 2 lines
package/systemd/systemd.mk +2 -0
+ifeq ($(BR2_PACKAGE_SYSTEMD_SYSV),y)
+SYSTEMD_CONF_OPTS += -Dsysvinit-path=/etc/init.d

-Dsysvrcnd-path=/etc/rc.d

We don't have any /etc/rc.d directory in Buildroot, and when systemd is selected as the init system, we don't install init scripts in /etc/init.d. So I'm wondering what is the use case for this option ?

Removing *support for unit scripts*. those scripts, as you said, don't exist.
That support comes in form of several services to parse and convert those script, some code and daemon to allow systemd to communicate with some sysv tools (initctl, runlevels et all).

Norbert

Quoted 8 lines

Best regards,

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20200711/aed0d494/attachment.html>

#7 lore raw

PATCH 1/3 package/systemd: add option to enable SysV and utmp compatibility

Norbert Lange <[email protected]> schrieb am Sa., 11. Juli 2020, 13:25:

Quoted 26 lines

Thomas Petazzoni <[email protected]> schrieb am Sa., 11. Juli 2020, 12:56:

Quoted 11 lines
Quoted 8 lines · On Sat, 11 Jul 2020 01:41:47 +0200 Norbert Lange <[email protected]> wrote:
package/systemd/systemd.mk +0 -0
index 05c1d1ff9a..05d8cb4934 100644
@@ -199,6 +199,18 @@ else
 SYSTEMD_CONF_OPTS += -Dpcre2=false
 endif
 
Quoted 8 lines

package/systemd/systemd.mk else · line 203

Quoted 2 lines
package/systemd/systemd.mk +2 -0
+ifeq ($(BR2_PACKAGE_SYSTEMD_SYSV),y)
+SYSTEMD_CONF_OPTS += -Dsysvinit-path=/etc/init.d

-Dsysvrcnd-path=/etc/rc.d

We don't have any /etc/rc.d directory in Buildroot, and when systemd is selected as the init system, we don't install init scripts in /etc/init.d. So I'm wondering what is the use case for this option ?

Quoted 18 lines

Removing *support for unit scripts*. those scripts, as you said, don't exist.
That support comes in form of several services to parse and convert those script, some code and daemon to allow systemd to communicate with some sysv tools (initctl, runlevels et all).

Norbert

Quoted 7 lines

Best regards,

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Hmm, maybe I misunderstood. There is no Boolean to enable this support, but it is disabled when those paths are empty.

I enable these paths by setting the defaults.
If you want to argue, that we should just disabled the compatibility without option, I won't object

Norbert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20200711/c70a8667/attachment.html>

#8 lore raw

PATCH 1/3 package/systemd: add option to enable SysV and utmp compatibility

In reply to Norbert Lange
Quoted 11 lines · On Sat, 11 Jul 2020 13:25:08 +0200 Norbert Lange <[email protected]> wrote:
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+ifeq ($(BR2_PACKAGE_SYSTEMD_SYSV),y)
+SYSTEMD_CONF_OPTS += -Dsysvinit-path=/etc/init.d  

-Dsysvrcnd-path=/etc/rc.d

We don't have any /etc/rc.d directory in Buildroot, and when systemd is selected as the init system, we don't install init scripts in /etc/init.d. So I'm wondering what is the use case for this option ?

Removing *support for unit scripts*. those scripts, as you said, don't exist.

Yes, but your patch also keeps support for init scripts enabled when BR2_PACKAGE_SYSTEMD_SYSV=y, and I don't understand what is the use case.

When systemd is enabled, there will be nothing in /etc/init.d, because Buildroot only executes the <pkg>_INIT_SYSV commands (that install init scripts) when the init system is Busybox or SysVinit.

Or do you want to support use cases where some users may install their own init scripts in /etc/init.d, but are using systemd ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#9 lore raw

PATCH 1/3 package/systemd: add option to enable SysV and utmp compatibility

Am Sa., 11. Juli 2020 um 15:14 Uhr schrieb Thomas Petazzoni <[email protected]>:

Quoted 19 lines
Quoted 11 lines · On Sat, 11 Jul 2020 13:25:08 +0200 Norbert Lange <[email protected]> wrote:
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+ifeq ($(BR2_PACKAGE_SYSTEMD_SYSV),y)
+SYSTEMD_CONF_OPTS += -Dsysvinit-path=/etc/init.d

-Dsysvrcnd-path=/etc/rc.d

We don't have any /etc/rc.d directory in Buildroot, and when systemd is selected as the init system, we don't install init scripts in /etc/init.d. So I'm wondering what is the use case for this option ?

Removing *support for unit scripts*. those scripts, as you said, don't exist.

Yes, but your patch also keeps support for init scripts enabled when BR2_PACKAGE_SYSTEMD_SYSV=y, and I don't understand what is the use case.

Quoted 6 lines

When systemd is enabled, there will be nothing in /etc/init.d, because Buildroot only executes the <pkg>_INIT_SYSV commands (that install init scripts) when the init system is Busybox or SysVinit.

Or do you want to support use cases where some users may install their own init scripts in /etc/init.d, but are using systemd ?

I accounted for such usecases, because I thought that's expected with buildroot. No trouble removing the option from my side.
This goes for utmp aswell (not sure Id want logged in users exposed in a file amyway)

Norbert