Skip to contentSkip to conversation

boot/systemd-boot: new package

PATCH New james.hilliard1 at gmail.com 3 participants 11 messages Dec 14, 2018 – Dec 15, 2018 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 boot/systemd-boot: new package

From: James Hilliard <[email protected]>

This is essentially the successor to gummiboot.

---
 DEVELOPERS                              |  1 +
 boot/Config.in                          |  1 +
 boot/systemd-boot/Config.in             | 23 ++++++++++++++
 boot/systemd-boot/systemd-boot.mk       |  7 +++++
 package/meson/cross-compilation.conf.in |  1 +
 package/meson/meson.mk                  | 41 ++++++++++++++++++++++++-
 package/systemd/Config.in               | 54 +++++++++++++++++++++++++--------
 package/systemd/buildroot.conf          |  3 ++
 package/systemd/loader.conf             |  2 ++
 package/systemd/systemd.mk              | 53 ++++++++++++++++++++++++++++++--
 system/Config.in                        |  1 +
 11 files changed, 171 insertions(+), 16 deletions(-)
 create mode 100644 boot/systemd-boot/Config.in
 create mode 100644 boot/systemd-boot/systemd-boot.mk
 create mode 100644 package/systemd/buildroot.conf
 create mode 100644 package/systemd/loader.conf
DEVELOPERS +1 -0
index 4192681..93599fe 100644
@@ -995,6 +995,7 @@ F:	configs/pine64_defconfig
 F:	configs/pine64_sopine_defconfig
 
 N:	James Hilliard <[email protected]>
+F:	boot/systemd-boot/
 F:	package/python-aiodns/
 F:	package/python-aiohttp/
 F:	package/python-aiohttp-jinja2/
boot/Config.in +1 -0
index 8e0c8e5..5b7f606 100644
@@ -16,6 +16,7 @@ source "boot/mxs-bootlets/Config.in"
 source "boot/riscv-pk/Config.in"
 source "boot/s500-bootloader/Config.in"
 source "boot/syslinux/Config.in"
+source "boot/systemd-boot/Config.in"
 source "boot/ts4800-mbrboot/Config.in"
 source "boot/uboot/Config.in"
 source "boot/vexpress-firmware/Config.in"
boot/systemd-boot/Config.in new file +23 -0
new file mode 100644
index 0000000..7c64cef
@@ -0,0 +1,23 @@
+config BR2_TARGET_SYSTEMD_BOOT
+	bool "systemd-boot"
+	depends on BR2_i386 || BR2_x86_64
+	select BR2_PACKAGE_BUILD_SYSTEMD
+	select BR2_PACKAGE_SYSTEMD
+	select BR2_PACKAGE_GNU_EFI
+	help
+	  systemd-boot is a simple UEFI boot manager which executes
+	  configured EFI images. The default entry is selected by a
+	  configured pattern (glob) or an on-screen menu.
+
+	  systemd-boot operates on the EFI System Partition (ESP)
+	  only. Configuration file fragments, kernels, initrds, other
+	  EFI images need to reside on the ESP. Linux kernels need to
+	  be built with CONFIG_EFI_STUB to be able to be directly
+	  executed as an EFI image.
+
+	  See the Grub2 help text for details on preparing an EFI
+	  capable disk image using systemd-boot: the instructions are
+	  exactly the same, except that the systemd-boot configuration
+	  files will be located in /loader/ inside the EFI partition.
+
+	  https://www.freedesktop.org/wiki/Software/systemd/systemd-boot/
\ No newline at end of file
boot/systemd-boot/systemd-boot.mk new file +7 -0
new file mode 100644
index 0000000..5854024
@@ -0,0 +1,7 @@
+################################################################################
+#
+# systemd-boot
+#
+################################################################################
+
+$(eval $(virtual-package))
package/meson/cross-compilation.conf.in +1 -0
index 0eec740..fc8e27f 100644
@@ -11,6 +11,7 @@ strip = '@TARGET_CROSS at strip'
 pkgconfig = '@HOST_DIR@/usr/bin/pkg-config'
 
 [properties]
+needs_exe_wrapper = true
 c_args = [@TARGET_CFLAGS@]
 c_link_args = [@TARGET_LDFLAGS@]
 cpp_args = [@TARGET_CXXFLAGS@]
package/meson/meson.mk +40 -1

53 lines not on this page · raw message

package/systemd/Config.in +42 -12

226 lines not on this page · raw message

package/systemd/buildroot.conf new file +3 -0
new file mode 100644
index 0000000..16d4d85
@@ -0,0 +1,3 @@
+title	Buildroot
+linux	/bzImage
+options	root=/dev/sda2 rootwait console=tty1
package/systemd/loader.conf new file +2 -0
new file mode 100644
index 0000000..93b77b8
@@ -0,0 +1,2 @@
+timeout 3
+default buildroot
package/systemd/systemd.mk +50 -3

77 lines not on this page · raw message

system/Config.in +1 -0
index 9e34f11..773a2cc 100644
@@ -133,6 +133,7 @@ config BR2_INIT_SYSTEMD
 	depends on !BR2_STATIC_LIBS
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10
 	select BR2_ROOTFS_MERGED_USR
+	select BR2_PACKAGE_BUILD_SYSTEMD
 	select BR2_PACKAGE_SYSTEMD
 
 comment "systemd needs a glibc toolchain w/ SSP, headers >= 3.10"
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/1 boot/systemd-boot: new package

James, All,

On 2018-12-14 19:42 +0800, james.hilliard1 at gmail.com spake thusly:

Quoted 3 lines

From: James Hilliard <[email protected]>

This is essentially the successor to gummiboot.

First, this patch is huge, it does many tricky things, so the commit log can't be that short. You need to explain in the commit log what this patch does, why it needs to do it.

Second, the patch basically does three different things:
- change stuff in the meson-packae infrastructure
- change stuff in the systemd package
- adds a new virtual boot package
This is a good indication that there should be _at least_ three patches, one for each of the above changes, each with a detailed commit log that explains what the change does and why it has to be done). Patches should do a complete change of their own, yet be atomic (i.e. can't be split). Here it is obvious that the patch can be split. And if it can't then you have to say why in the commit log, again.

Third, the new virtual boot package has no provider, so that's a indication that something is wrong with that patch.

You need to clearly explain what is going on here, because all I can think is, why can't we simply build the systemd-boot component of systemd directly from the systemd package itself? (Yeah, I think I know the answer, but you have to explain it in the commit log. And no, it can't just be "but this is a bootloader, it has to have an entry in boot/": we have other bootloaders elsewhere, e.g. rpi-firmware, which do not live in boot/ (to my own dismay, but that's another story.))

Regards,
Yann E. MORIN.

Quoted 529 lines
---
 DEVELOPERS                              |  1 +
 boot/Config.in                          |  1 +
 boot/systemd-boot/Config.in             | 23 ++++++++++++++
 boot/systemd-boot/systemd-boot.mk       |  7 +++++
 package/meson/cross-compilation.conf.in |  1 +
 package/meson/meson.mk                  | 41 ++++++++++++++++++++++++-
 package/systemd/Config.in               | 54 +++++++++++++++++++++++++--------
 package/systemd/buildroot.conf          |  3 ++
 package/systemd/loader.conf             |  2 ++
 package/systemd/systemd.mk              | 53 ++++++++++++++++++++++++++++++--
 system/Config.in                        |  1 +
 11 files changed, 171 insertions(+), 16 deletions(-)
 create mode 100644 boot/systemd-boot/Config.in
 create mode 100644 boot/systemd-boot/systemd-boot.mk
 create mode 100644 package/systemd/buildroot.conf
 create mode 100644 package/systemd/loader.conf
DEVELOPERS +1 -0
index 4192681..93599fe 100644
@@ -995,6 +995,7 @@ F:	configs/pine64_defconfig
 F:	configs/pine64_sopine_defconfig
 
 N:	James Hilliard <[email protected]>
+F:	boot/systemd-boot/
 F:	package/python-aiodns/
 F:	package/python-aiohttp/
 F:	package/python-aiohttp-jinja2/
boot/Config.in +1 -0
index 8e0c8e5..5b7f606 100644
@@ -16,6 +16,7 @@ source "boot/mxs-bootlets/Config.in"
 source "boot/riscv-pk/Config.in"
 source "boot/s500-bootloader/Config.in"
 source "boot/syslinux/Config.in"
+source "boot/systemd-boot/Config.in"
 source "boot/ts4800-mbrboot/Config.in"
 source "boot/uboot/Config.in"
 source "boot/vexpress-firmware/Config.in"
boot/systemd-boot/Config.in new file +23 -0
new file mode 100644
index 0000000..7c64cef
@@ -0,0 +1,23 @@
+config BR2_TARGET_SYSTEMD_BOOT
+	bool "systemd-boot"
+	depends on BR2_i386 || BR2_x86_64
+	select BR2_PACKAGE_BUILD_SYSTEMD
+	select BR2_PACKAGE_SYSTEMD
+	select BR2_PACKAGE_GNU_EFI
+	help
+	  systemd-boot is a simple UEFI boot manager which executes
+	  configured EFI images. The default entry is selected by a
+	  configured pattern (glob) or an on-screen menu.
+
+	  systemd-boot operates on the EFI System Partition (ESP)
+	  only. Configuration file fragments, kernels, initrds, other
+	  EFI images need to reside on the ESP. Linux kernels need to
+	  be built with CONFIG_EFI_STUB to be able to be directly
+	  executed as an EFI image.
+
+	  See the Grub2 help text for details on preparing an EFI
+	  capable disk image using systemd-boot: the instructions are
+	  exactly the same, except that the systemd-boot configuration
+	  files will be located in /loader/ inside the EFI partition.
+
+	  https://www.freedesktop.org/wiki/Software/systemd/systemd-boot/
\ No newline at end of file
boot/systemd-boot/systemd-boot.mk new file +7 -0
new file mode 100644
index 0000000..5854024
@@ -0,0 +1,7 @@
+################################################################################
+#
+# systemd-boot
+#
+################################################################################
+
+$(eval $(virtual-package))
package/meson/cross-compilation.conf.in +1 -0
index 0eec740..fc8e27f 100644
@@ -11,6 +11,7 @@ strip = '@TARGET_CROSS at strip'
 pkgconfig = '@HOST_DIR@/usr/bin/pkg-config'
 
 [properties]
+needs_exe_wrapper = true
 c_args = [@TARGET_CFLAGS@]
 c_link_args = [@TARGET_LDFLAGS@]
 cpp_args = [@TARGET_CXXFLAGS@]
package/meson/meson.mk +40 -1
index e1675c2..d9ad2fc 100644
@@ -15,6 +15,45 @@ HOST_MESON_NEEDS_HOST_PYTHON = python3
 
 HOST_MESON_TARGET_ENDIAN = $(call LOWERCASE,$(BR2_ENDIAN))
 HOST_MESON_TARGET_CPU = $(GCC_TARGET_CPU)
+ifeq ($(BR2_arcle),y)
+HOST_MESON_TARGET_CPU_FAMILY = arc
+else ifeq ($(BR2_arceb),y)
+HOST_MESON_TARGET_CPU_FAMILY = arc
+else ifeq ($(BR2_arm),y)
+HOST_MESON_TARGET_CPU_FAMILY = arm
+else ifeq ($(BR2_armeb),y)
+HOST_MESON_TARGET_CPU_FAMILY = arm
+else ifeq ($(BR2_aarch64),y)
+HOST_MESON_TARGET_CPU_FAMILY = aarch64
+else ifeq ($(BR2_aarch64_be),y)
+HOST_MESON_TARGET_CPU_FAMILY = aarch64
+else ifeq ($(BR2_i386),y)
+HOST_MESON_TARGET_CPU_FAMILY = x86
+else ifeq ($(BR2_mips),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips
+else ifeq ($(BR2_mipsel),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips
+else ifeq ($(BR2_mips64),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips64
+else ifeq ($(BR2_mips64el),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips64
+else ifeq ($(BR2_powerpc),y)
+HOST_MESON_TARGET_CPU_FAMILY = ppc
+else ifeq ($(BR2_powerpc64),y)
+HOST_MESON_TARGET_CPU_FAMILY = ppc64
+else ifeq ($(BR2_powerpc64le),y)
+HOST_MESON_TARGET_CPU_FAMILY = ppc64
+else ifeq ($(BR2_riscv),y)
+HOST_MESON_TARGET_CPU_FAMILY = riscv32
+else ifeq ($(BR2_sparc),y)
+HOST_MESON_TARGET_CPU_FAMILY = sparc
+else ifeq ($(BR2_sparc64),y)
+HOST_MESON_TARGET_CPU_FAMILY = sparc64
+else ifeq ($(BR2_x86_64),y)
+HOST_MESON_TARGET_CPU_FAMILY = x86_64
+else
+HOST_MESON_TARGET_CPU_FAMILY = $(ARCH)
+endif
 
 HOST_MESON_SED_CFLAGS = $(if $(TARGET_CFLAGS),`printf '"%s"$(comma) ' $(TARGET_CFLAGS)`)
 HOST_MESON_SED_LDFLAGS = $(if $(TARGET_LDFLAGS),`printf '"%s"$(comma) ' $(TARGET_LDFLAGS)`)
@@ -23,7 +62,7 @@ HOST_MESON_SED_CXXFLAGS = $(if $(TARGET_CXXFLAGS),`printf '"%s"$(comma) ' $(TARG
 define HOST_MESON_INSTALL_CROSS_CONF
 	mkdir -p $(HOST_DIR)/etc/meson
 	sed -e "s%@TARGET_CROSS@%$(TARGET_CROSS)%g" \
-	    -e "s%@TARGET_ARCH@%$(ARCH)%g" \
+	    -e "s%@TARGET_ARCH@%$(HOST_MESON_TARGET_CPU_FAMILY)%g" \
 	    -e "s%@TARGET_CPU@%$(HOST_MESON_TARGET_CPU)%g" \
 	    -e "s%@TARGET_ENDIAN@%$(HOST_MESON_TARGET_ENDIAN)%g" \
 	    -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)%g" \
package/systemd/Config.in +42 -12
index 25f322e..c8fa786 100644
@@ -7,27 +7,30 @@ config BR2_PACKAGE_SYSTEMD_ARCH_SUPPORTS
 		BR2_sh4a || BR2_sh4aeb || BR2_sparc || BR2_x86_64 || \
 		BR2_aarch64 || BR2_m68k || BR2_arc
 
+config BR2_PACKAGE_BUILD_SYSTEMD
+	bool
+
 menuconfig BR2_PACKAGE_SYSTEMD
 	bool "systemd"
-	depends on BR2_INIT_SYSTEMD
+	depends on BR2_PACKAGE_BUILD_SYSTEMD
 	depends on !BR2_STATIC_LIBS # kmod
 	depends on BR2_TOOLCHAIN_HAS_THREADS # dbus
 	depends on BR2_USE_MMU # dbus
-	select BR2_PACKAGE_HAS_UDEV
-	select BR2_PACKAGE_DBUS # runtime dependency only
+	select BR2_PACKAGE_HAS_UDEV if BR2_INIT_SYSTEMD
+	select BR2_PACKAGE_DBUS if BR2_INIT_SYSTEMD # runtime dependency only
 	select BR2_PACKAGE_LIBCAP
 	select BR2_PACKAGE_UTIL_LINUX
-	select BR2_PACKAGE_UTIL_LINUX_LIBBLKID
+	select BR2_PACKAGE_UTIL_LINUX_LIBBLKID if BR2_INIT_SYSTEMD
 	select BR2_PACKAGE_UTIL_LINUX_LIBMOUNT
-	select BR2_PACKAGE_UTIL_LINUX_BINARIES
+	select BR2_PACKAGE_UTIL_LINUX_BINARIES if BR2_INIT_SYSTEMD
 	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
-	select BR2_PACKAGE_KMOD_TOOLS
-	select BR2_TARGET_TZ_INFO
-	select BR2_NEEDS_HOST_UTF8_LOCALE
+	select BR2_PACKAGE_UTIL_LINUX_NOLOGIN if BR2_INIT_SYSTEMD
+	select BR2_PACKAGE_UTIL_LINUX_FSCK if BR2_INIT_SYSTEMD
+	select BR2_PACKAGE_KMOD if BR2_INIT_SYSTEMD
+	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS if BR2_INIT_SYSTEMD # kmod-tools
+	select BR2_PACKAGE_KMOD_TOOLS if BR2_INIT_SYSTEMD
+	select BR2_TARGET_TZ_INFO if BR2_INIT_SYSTEMD
+	select BR2_NEEDS_HOST_UTF8_LOCALE if BR2_INIT_SYSTEMD
 	help
 	  systemd is a system and service manager for Linux,
 	  compatible with SysV and LSB init scripts. systemd provides
@@ -76,9 +79,11 @@ if BR2_PACKAGE_SYSTEMD
 
 config BR2_PACKAGE_PROVIDES_UDEV
 	default "systemd"
+	depends on BR2_INIT_SYSTEMD
 
 config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
 	bool "HTTP server for journal events"
+	depends on BR2_INIT_SYSTEMD
 	select BR2_PACKAGE_LIBMICROHTTPD
 	help
 	  systemd-journal-gatewayd serves journal events over the
@@ -89,6 +94,7 @@ config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
 
 config BR2_PACKAGE_SYSTEMD_BACKLIGHT
 	bool "enable backlight support"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-backlight is a service that restores the display
 	  backlight brightness at early boot and saves it at shutdown.
@@ -97,6 +103,7 @@ config BR2_PACKAGE_SYSTEMD_BACKLIGHT
 
 config BR2_PACKAGE_SYSTEMD_BINFMT
 	bool "enable binfmt tool"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-binfmt is an early boot service that registers
 	  additional binary formats for executables in the kernel.
@@ -105,6 +112,7 @@ config BR2_PACKAGE_SYSTEMD_BINFMT
 
 config BR2_PACKAGE_SYSTEMD_COREDUMP
 	bool "enable coredump hook"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-coredump can be used as a helper binary by the
 	  kernel when a user space program receives a fatal signal and
@@ -114,6 +122,7 @@ config BR2_PACKAGE_SYSTEMD_COREDUMP
 
 config BR2_PACKAGE_SYSTEMD_FIRSTBOOT
 	bool "enable firstboot support"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-firstboot initializes the most basic system settings
 	  interactively on the first boot.
@@ -122,6 +131,7 @@ config BR2_PACKAGE_SYSTEMD_FIRSTBOOT
 
 config BR2_PACKAGE_SYSTEMD_HIBERNATE
 	bool "enable hibernation support"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  When this features is enabled, additional tools and services
 	  are built to support suspending and resuming the system.
@@ -131,6 +141,7 @@ config BR2_PACKAGE_SYSTEMD_HIBERNATE
 config BR2_PACKAGE_SYSTEMD_HOSTNAMED
 	bool "enable hostname daemon"
 	default y
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-hostnamed is a system service that may be used as a
 	  mechanism to change the system's hostname.
@@ -140,6 +151,7 @@ config BR2_PACKAGE_SYSTEMD_HOSTNAMED
 config BR2_PACKAGE_SYSTEMD_HWDB
 	bool "enable hwdb installation"
 	default y
+	depends on BR2_INIT_SYSTEMD
 	help
 	  Enables hardware database installation to /usr/lib/udev/hwdb.d
 
@@ -150,6 +162,7 @@ config BR2_PACKAGE_SYSTEMD_HWDB
 
 config BR2_PACKAGE_SYSTEMD_IMPORTD
 	bool "enable import daemon"
+	depends on BR2_INIT_SYSTEMD
 	depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS # libgcrypt
 	select BR2_PACKAGE_LIBCURL
 	select BR2_PACKAGE_LIBGCRYPT
@@ -166,6 +179,7 @@ config BR2_PACKAGE_SYSTEMD_IMPORTD
 
 config BR2_PACKAGE_SYSTEMD_LOCALED
 	bool "enable locale daemon"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-localed is a system service that may be used as
 	  mechanism to change the system locale settings, as well as
@@ -175,6 +189,7 @@ config BR2_PACKAGE_SYSTEMD_LOCALED
 
 config BR2_PACKAGE_SYSTEMD_LOGIND
 	bool "enable login daemon"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-logind is a system service that manages user logins.
 
@@ -182,6 +197,7 @@ config BR2_PACKAGE_SYSTEMD_LOGIND
 
 config BR2_PACKAGE_SYSTEMD_MACHINED
 	bool "enable machine daemon"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-machined is a system service that keeps track of
 	  virtual machines and containers, and processes belonging to
@@ -192,6 +208,7 @@ config BR2_PACKAGE_SYSTEMD_MACHINED
 config BR2_PACKAGE_SYSTEMD_MYHOSTNAME
 	bool "enable myhostname NSS plugin"
 	default y
+	depends on BR2_INIT_SYSTEMD
 	help
 	  nss-myhostname is a plug-in module for the GNU Name Service
 	  Switch (NSS) functionality of the GNU C Library (glibc),
@@ -203,6 +220,7 @@ config BR2_PACKAGE_SYSTEMD_MYHOSTNAME
 config BR2_PACKAGE_SYSTEMD_NETWORKD
 	bool "enable network manager"
 	default y
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-networkd is a system service that manages networks.
 	  It detects and configures network devices as they appear, as
@@ -215,6 +233,7 @@ config BR2_PACKAGE_SYSTEMD_NETWORKD
 
 config BR2_PACKAGE_SYSTEMD_POLKIT
 	bool "enable polkit support"
+	depends on BR2_INIT_SYSTEMD
 	depends on BR2_TOOLCHAIN_USES_GLIBC # polkit
 	select BR2_PACKAGE_POLKIT
 	help
@@ -226,10 +245,12 @@ config BR2_PACKAGE_SYSTEMD_POLKIT
 	  http://wiki.freedesktop.org/www/Software/polkit/
 
 comment "polkit support needs a glibc toolchain"
+	depends on BR2_INIT_SYSTEMD
 	depends on !BR2_TOOLCHAIN_USES_GLIBC
 
 config BR2_PACKAGE_SYSTEMD_QUOTACHECK
 	bool "enable quotacheck tools"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-quotacheck is a service responsible for file system
 	  quota checks. It is run once at boot after all necessary
@@ -240,6 +261,7 @@ config BR2_PACKAGE_SYSTEMD_QUOTACHECK
 
 config BR2_PACKAGE_SYSTEMD_RANDOMSEED
 	bool "enable random-seed support"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-random-seed is a service that restores the random
 	  seed of the system at early boot and saves it at
@@ -251,6 +273,7 @@ config BR2_PACKAGE_SYSTEMD_RANDOMSEED
 config BR2_PACKAGE_SYSTEMD_RESOLVED
 	bool "enable resolve daemon"
 	default y
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-resolved is a system service that provides network
 	  name resolution to local applications. It implements a
@@ -261,6 +284,7 @@ config BR2_PACKAGE_SYSTEMD_RESOLVED
 
 config BR2_PACKAGE_SYSTEMD_RFKILL
 	bool "enable rfkill tools"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-rfkill is a service that restores the RF kill switch
 	  state at early boot and saves it at shutdown.
@@ -269,6 +293,7 @@ config BR2_PACKAGE_SYSTEMD_RFKILL
 
 config BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT
 	bool "enable SMACK support"
+	depends on BR2_INIT_SYSTEMD
 	select BR2_PACKAGE_ATTR
 	select BR2_PACKAGE_SMACK
 	help
@@ -283,6 +308,7 @@ config BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT
 
 config BR2_PACKAGE_SYSTEMD_SYSUSERS
 	bool "enable sysusers support"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-sysusers creates system users and groups, based on
 	  the file format and location specified in sysusers.d(5).
@@ -292,6 +318,7 @@ config BR2_PACKAGE_SYSTEMD_SYSUSERS
 config BR2_PACKAGE_SYSTEMD_TIMEDATED
 	bool "enable timedate daemon"
 	default y
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-timedated is a system service that may be used as a
 	  mechanism to change the system clock and timezone, as well
@@ -302,6 +329,7 @@ config BR2_PACKAGE_SYSTEMD_TIMEDATED
 config BR2_PACKAGE_SYSTEMD_TIMESYNCD
 	bool "enable timesync daemon"
 	default y
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-timesyncd is a service that may be used to
 	  synchronize the local system clock with a Network Time
@@ -315,6 +343,7 @@ config BR2_PACKAGE_SYSTEMD_TIMESYNCD
 config BR2_PACKAGE_SYSTEMD_TMPFILES
 	bool "enable tmpfiles support"
 	default y
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-tmpfiles creates, deletes, and cleans up volatile
 	  and temporary files and directories, based on the
@@ -325,6 +354,7 @@ config BR2_PACKAGE_SYSTEMD_TMPFILES
 
 config BR2_PACKAGE_SYSTEMD_VCONSOLE
 	bool "enable vconsole tool"
+	depends on BR2_INIT_SYSTEMD
 	help
 	  systemd-vconsole-setup is an early boot service that
 	  configures the virtual console font and console keymap.
package/systemd/buildroot.conf new file +3 -0
new file mode 100644
index 0000000..16d4d85
@@ -0,0 +1,3 @@
+title	Buildroot
+linux	/bzImage
+options	root=/dev/sda2 rootwait console=tty1
package/systemd/loader.conf new file +2 -0
new file mode 100644
index 0000000..93b77b8
@@ -0,0 +1,2 @@
+timeout 3
+default buildroot
package/systemd/systemd.mk +50 -3
index e53f0b6..b7234be 100644
@@ -8,15 +8,31 @@ SYSTEMD_VERSION = 239
 SYSTEMD_SITE = $(call github,systemd,systemd,v$(SYSTEMD_VERSION))
 SYSTEMD_LICENSE = LGPL-2.1+, GPL-2.0+ (udev), Public Domain (few source files, see README)
 SYSTEMD_LICENSE_FILES = LICENSE.GPL2 LICENSE.LGPL2.1 README
+ifeq ($(BR2_INIT_SYSTEMD),y)
 SYSTEMD_INSTALL_STAGING = YES
+else
+SYSTEMD_INSTALL_STAGING = NO
+SYSTEMD_INSTALL_TARGET = NO
+endif
+ifeq ($(BR2_TARGET_SYSTEMD_BOOT),y)
+SYSTEMD_INSTALL_IMAGES = YES
+ifeq ($(BR2_i386),y)
+SYSTEMD_IMGARCH = ia32
+else ifeq ($(BR2_x86_64),y)
+SYSTEMD_IMGARCH = x64
+endif
+endif
 SYSTEMD_DEPENDENCIES = \
 	host-gperf \
 	host-intltool \
-	kmod \
 	libcap \
 	util-linux
 
+ifeq ($(BR2_INIT_SYSTEMD),y)
+SYSTEMD_DEPENDENCIES += \
+	kmod
 SYSTEMD_PROVIDES = udev
+endif
 
 SYSTEMD_CONF_OPTS += \
 	-Drootlibdir='/usr/lib' \
@@ -24,8 +40,6 @@ SYSTEMD_CONF_OPTS += \
 	-Dman=false \
 	-Dima=false \
 	-Dlibcryptsetup=false \
-	-Defi=false \
-	-Dgnu-efi=false \
 	-Dldconfig=false \
 	-Ddefault-dnssec=no \
 	-Dtests=false \
@@ -404,4 +418,37 @@ endef
 SYSTEMD_CONF_ENV = $(HOST_UTF8_LOCALE_ENV)
 SYSTEMD_NINJA_ENV = $(HOST_UTF8_LOCALE_ENV)
 
+ifeq ($(BR2_TARGET_SYSTEMD_BOOT),y)
+SYSTEMD_DEPENDENCIES += gnu-efi
+SYSTEMD_CONF_OPTS += \
+	-Defi=true \
+	-Dgnu-efi=true \
+	-Defi-cc=$(TARGET_CC) \
+	-Defi-ld=$(TARGET_LD) \
+	-Defi-libdir=$(STAGING_DIR)/usr/lib \
+	-Defi-ldsdir=$(STAGING_DIR)/usr/lib \
+	-Defi-includedir=$(STAGING_DIR)/usr/include/efi \
+
+ifneq ($(BR2_INIT_SYSTEMD),y)
+define SYSTEMD_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(SYSTEMD_NINJA_ENV) \
+		$(NINJA) $(NINJA_OPTS) -C $(SYSTEMD_SRCDIR)/build \
+		src/boot/efi/{systemd-boot$(SYSTEMD_IMGARCH).efi,linux$(SYSTEMD_IMGARCH).efi.stub}
+endef
+endif
+
+define SYSTEMD_INSTALL_IMAGES_CMDS
+	$(INSTALL) -D -m 0644 $(@D)/build/src/boot/efi/systemd-boot$(SYSTEMD_IMGARCH).efi \
+		$(BINARIES_DIR)/efi-part/EFI/BOOT/boot$(SYSTEMD_IMGARCH).efi
+	echo "boot$(SYSTEMD_IMGARCH).efi" > \
+		$(BINARIES_DIR)/efi-part/startup.nsh
+	$(INSTALL) -D -m 0644 $(SYSTEMD_PKGDIR)/loader.conf \
+		$(BINARIES_DIR)/efi-part/loader/loader.conf
+	$(INSTALL) -D -m 0644 $(SYSTEMD_PKGDIR)/buildroot.conf \
+		$(BINARIES_DIR)/efi-part/loader/entries/buildroot.conf
+endef
+else
+SYSTEMD_CONF_OPTS += -Defi=false -Dgnu-efi=false
+endif
+
 $(eval $(meson-package))
system/Config.in +1 -0
index 9e34f11..773a2cc 100644
@@ -133,6 +133,7 @@ config BR2_INIT_SYSTEMD
 	depends on !BR2_STATIC_LIBS
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10
 	select BR2_ROOTFS_MERGED_USR
+	select BR2_PACKAGE_BUILD_SYSTEMD
 	select BR2_PACKAGE_SYSTEMD
 
 comment "systemd needs a glibc toolchain w/ SSP, headers >= 3.10"
Signature · 1 line
2.7.4
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH v2 1/1 boot/systemd-boot: new package

Quoted 6 lines · Yann E. MORIN

James, All,

On 2018-12-14 19:42 +0800, james.hilliard1 at gmail.com spake thusly:

Quoted 2 lines

From: James Hilliard <[email protected]>

Quoted 8 lines
Quoted 1 line

This is essentially the successor to gummiboot.

First, this patch is huge, it does many tricky things, so the commit log can't be that short. You need to explain in the commit log what this patch does, why it needs to do it.

Second, the patch basically does three different things:
- change stuff in the meson-packae infrastructure

Yeah, this can def be split off, it's to fix an issue with meson requiring cpu family to be normalized(it only seems to be an issue for meson.build files that have cpu family detection however).

Quoted 2 lines

- change stuff in the systemd package
- adds a new virtual boot package

These kind of go together, all the changes in the systemd package are essentially adding systemd-boot package infrastructure.

Quoted 9 lines

This is a good indication that there should be _at least_ three patches, one for each of the above changes, each with a detailed commit log that explains what the change does and why it has to be done). Patches should do a complete change of their own, yet be atomic (i.e. can't be split). Here it is obvious that the patch can be split. And if it can't then you have to say why in the commit log, again.

Third, the new virtual boot package has no provider, so that's a indication that something is wrong with that patch.

So the virtual package is really just there so that there's an entry in the boot menu instead of packages for systemd-boot.

Quoted 8 lines

You need to clearly explain what is going on here, because all I can think is, why can't we simply build the systemd-boot component of systemd directly from the systemd package itself? (Yeah, I think I know the answer, but you have to explain it in the commit log. And no, it can't just be "but this is a bootloader, it has to have an entry in boot/": we have other bootloaders elsewhere, e.g. rpi-firmware, which do not live in boot/ (to my own dismay, but that's another story.))

I did it this way so that it's clear that systemd-boot can be built without a systemd init system. Would it make sense to move all bootloaders to be under the boot menu?

Quoted 541 lines

Regards,
Yann E. MORIN.

Quoted 527 lines
---
 DEVELOPERS                              |  1 +
 boot/Config.in                          |  1 +
 boot/systemd-boot/Config.in             | 23 ++++++++++++++
 boot/systemd-boot/systemd-boot.mk       |  7 +++++
 package/meson/cross-compilation.conf.in |  1 +
 package/meson/meson.mk                  | 41 ++++++++++++++++++++++++-
 package/systemd/Config.in               | 54 +++++++++++++++++++++++++--------
 package/systemd/buildroot.conf          |  3 ++
 package/systemd/loader.conf             |  2 ++
 package/systemd/systemd.mk              | 53 ++++++++++++++++++++++++++++++--
 system/Config.in                        |  1 +
 11 files changed, 171 insertions(+), 16 deletions(-)
 create mode 100644 boot/systemd-boot/Config.in
 create mode 100644 boot/systemd-boot/systemd-boot.mk
 create mode 100644 package/systemd/buildroot.conf
 create mode 100644 package/systemd/loader.conf
DEVELOPERS +1 -0
index 4192681..93599fe 100644
@@ -995,6 +995,7 @@ F:        configs/pine64_defconfig
 F:   configs/pine64_sopine_defconfig
 
 N:   James Hilliard <[email protected]>
+F:   boot/systemd-boot/
 F:   package/python-aiodns/
 F:   package/python-aiohttp/
 F:   package/python-aiohttp-jinja2/
boot/Config.in +1 -0
index 8e0c8e5..5b7f606 100644
@@ -16,6 +16,7 @@ source "boot/mxs-bootlets/Config.in"
 source "boot/riscv-pk/Config.in"
 source "boot/s500-bootloader/Config.in"
 source "boot/syslinux/Config.in"
+source "boot/systemd-boot/Config.in"
 source "boot/ts4800-mbrboot/Config.in"
 source "boot/uboot/Config.in"
 source "boot/vexpress-firmware/Config.in"
boot/systemd-boot/Config.in new file +23 -0
new file mode 100644
index 0000000..7c64cef
@@ -0,0 +1,23 @@
+config BR2_TARGET_SYSTEMD_BOOT
+     bool "systemd-boot"
+     depends on BR2_i386 || BR2_x86_64
+     select BR2_PACKAGE_BUILD_SYSTEMD
+     select BR2_PACKAGE_SYSTEMD
+     select BR2_PACKAGE_GNU_EFI
+     help
+       systemd-boot is a simple UEFI boot manager which executes
+       configured EFI images. The default entry is selected by a
+       configured pattern (glob) or an on-screen menu.
+
+       systemd-boot operates on the EFI System Partition (ESP)
+       only. Configuration file fragments, kernels, initrds, other
+       EFI images need to reside on the ESP. Linux kernels need to
+       be built with CONFIG_EFI_STUB to be able to be directly
+       executed as an EFI image.
+
+       See the Grub2 help text for details on preparing an EFI
+       capable disk image using systemd-boot: the instructions are
+       exactly the same, except that the systemd-boot configuration
+       files will be located in /loader/ inside the EFI partition.
+
+       https://www.freedesktop.org/wiki/Software/systemd/systemd-boot/
\ No newline at end of file
boot/systemd-boot/systemd-boot.mk new file +7 -0
new file mode 100644
index 0000000..5854024
@@ -0,0 +1,7 @@
+################################################################################
+#
+# systemd-boot
+#
+################################################################################
+
+$(eval $(virtual-package))
package/meson/cross-compilation.conf.in +1 -0
index 0eec740..fc8e27f 100644
@@ -11,6 +11,7 @@ strip = '@TARGET_CROSS at strip'
 pkgconfig = '@HOST_DIR@/usr/bin/pkg-config'
 
 [properties]
+needs_exe_wrapper = true
 c_args = [@TARGET_CFLAGS@]
 c_link_args = [@TARGET_LDFLAGS@]
 cpp_args = [@TARGET_CXXFLAGS@]
package/meson/meson.mk +40 -1
index e1675c2..d9ad2fc 100644
@@ -15,6 +15,45 @@ HOST_MESON_NEEDS_HOST_PYTHON = python3
 
 HOST_MESON_TARGET_ENDIAN = $(call LOWERCASE,$(BR2_ENDIAN))
 HOST_MESON_TARGET_CPU = $(GCC_TARGET_CPU)
+ifeq ($(BR2_arcle),y)
+HOST_MESON_TARGET_CPU_FAMILY = arc
+else ifeq ($(BR2_arceb),y)
+HOST_MESON_TARGET_CPU_FAMILY = arc
+else ifeq ($(BR2_arm),y)
+HOST_MESON_TARGET_CPU_FAMILY = arm
+else ifeq ($(BR2_armeb),y)
+HOST_MESON_TARGET_CPU_FAMILY = arm
+else ifeq ($(BR2_aarch64),y)
+HOST_MESON_TARGET_CPU_FAMILY = aarch64
+else ifeq ($(BR2_aarch64_be),y)
+HOST_MESON_TARGET_CPU_FAMILY = aarch64
+else ifeq ($(BR2_i386),y)
+HOST_MESON_TARGET_CPU_FAMILY = x86
+else ifeq ($(BR2_mips),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips
+else ifeq ($(BR2_mipsel),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips
+else ifeq ($(BR2_mips64),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips64
+else ifeq ($(BR2_mips64el),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips64
+else ifeq ($(BR2_powerpc),y)
+HOST_MESON_TARGET_CPU_FAMILY = ppc
+else ifeq ($(BR2_powerpc64),y)
+HOST_MESON_TARGET_CPU_FAMILY = ppc64
+else ifeq ($(BR2_powerpc64le),y)
+HOST_MESON_TARGET_CPU_FAMILY = ppc64
+else ifeq ($(BR2_riscv),y)
+HOST_MESON_TARGET_CPU_FAMILY = riscv32
+else ifeq ($(BR2_sparc),y)
+HOST_MESON_TARGET_CPU_FAMILY = sparc
+else ifeq ($(BR2_sparc64),y)
+HOST_MESON_TARGET_CPU_FAMILY = sparc64
+else ifeq ($(BR2_x86_64),y)
+HOST_MESON_TARGET_CPU_FAMILY = x86_64
+else
+HOST_MESON_TARGET_CPU_FAMILY = $(ARCH)
+endif
 
 HOST_MESON_SED_CFLAGS = $(if $(TARGET_CFLAGS),`printf '"%s"$(comma) ' $(TARGET_CFLAGS)`)
 HOST_MESON_SED_LDFLAGS = $(if $(TARGET_LDFLAGS),`printf '"%s"$(comma) ' $(TARGET_LDFLAGS)`)
@@ -23,7 +62,7 @@ HOST_MESON_SED_CXXFLAGS = $(if $(TARGET_CXXFLAGS),`printf '"%s"$(comma) ' $(TARG
 define HOST_MESON_INSTALL_CROSS_CONF
      mkdir -p $(HOST_DIR)/etc/meson
      sed -e "s%@TARGET_CROSS@%$(TARGET_CROSS)%g" \
-         -e "s%@TARGET_ARCH@%$(ARCH)%g" \
+         -e "s%@TARGET_ARCH@%$(HOST_MESON_TARGET_CPU_FAMILY)%g" \
          -e "s%@TARGET_CPU@%$(HOST_MESON_TARGET_CPU)%g" \
          -e "s%@TARGET_ENDIAN@%$(HOST_MESON_TARGET_ENDIAN)%g" \
          -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)%g" \
package/systemd/Config.in +42 -12
index 25f322e..c8fa786 100644
@@ -7,27 +7,30 @@ config BR2_PACKAGE_SYSTEMD_ARCH_SUPPORTS
              BR2_sh4a || BR2_sh4aeb || BR2_sparc || BR2_x86_64 || \
              BR2_aarch64 || BR2_m68k || BR2_arc
 
+config BR2_PACKAGE_BUILD_SYSTEMD
+     bool
+
 menuconfig BR2_PACKAGE_SYSTEMD
      bool "systemd"
-     depends on BR2_INIT_SYSTEMD
+     depends on BR2_PACKAGE_BUILD_SYSTEMD
      depends on !BR2_STATIC_LIBS # kmod
      depends on BR2_TOOLCHAIN_HAS_THREADS # dbus
      depends on BR2_USE_MMU # dbus
-     select BR2_PACKAGE_HAS_UDEV
-     select BR2_PACKAGE_DBUS # runtime dependency only
+     select BR2_PACKAGE_HAS_UDEV if BR2_INIT_SYSTEMD
+     select BR2_PACKAGE_DBUS if BR2_INIT_SYSTEMD # runtime dependency only
      select BR2_PACKAGE_LIBCAP
      select BR2_PACKAGE_UTIL_LINUX
-     select BR2_PACKAGE_UTIL_LINUX_LIBBLKID
+     select BR2_PACKAGE_UTIL_LINUX_LIBBLKID if BR2_INIT_SYSTEMD
      select BR2_PACKAGE_UTIL_LINUX_LIBMOUNT
-     select BR2_PACKAGE_UTIL_LINUX_BINARIES
+     select BR2_PACKAGE_UTIL_LINUX_BINARIES if BR2_INIT_SYSTEMD
      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
-     select BR2_PACKAGE_KMOD_TOOLS
-     select BR2_TARGET_TZ_INFO
-     select BR2_NEEDS_HOST_UTF8_LOCALE
+     select BR2_PACKAGE_UTIL_LINUX_NOLOGIN if BR2_INIT_SYSTEMD
+     select BR2_PACKAGE_UTIL_LINUX_FSCK if BR2_INIT_SYSTEMD
+     select BR2_PACKAGE_KMOD if BR2_INIT_SYSTEMD
+     select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS if BR2_INIT_SYSTEMD # kmod-tools
+     select BR2_PACKAGE_KMOD_TOOLS if BR2_INIT_SYSTEMD
+     select BR2_TARGET_TZ_INFO if BR2_INIT_SYSTEMD
+     select BR2_NEEDS_HOST_UTF8_LOCALE if BR2_INIT_SYSTEMD
      help
        systemd is a system and service manager for Linux,
        compatible with SysV and LSB init scripts. systemd provides
@@ -76,9 +79,11 @@ if BR2_PACKAGE_SYSTEMD
 
 config BR2_PACKAGE_PROVIDES_UDEV
      default "systemd"
+     depends on BR2_INIT_SYSTEMD
 
 config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
      bool "HTTP server for journal events"
+     depends on BR2_INIT_SYSTEMD
      select BR2_PACKAGE_LIBMICROHTTPD
      help
        systemd-journal-gatewayd serves journal events over the
@@ -89,6 +94,7 @@ config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
 
 config BR2_PACKAGE_SYSTEMD_BACKLIGHT
      bool "enable backlight support"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-backlight is a service that restores the display
        backlight brightness at early boot and saves it at shutdown.
@@ -97,6 +103,7 @@ config BR2_PACKAGE_SYSTEMD_BACKLIGHT
 
 config BR2_PACKAGE_SYSTEMD_BINFMT
      bool "enable binfmt tool"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-binfmt is an early boot service that registers
        additional binary formats for executables in the kernel.
@@ -105,6 +112,7 @@ config BR2_PACKAGE_SYSTEMD_BINFMT
 
 config BR2_PACKAGE_SYSTEMD_COREDUMP
      bool "enable coredump hook"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-coredump can be used as a helper binary by the
        kernel when a user space program receives a fatal signal and
@@ -114,6 +122,7 @@ config BR2_PACKAGE_SYSTEMD_COREDUMP
 
 config BR2_PACKAGE_SYSTEMD_FIRSTBOOT
      bool "enable firstboot support"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-firstboot initializes the most basic system settings
        interactively on the first boot.
@@ -122,6 +131,7 @@ config BR2_PACKAGE_SYSTEMD_FIRSTBOOT
 
 config BR2_PACKAGE_SYSTEMD_HIBERNATE
      bool "enable hibernation support"
+     depends on BR2_INIT_SYSTEMD
      help
        When this features is enabled, additional tools and services
        are built to support suspending and resuming the system.
@@ -131,6 +141,7 @@ config BR2_PACKAGE_SYSTEMD_HIBERNATE
 config BR2_PACKAGE_SYSTEMD_HOSTNAMED
      bool "enable hostname daemon"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-hostnamed is a system service that may be used as a
        mechanism to change the system's hostname.
@@ -140,6 +151,7 @@ config BR2_PACKAGE_SYSTEMD_HOSTNAMED
 config BR2_PACKAGE_SYSTEMD_HWDB
      bool "enable hwdb installation"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        Enables hardware database installation to /usr/lib/udev/hwdb.d
 
@@ -150,6 +162,7 @@ config BR2_PACKAGE_SYSTEMD_HWDB
 
 config BR2_PACKAGE_SYSTEMD_IMPORTD
      bool "enable import daemon"
+     depends on BR2_INIT_SYSTEMD
      depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS # libgcrypt
      select BR2_PACKAGE_LIBCURL
      select BR2_PACKAGE_LIBGCRYPT
@@ -166,6 +179,7 @@ config BR2_PACKAGE_SYSTEMD_IMPORTD
 
 config BR2_PACKAGE_SYSTEMD_LOCALED
      bool "enable locale daemon"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-localed is a system service that may be used as
        mechanism to change the system locale settings, as well as
@@ -175,6 +189,7 @@ config BR2_PACKAGE_SYSTEMD_LOCALED
 
 config BR2_PACKAGE_SYSTEMD_LOGIND
      bool "enable login daemon"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-logind is a system service that manages user logins.
 
@@ -182,6 +197,7 @@ config BR2_PACKAGE_SYSTEMD_LOGIND
 
 config BR2_PACKAGE_SYSTEMD_MACHINED
      bool "enable machine daemon"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-machined is a system service that keeps track of
        virtual machines and containers, and processes belonging to
@@ -192,6 +208,7 @@ config BR2_PACKAGE_SYSTEMD_MACHINED
 config BR2_PACKAGE_SYSTEMD_MYHOSTNAME
      bool "enable myhostname NSS plugin"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        nss-myhostname is a plug-in module for the GNU Name Service
        Switch (NSS) functionality of the GNU C Library (glibc),
@@ -203,6 +220,7 @@ config BR2_PACKAGE_SYSTEMD_MYHOSTNAME
 config BR2_PACKAGE_SYSTEMD_NETWORKD
      bool "enable network manager"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-networkd is a system service that manages networks.
        It detects and configures network devices as they appear, as
@@ -215,6 +233,7 @@ config BR2_PACKAGE_SYSTEMD_NETWORKD
 
 config BR2_PACKAGE_SYSTEMD_POLKIT
      bool "enable polkit support"
+     depends on BR2_INIT_SYSTEMD
      depends on BR2_TOOLCHAIN_USES_GLIBC # polkit
      select BR2_PACKAGE_POLKIT
      help
@@ -226,10 +245,12 @@ config BR2_PACKAGE_SYSTEMD_POLKIT
        http://wiki.freedesktop.org/www/Software/polkit/
 
 comment "polkit support needs a glibc toolchain"
+     depends on BR2_INIT_SYSTEMD
      depends on !BR2_TOOLCHAIN_USES_GLIBC
 
 config BR2_PACKAGE_SYSTEMD_QUOTACHECK
      bool "enable quotacheck tools"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-quotacheck is a service responsible for file system
        quota checks. It is run once at boot after all necessary
@@ -240,6 +261,7 @@ config BR2_PACKAGE_SYSTEMD_QUOTACHECK
 
 config BR2_PACKAGE_SYSTEMD_RANDOMSEED
      bool "enable random-seed support"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-random-seed is a service that restores the random
        seed of the system at early boot and saves it at
@@ -251,6 +273,7 @@ config BR2_PACKAGE_SYSTEMD_RANDOMSEED
 config BR2_PACKAGE_SYSTEMD_RESOLVED
      bool "enable resolve daemon"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-resolved is a system service that provides network
        name resolution to local applications. It implements a
@@ -261,6 +284,7 @@ config BR2_PACKAGE_SYSTEMD_RESOLVED
 
 config BR2_PACKAGE_SYSTEMD_RFKILL
      bool "enable rfkill tools"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-rfkill is a service that restores the RF kill switch
        state at early boot and saves it at shutdown.
@@ -269,6 +293,7 @@ config BR2_PACKAGE_SYSTEMD_RFKILL
 
 config BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT
      bool "enable SMACK support"
+     depends on BR2_INIT_SYSTEMD
      select BR2_PACKAGE_ATTR
      select BR2_PACKAGE_SMACK
      help
@@ -283,6 +308,7 @@ config BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT
 
 config BR2_PACKAGE_SYSTEMD_SYSUSERS
      bool "enable sysusers support"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-sysusers creates system users and groups, based on
        the file format and location specified in sysusers.d(5).
@@ -292,6 +318,7 @@ config BR2_PACKAGE_SYSTEMD_SYSUSERS
 config BR2_PACKAGE_SYSTEMD_TIMEDATED
      bool "enable timedate daemon"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-timedated is a system service that may be used as a
        mechanism to change the system clock and timezone, as well
@@ -302,6 +329,7 @@ config BR2_PACKAGE_SYSTEMD_TIMEDATED
 config BR2_PACKAGE_SYSTEMD_TIMESYNCD
      bool "enable timesync daemon"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-timesyncd is a service that may be used to
        synchronize the local system clock with a Network Time
@@ -315,6 +343,7 @@ config BR2_PACKAGE_SYSTEMD_TIMESYNCD
 config BR2_PACKAGE_SYSTEMD_TMPFILES
      bool "enable tmpfiles support"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-tmpfiles creates, deletes, and cleans up volatile
        and temporary files and directories, based on the
@@ -325,6 +354,7 @@ config BR2_PACKAGE_SYSTEMD_TMPFILES
 
 config BR2_PACKAGE_SYSTEMD_VCONSOLE
      bool "enable vconsole tool"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-vconsole-setup is an early boot service that
        configures the virtual console font and console keymap.
package/systemd/buildroot.conf new file +3 -0
new file mode 100644
index 0000000..16d4d85
@@ -0,0 +1,3 @@
+title        Buildroot
+linux        /bzImage
+options      root=/dev/sda2 rootwait console=tty1
package/systemd/loader.conf new file +2 -0
new file mode 100644
index 0000000..93b77b8
@@ -0,0 +1,2 @@
+timeout 3
+default buildroot
package/systemd/systemd.mk +50 -3
index e53f0b6..b7234be 100644
@@ -8,15 +8,31 @@ SYSTEMD_VERSION = 239
 SYSTEMD_SITE = $(call github,systemd,systemd,v$(SYSTEMD_VERSION))
 SYSTEMD_LICENSE = LGPL-2.1+, GPL-2.0+ (udev), Public Domain (few source files, see README)
 SYSTEMD_LICENSE_FILES = LICENSE.GPL2 LICENSE.LGPL2.1 README
+ifeq ($(BR2_INIT_SYSTEMD),y)
 SYSTEMD_INSTALL_STAGING = YES
+else
+SYSTEMD_INSTALL_STAGING = NO
+SYSTEMD_INSTALL_TARGET = NO
+endif
+ifeq ($(BR2_TARGET_SYSTEMD_BOOT),y)
+SYSTEMD_INSTALL_IMAGES = YES
+ifeq ($(BR2_i386),y)
+SYSTEMD_IMGARCH = ia32
+else ifeq ($(BR2_x86_64),y)
+SYSTEMD_IMGARCH = x64
+endif
+endif
 SYSTEMD_DEPENDENCIES = \
      host-gperf \
      host-intltool \
-     kmod \
      libcap \
      util-linux
 
+ifeq ($(BR2_INIT_SYSTEMD),y)
+SYSTEMD_DEPENDENCIES += \
+     kmod
 SYSTEMD_PROVIDES = udev
+endif
 
 SYSTEMD_CONF_OPTS += \
      -Drootlibdir='/usr/lib' \
@@ -24,8 +40,6 @@ SYSTEMD_CONF_OPTS += \
      -Dman=false \
      -Dima=false \
      -Dlibcryptsetup=false \
-     -Defi=false \
-     -Dgnu-efi=false \
      -Dldconfig=false \
      -Ddefault-dnssec=no \
      -Dtests=false \
@@ -404,4 +418,37 @@ endef
 SYSTEMD_CONF_ENV = $(HOST_UTF8_LOCALE_ENV)
 SYSTEMD_NINJA_ENV = $(HOST_UTF8_LOCALE_ENV)
 
+ifeq ($(BR2_TARGET_SYSTEMD_BOOT),y)
+SYSTEMD_DEPENDENCIES += gnu-efi
+SYSTEMD_CONF_OPTS += \
+     -Defi=true \
+     -Dgnu-efi=true \
+     -Defi-cc=$(TARGET_CC) \
+     -Defi-ld=$(TARGET_LD) \
+     -Defi-libdir=$(STAGING_DIR)/usr/lib \
+     -Defi-ldsdir=$(STAGING_DIR)/usr/lib \
+     -Defi-includedir=$(STAGING_DIR)/usr/include/efi \
+
+ifneq ($(BR2_INIT_SYSTEMD),y)
+define SYSTEMD_BUILD_CMDS
+     $(TARGET_MAKE_ENV) $(SYSTEMD_NINJA_ENV) \
+             $(NINJA) $(NINJA_OPTS) -C $(SYSTEMD_SRCDIR)/build \
+             src/boot/efi/{systemd-boot$(SYSTEMD_IMGARCH).efi,linux$(SYSTEMD_IMGARCH).efi.stub}
+endef
+endif
+
+define SYSTEMD_INSTALL_IMAGES_CMDS
+     $(INSTALL) -D -m 0644 $(@D)/build/src/boot/efi/systemd-boot$(SYSTEMD_IMGARCH).efi \
+             $(BINARIES_DIR)/efi-part/EFI/BOOT/boot$(SYSTEMD_IMGARCH).efi
+     echo "boot$(SYSTEMD_IMGARCH).efi" > \
+             $(BINARIES_DIR)/efi-part/startup.nsh
+     $(INSTALL) -D -m 0644 $(SYSTEMD_PKGDIR)/loader.conf \
+             $(BINARIES_DIR)/efi-part/loader/loader.conf
+     $(INSTALL) -D -m 0644 $(SYSTEMD_PKGDIR)/buildroot.conf \
+             $(BINARIES_DIR)/efi-part/loader/entries/buildroot.conf
+endef
+else
+SYSTEMD_CONF_OPTS += -Defi=false -Dgnu-efi=false
+endif
+
 $(eval $(meson-package))
system/Config.in +1 -1
index 9e34f11..773a2cc 100644
@@ -133,6 +133,7 @@ config BR2_INIT_SYSTEMD
      depends on !BR2_STATIC_LIBS
      depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10
      select BR2_ROOTFS_MERGED_USR
+     select BR2_PACKAGE_BUILD_SYSTEMD
      select BR2_PACKAGE_SYSTEMD
 
 comment "systemd needs a glibc toolchain w/ SSP, headers >= 3.10"
--
Quoted 2 lines

2.7.4

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |

'------------------------------^-------^------------------^--------------------'

#3 lore raw

PATCH v2 1/1 boot/systemd-boot: new package

James, All,

On 2018-12-15 02:12 -0700, James Hilliard spake thusly:

Quoted 10 lines · Yann E. MORIN
Quoted 9 lines

On 2018-12-14 19:42 +0800, james.hilliard1 at gmail.com spake thusly:

Quoted 3 lines

From: James Hilliard <[email protected]>

This is essentially the successor to gummiboot.

First, this patch is huge, it does many tricky things, so the commit log can't be that short. You need to explain in the commit log what this patch does, why it needs to do it.

Quoted 5 lines
Quoted 2 lines

Second, the patch basically does three different things:
- change stuff in the meson-packae infrastructure

Yeah, this can def be split off, it's to fix an issue with meson requiring cpu family to be normalized(it only seems to be an issue for meson.build files that have cpu family detection however).

Then just submit it as a separate patch of its own.

If this change was needed because of systemd-boot, then you can send a patch series to make it explicit that they are part of a same job, with the front patches needed by later patches in the series.

Quoted 4 lines
Quoted 2 lines

- change stuff in the systemd package
- adds a new virtual boot package

These kind of go together, all the changes in the systemd package are essentially adding systemd-boot package infrastructure.

No, sorry, I don't buy it. You can do changes in a package in a patch, that paves the way for another patch to use those changes.

In this case (but read below [*]), a first patch would change systemd so that it can be built without being the init system; then a second patch would add systemd-boot, that relies on building systemd even if it is not an init system.

Quoted 11 lines
Quoted 9 lines

This is a good indication that there should be _at least_ three patches, one for each of the above changes, each with a detailed commit log that explains what the change does and why it has to be done). Patches should do a complete change of their own, yet be atomic (i.e. can't be split). Here it is obvious that the patch can be split. And if it can't then you have to say why in the commit log, again.

Third, the new virtual boot package has no provider, so that's a indication that something is wrong with that patch.

So the virtual package is really just there so that there's an entry in the boot menu instead of packages for systemd-boot.

[*] Sorry, but I am still not convinced that we need all that complexity and why we can't just build systemd-boot as yet anotehr component of systemd *in* the systemd package, i.e. in package/systemd/systemd.mk, like we do for the other components (e.g. systemd-networkd or -resolved, etc...)

Quoted 9 lines
Quoted 7 lines

You need to clearly explain what is going on here, because all I can think is, why can't we simply build the systemd-boot component of systemd directly from the systemd package itself? (Yeah, I think I know the answer, but you have to explain it in the commit log. And no, it can't just be "but this is a bootloader, it has to have an entry in boot/": we have other bootloaders elsewhere, e.g. rpi-firmware, which do not live in boot/ (to my own dismay, but that's another story.))

I did it this way so that it's clear that systemd-boot can be built without a systemd init system.

There, _that_ is the reason for all this complexity.

So, let me suggest two alternative options that avoid all this mess:

1- make systemd-boot available only for systemd-based init,

2- just do a systemd-boot package (in boot/) that is a whole package on
its own, and just happens to build just the systemd-boot part of systemd.

I would very much favour the first option, because it is very simple, as it just requires a *few* tweaks in the existing sytemd.mk, i.e. basically:

    ifeq ($()BR2_PACKAGES_SYSTEMD_BOOT,y)
    SYSTEMD_CONF_OPTS += \
        -Defi=true \
        -Dgnu-efi=true \
        -Dcc-efi=blabla \
        [...]
    else
    SYSTEMD_CONF_OPTS += -Defi=false -Dgnu-efi=false
    endif

Also, I wonder if it ever makes sense to provide systemd-boot to non-systemd init systems to begin with.

Baring that, option 2 is pretty simple as well. It's a separate package that just happens to share its source code with another one, like we have with mesa3d and mesa3d-headers (just as an example).

Quoted 2 lines

Would it make sense to move all
bootloaders to be under the boot menu?

No, that ship has long sailed now, let's not revisit this.

Regards,
Yann E. MORIN.

Quoted 541 lines
Quoted 541 lines

Regards,
Yann E. MORIN.

Quoted 527 lines
---
 DEVELOPERS                              |  1 +
 boot/Config.in                          |  1 +
 boot/systemd-boot/Config.in             | 23 ++++++++++++++
 boot/systemd-boot/systemd-boot.mk       |  7 +++++
 package/meson/cross-compilation.conf.in |  1 +
 package/meson/meson.mk                  | 41 ++++++++++++++++++++++++-
 package/systemd/Config.in               | 54 +++++++++++++++++++++++++--------
 package/systemd/buildroot.conf          |  3 ++
 package/systemd/loader.conf             |  2 ++
 package/systemd/systemd.mk              | 53 ++++++++++++++++++++++++++++++--
 system/Config.in                        |  1 +
 11 files changed, 171 insertions(+), 16 deletions(-)
 create mode 100644 boot/systemd-boot/Config.in
 create mode 100644 boot/systemd-boot/systemd-boot.mk
 create mode 100644 package/systemd/buildroot.conf
 create mode 100644 package/systemd/loader.conf
DEVELOPERS +1 -0
index 4192681..93599fe 100644
@@ -995,6 +995,7 @@ F:        configs/pine64_defconfig
 F:   configs/pine64_sopine_defconfig
 
 N:   James Hilliard <[email protected]>
+F:   boot/systemd-boot/
 F:   package/python-aiodns/
 F:   package/python-aiohttp/
 F:   package/python-aiohttp-jinja2/
boot/Config.in +1 -0
index 8e0c8e5..5b7f606 100644
@@ -16,6 +16,7 @@ source "boot/mxs-bootlets/Config.in"
 source "boot/riscv-pk/Config.in"
 source "boot/s500-bootloader/Config.in"
 source "boot/syslinux/Config.in"
+source "boot/systemd-boot/Config.in"
 source "boot/ts4800-mbrboot/Config.in"
 source "boot/uboot/Config.in"
 source "boot/vexpress-firmware/Config.in"
boot/systemd-boot/Config.in new file +23 -0
new file mode 100644
index 0000000..7c64cef
@@ -0,0 +1,23 @@
+config BR2_TARGET_SYSTEMD_BOOT
+     bool "systemd-boot"
+     depends on BR2_i386 || BR2_x86_64
+     select BR2_PACKAGE_BUILD_SYSTEMD
+     select BR2_PACKAGE_SYSTEMD
+     select BR2_PACKAGE_GNU_EFI
+     help
+       systemd-boot is a simple UEFI boot manager which executes
+       configured EFI images. The default entry is selected by a
+       configured pattern (glob) or an on-screen menu.
+
+       systemd-boot operates on the EFI System Partition (ESP)
+       only. Configuration file fragments, kernels, initrds, other
+       EFI images need to reside on the ESP. Linux kernels need to
+       be built with CONFIG_EFI_STUB to be able to be directly
+       executed as an EFI image.
+
+       See the Grub2 help text for details on preparing an EFI
+       capable disk image using systemd-boot: the instructions are
+       exactly the same, except that the systemd-boot configuration
+       files will be located in /loader/ inside the EFI partition.
+
+       https://www.freedesktop.org/wiki/Software/systemd/systemd-boot/
\ No newline at end of file
boot/systemd-boot/systemd-boot.mk new file +7 -0
new file mode 100644
index 0000000..5854024
@@ -0,0 +1,7 @@
+################################################################################
+#
+# systemd-boot
+#
+################################################################################
+
+$(eval $(virtual-package))
package/meson/cross-compilation.conf.in +1 -0
index 0eec740..fc8e27f 100644
@@ -11,6 +11,7 @@ strip = '@TARGET_CROSS at strip'
 pkgconfig = '@HOST_DIR@/usr/bin/pkg-config'
 
 [properties]
+needs_exe_wrapper = true
 c_args = [@TARGET_CFLAGS@]
 c_link_args = [@TARGET_LDFLAGS@]
 cpp_args = [@TARGET_CXXFLAGS@]
package/meson/meson.mk +40 -1
index e1675c2..d9ad2fc 100644
@@ -15,6 +15,45 @@ HOST_MESON_NEEDS_HOST_PYTHON = python3
 
 HOST_MESON_TARGET_ENDIAN = $(call LOWERCASE,$(BR2_ENDIAN))
 HOST_MESON_TARGET_CPU = $(GCC_TARGET_CPU)
+ifeq ($(BR2_arcle),y)
+HOST_MESON_TARGET_CPU_FAMILY = arc
+else ifeq ($(BR2_arceb),y)
+HOST_MESON_TARGET_CPU_FAMILY = arc
+else ifeq ($(BR2_arm),y)
+HOST_MESON_TARGET_CPU_FAMILY = arm
+else ifeq ($(BR2_armeb),y)
+HOST_MESON_TARGET_CPU_FAMILY = arm
+else ifeq ($(BR2_aarch64),y)
+HOST_MESON_TARGET_CPU_FAMILY = aarch64
+else ifeq ($(BR2_aarch64_be),y)
+HOST_MESON_TARGET_CPU_FAMILY = aarch64
+else ifeq ($(BR2_i386),y)
+HOST_MESON_TARGET_CPU_FAMILY = x86
+else ifeq ($(BR2_mips),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips
+else ifeq ($(BR2_mipsel),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips
+else ifeq ($(BR2_mips64),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips64
+else ifeq ($(BR2_mips64el),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips64
+else ifeq ($(BR2_powerpc),y)
+HOST_MESON_TARGET_CPU_FAMILY = ppc
+else ifeq ($(BR2_powerpc64),y)
+HOST_MESON_TARGET_CPU_FAMILY = ppc64
+else ifeq ($(BR2_powerpc64le),y)
+HOST_MESON_TARGET_CPU_FAMILY = ppc64
+else ifeq ($(BR2_riscv),y)
+HOST_MESON_TARGET_CPU_FAMILY = riscv32
+else ifeq ($(BR2_sparc),y)
+HOST_MESON_TARGET_CPU_FAMILY = sparc
+else ifeq ($(BR2_sparc64),y)
+HOST_MESON_TARGET_CPU_FAMILY = sparc64
+else ifeq ($(BR2_x86_64),y)
+HOST_MESON_TARGET_CPU_FAMILY = x86_64
+else
+HOST_MESON_TARGET_CPU_FAMILY = $(ARCH)
+endif
 
 HOST_MESON_SED_CFLAGS = $(if $(TARGET_CFLAGS),`printf '"%s"$(comma) ' $(TARGET_CFLAGS)`)
 HOST_MESON_SED_LDFLAGS = $(if $(TARGET_LDFLAGS),`printf '"%s"$(comma) ' $(TARGET_LDFLAGS)`)
@@ -23,7 +62,7 @@ HOST_MESON_SED_CXXFLAGS = $(if $(TARGET_CXXFLAGS),`printf '"%s"$(comma) ' $(TARG
 define HOST_MESON_INSTALL_CROSS_CONF
      mkdir -p $(HOST_DIR)/etc/meson
      sed -e "s%@TARGET_CROSS@%$(TARGET_CROSS)%g" \
-         -e "s%@TARGET_ARCH@%$(ARCH)%g" \
+         -e "s%@TARGET_ARCH@%$(HOST_MESON_TARGET_CPU_FAMILY)%g" \
          -e "s%@TARGET_CPU@%$(HOST_MESON_TARGET_CPU)%g" \
          -e "s%@TARGET_ENDIAN@%$(HOST_MESON_TARGET_ENDIAN)%g" \
          -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)%g" \
package/systemd/Config.in +42 -12
index 25f322e..c8fa786 100644
@@ -7,27 +7,30 @@ config BR2_PACKAGE_SYSTEMD_ARCH_SUPPORTS
              BR2_sh4a || BR2_sh4aeb || BR2_sparc || BR2_x86_64 || \
              BR2_aarch64 || BR2_m68k || BR2_arc
 
+config BR2_PACKAGE_BUILD_SYSTEMD
+     bool
+
 menuconfig BR2_PACKAGE_SYSTEMD
      bool "systemd"
-     depends on BR2_INIT_SYSTEMD
+     depends on BR2_PACKAGE_BUILD_SYSTEMD
      depends on !BR2_STATIC_LIBS # kmod
      depends on BR2_TOOLCHAIN_HAS_THREADS # dbus
      depends on BR2_USE_MMU # dbus
-     select BR2_PACKAGE_HAS_UDEV
-     select BR2_PACKAGE_DBUS # runtime dependency only
+     select BR2_PACKAGE_HAS_UDEV if BR2_INIT_SYSTEMD
+     select BR2_PACKAGE_DBUS if BR2_INIT_SYSTEMD # runtime dependency only
      select BR2_PACKAGE_LIBCAP
      select BR2_PACKAGE_UTIL_LINUX
-     select BR2_PACKAGE_UTIL_LINUX_LIBBLKID
+     select BR2_PACKAGE_UTIL_LINUX_LIBBLKID if BR2_INIT_SYSTEMD
      select BR2_PACKAGE_UTIL_LINUX_LIBMOUNT
-     select BR2_PACKAGE_UTIL_LINUX_BINARIES
+     select BR2_PACKAGE_UTIL_LINUX_BINARIES if BR2_INIT_SYSTEMD
      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
-     select BR2_PACKAGE_KMOD_TOOLS
-     select BR2_TARGET_TZ_INFO
-     select BR2_NEEDS_HOST_UTF8_LOCALE
+     select BR2_PACKAGE_UTIL_LINUX_NOLOGIN if BR2_INIT_SYSTEMD
+     select BR2_PACKAGE_UTIL_LINUX_FSCK if BR2_INIT_SYSTEMD
+     select BR2_PACKAGE_KMOD if BR2_INIT_SYSTEMD
+     select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS if BR2_INIT_SYSTEMD # kmod-tools
+     select BR2_PACKAGE_KMOD_TOOLS if BR2_INIT_SYSTEMD
+     select BR2_TARGET_TZ_INFO if BR2_INIT_SYSTEMD
+     select BR2_NEEDS_HOST_UTF8_LOCALE if BR2_INIT_SYSTEMD
      help
        systemd is a system and service manager for Linux,
        compatible with SysV and LSB init scripts. systemd provides
@@ -76,9 +79,11 @@ if BR2_PACKAGE_SYSTEMD
 
 config BR2_PACKAGE_PROVIDES_UDEV
      default "systemd"
+     depends on BR2_INIT_SYSTEMD
 
 config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
      bool "HTTP server for journal events"
+     depends on BR2_INIT_SYSTEMD
      select BR2_PACKAGE_LIBMICROHTTPD
      help
        systemd-journal-gatewayd serves journal events over the
@@ -89,6 +94,7 @@ config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
 
 config BR2_PACKAGE_SYSTEMD_BACKLIGHT
      bool "enable backlight support"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-backlight is a service that restores the display
        backlight brightness at early boot and saves it at shutdown.
@@ -97,6 +103,7 @@ config BR2_PACKAGE_SYSTEMD_BACKLIGHT
 
 config BR2_PACKAGE_SYSTEMD_BINFMT
      bool "enable binfmt tool"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-binfmt is an early boot service that registers
        additional binary formats for executables in the kernel.
@@ -105,6 +112,7 @@ config BR2_PACKAGE_SYSTEMD_BINFMT
 
 config BR2_PACKAGE_SYSTEMD_COREDUMP
      bool "enable coredump hook"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-coredump can be used as a helper binary by the
        kernel when a user space program receives a fatal signal and
@@ -114,6 +122,7 @@ config BR2_PACKAGE_SYSTEMD_COREDUMP
 
 config BR2_PACKAGE_SYSTEMD_FIRSTBOOT
      bool "enable firstboot support"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-firstboot initializes the most basic system settings
        interactively on the first boot.
@@ -122,6 +131,7 @@ config BR2_PACKAGE_SYSTEMD_FIRSTBOOT
 
 config BR2_PACKAGE_SYSTEMD_HIBERNATE
      bool "enable hibernation support"
+     depends on BR2_INIT_SYSTEMD
      help
        When this features is enabled, additional tools and services
        are built to support suspending and resuming the system.
@@ -131,6 +141,7 @@ config BR2_PACKAGE_SYSTEMD_HIBERNATE
 config BR2_PACKAGE_SYSTEMD_HOSTNAMED
      bool "enable hostname daemon"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-hostnamed is a system service that may be used as a
        mechanism to change the system's hostname.
@@ -140,6 +151,7 @@ config BR2_PACKAGE_SYSTEMD_HOSTNAMED
 config BR2_PACKAGE_SYSTEMD_HWDB
      bool "enable hwdb installation"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        Enables hardware database installation to /usr/lib/udev/hwdb.d
 
@@ -150,6 +162,7 @@ config BR2_PACKAGE_SYSTEMD_HWDB
 
 config BR2_PACKAGE_SYSTEMD_IMPORTD
      bool "enable import daemon"
+     depends on BR2_INIT_SYSTEMD
      depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS # libgcrypt
      select BR2_PACKAGE_LIBCURL
      select BR2_PACKAGE_LIBGCRYPT
@@ -166,6 +179,7 @@ config BR2_PACKAGE_SYSTEMD_IMPORTD
 
 config BR2_PACKAGE_SYSTEMD_LOCALED
      bool "enable locale daemon"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-localed is a system service that may be used as
        mechanism to change the system locale settings, as well as
@@ -175,6 +189,7 @@ config BR2_PACKAGE_SYSTEMD_LOCALED
 
 config BR2_PACKAGE_SYSTEMD_LOGIND
      bool "enable login daemon"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-logind is a system service that manages user logins.
 
@@ -182,6 +197,7 @@ config BR2_PACKAGE_SYSTEMD_LOGIND
 
 config BR2_PACKAGE_SYSTEMD_MACHINED
      bool "enable machine daemon"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-machined is a system service that keeps track of
        virtual machines and containers, and processes belonging to
@@ -192,6 +208,7 @@ config BR2_PACKAGE_SYSTEMD_MACHINED
 config BR2_PACKAGE_SYSTEMD_MYHOSTNAME
      bool "enable myhostname NSS plugin"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        nss-myhostname is a plug-in module for the GNU Name Service
        Switch (NSS) functionality of the GNU C Library (glibc),
@@ -203,6 +220,7 @@ config BR2_PACKAGE_SYSTEMD_MYHOSTNAME
 config BR2_PACKAGE_SYSTEMD_NETWORKD
      bool "enable network manager"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-networkd is a system service that manages networks.
        It detects and configures network devices as they appear, as
@@ -215,6 +233,7 @@ config BR2_PACKAGE_SYSTEMD_NETWORKD
 
 config BR2_PACKAGE_SYSTEMD_POLKIT
      bool "enable polkit support"
+     depends on BR2_INIT_SYSTEMD
      depends on BR2_TOOLCHAIN_USES_GLIBC # polkit
      select BR2_PACKAGE_POLKIT
      help
@@ -226,10 +245,12 @@ config BR2_PACKAGE_SYSTEMD_POLKIT
        http://wiki.freedesktop.org/www/Software/polkit/
 
 comment "polkit support needs a glibc toolchain"
+     depends on BR2_INIT_SYSTEMD
      depends on !BR2_TOOLCHAIN_USES_GLIBC
 
 config BR2_PACKAGE_SYSTEMD_QUOTACHECK
      bool "enable quotacheck tools"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-quotacheck is a service responsible for file system
        quota checks. It is run once at boot after all necessary
@@ -240,6 +261,7 @@ config BR2_PACKAGE_SYSTEMD_QUOTACHECK
 
 config BR2_PACKAGE_SYSTEMD_RANDOMSEED
      bool "enable random-seed support"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-random-seed is a service that restores the random
        seed of the system at early boot and saves it at
@@ -251,6 +273,7 @@ config BR2_PACKAGE_SYSTEMD_RANDOMSEED
 config BR2_PACKAGE_SYSTEMD_RESOLVED
      bool "enable resolve daemon"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-resolved is a system service that provides network
        name resolution to local applications. It implements a
@@ -261,6 +284,7 @@ config BR2_PACKAGE_SYSTEMD_RESOLVED
 
 config BR2_PACKAGE_SYSTEMD_RFKILL
      bool "enable rfkill tools"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-rfkill is a service that restores the RF kill switch
        state at early boot and saves it at shutdown.
@@ -269,6 +293,7 @@ config BR2_PACKAGE_SYSTEMD_RFKILL
 
 config BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT
      bool "enable SMACK support"
+     depends on BR2_INIT_SYSTEMD
      select BR2_PACKAGE_ATTR
      select BR2_PACKAGE_SMACK
      help
@@ -283,6 +308,7 @@ config BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT
 
 config BR2_PACKAGE_SYSTEMD_SYSUSERS
      bool "enable sysusers support"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-sysusers creates system users and groups, based on
        the file format and location specified in sysusers.d(5).
@@ -292,6 +318,7 @@ config BR2_PACKAGE_SYSTEMD_SYSUSERS
 config BR2_PACKAGE_SYSTEMD_TIMEDATED
      bool "enable timedate daemon"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-timedated is a system service that may be used as a
        mechanism to change the system clock and timezone, as well
@@ -302,6 +329,7 @@ config BR2_PACKAGE_SYSTEMD_TIMEDATED
 config BR2_PACKAGE_SYSTEMD_TIMESYNCD
      bool "enable timesync daemon"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-timesyncd is a service that may be used to
        synchronize the local system clock with a Network Time
@@ -315,6 +343,7 @@ config BR2_PACKAGE_SYSTEMD_TIMESYNCD
 config BR2_PACKAGE_SYSTEMD_TMPFILES
      bool "enable tmpfiles support"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-tmpfiles creates, deletes, and cleans up volatile
        and temporary files and directories, based on the
@@ -325,6 +354,7 @@ config BR2_PACKAGE_SYSTEMD_TMPFILES
 
 config BR2_PACKAGE_SYSTEMD_VCONSOLE
      bool "enable vconsole tool"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-vconsole-setup is an early boot service that
        configures the virtual console font and console keymap.
package/systemd/buildroot.conf new file +3 -0
new file mode 100644
index 0000000..16d4d85
@@ -0,0 +1,3 @@
+title        Buildroot
+linux        /bzImage
+options      root=/dev/sda2 rootwait console=tty1
package/systemd/loader.conf new file +2 -0
new file mode 100644
index 0000000..93b77b8
@@ -0,0 +1,2 @@
+timeout 3
+default buildroot
package/systemd/systemd.mk +50 -3
index e53f0b6..b7234be 100644
@@ -8,15 +8,31 @@ SYSTEMD_VERSION = 239
 SYSTEMD_SITE = $(call github,systemd,systemd,v$(SYSTEMD_VERSION))
 SYSTEMD_LICENSE = LGPL-2.1+, GPL-2.0+ (udev), Public Domain (few source files, see README)
 SYSTEMD_LICENSE_FILES = LICENSE.GPL2 LICENSE.LGPL2.1 README
+ifeq ($(BR2_INIT_SYSTEMD),y)
 SYSTEMD_INSTALL_STAGING = YES
+else
+SYSTEMD_INSTALL_STAGING = NO
+SYSTEMD_INSTALL_TARGET = NO
+endif
+ifeq ($(BR2_TARGET_SYSTEMD_BOOT),y)
+SYSTEMD_INSTALL_IMAGES = YES
+ifeq ($(BR2_i386),y)
+SYSTEMD_IMGARCH = ia32
+else ifeq ($(BR2_x86_64),y)
+SYSTEMD_IMGARCH = x64
+endif
+endif
 SYSTEMD_DEPENDENCIES = \
      host-gperf \
      host-intltool \
-     kmod \
      libcap \
      util-linux
 
+ifeq ($(BR2_INIT_SYSTEMD),y)
+SYSTEMD_DEPENDENCIES += \
+     kmod
 SYSTEMD_PROVIDES = udev
+endif
 
 SYSTEMD_CONF_OPTS += \
      -Drootlibdir='/usr/lib' \
@@ -24,8 +40,6 @@ SYSTEMD_CONF_OPTS += \
      -Dman=false \
      -Dima=false \
      -Dlibcryptsetup=false \
-     -Defi=false \
-     -Dgnu-efi=false \
      -Dldconfig=false \
      -Ddefault-dnssec=no \
      -Dtests=false \
@@ -404,4 +418,37 @@ endef
 SYSTEMD_CONF_ENV = $(HOST_UTF8_LOCALE_ENV)
 SYSTEMD_NINJA_ENV = $(HOST_UTF8_LOCALE_ENV)
 
+ifeq ($(BR2_TARGET_SYSTEMD_BOOT),y)
+SYSTEMD_DEPENDENCIES += gnu-efi
+SYSTEMD_CONF_OPTS += \
+     -Defi=true \
+     -Dgnu-efi=true \
+     -Defi-cc=$(TARGET_CC) \
+     -Defi-ld=$(TARGET_LD) \
+     -Defi-libdir=$(STAGING_DIR)/usr/lib \
+     -Defi-ldsdir=$(STAGING_DIR)/usr/lib \
+     -Defi-includedir=$(STAGING_DIR)/usr/include/efi \
+
+ifneq ($(BR2_INIT_SYSTEMD),y)
+define SYSTEMD_BUILD_CMDS
+     $(TARGET_MAKE_ENV) $(SYSTEMD_NINJA_ENV) \
+             $(NINJA) $(NINJA_OPTS) -C $(SYSTEMD_SRCDIR)/build \
+             src/boot/efi/{systemd-boot$(SYSTEMD_IMGARCH).efi,linux$(SYSTEMD_IMGARCH).efi.stub}
+endef
+endif
+
+define SYSTEMD_INSTALL_IMAGES_CMDS
+     $(INSTALL) -D -m 0644 $(@D)/build/src/boot/efi/systemd-boot$(SYSTEMD_IMGARCH).efi \
+             $(BINARIES_DIR)/efi-part/EFI/BOOT/boot$(SYSTEMD_IMGARCH).efi
+     echo "boot$(SYSTEMD_IMGARCH).efi" > \
+             $(BINARIES_DIR)/efi-part/startup.nsh
+     $(INSTALL) -D -m 0644 $(SYSTEMD_PKGDIR)/loader.conf \
+             $(BINARIES_DIR)/efi-part/loader/loader.conf
+     $(INSTALL) -D -m 0644 $(SYSTEMD_PKGDIR)/buildroot.conf \
+             $(BINARIES_DIR)/efi-part/loader/entries/buildroot.conf
+endef
+else
+SYSTEMD_CONF_OPTS += -Defi=false -Dgnu-efi=false
+endif
+
 $(eval $(meson-package))
system/Config.in +1 -1
index 9e34f11..773a2cc 100644
@@ -133,6 +133,7 @@ config BR2_INIT_SYSTEMD
      depends on !BR2_STATIC_LIBS
      depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10
      select BR2_ROOTFS_MERGED_USR
+     select BR2_PACKAGE_BUILD_SYSTEMD
      select BR2_PACKAGE_SYSTEMD
 
 comment "systemd needs a glibc toolchain w/ SSP, headers >= 3.10"
--
Quoted 2 lines

2.7.4

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |

'------------------------------^-------^------------------^--------------------'

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH v2 1/1 boot/systemd-boot: new package

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Hi,

Quoted 2 lines

Also, I wonder if it ever makes sense to provide systemd-boot to non-systemd init systems to begin with.

I agree with everything Yann wrote.

One feature of systemd-boot that some people (E.G. me) might find interesting even if they do not use systemd as init system is the fact that it comes with an EFI stub loader that allows you to combine Linux kernel, hardcoded command line and initramfs into a single (potentially signed) EFI PE image with objcopy:

objcopy \
--add-section .cmdline=cmdline --change-section-vma .osrel=0x20000 \
--add-section .linux=linux --change-section-vma .linux=0x30000 \
--add-section .initrd=initrd --change-section-vma .initrd=0x3000000 \
stubx64.efi linux.efi

For some use cases (E.G. if these are not built by the same defconfigs or for A/B boot with different Linux command line) this late binding may be preferable to just building a Linux kernel with compile time hardcoded command line and embedded initramfs.

Signature · 1 line
Bye, Peter Korsgaard
#5 lore raw

PATCH v2 1/1 boot/systemd-boot: new package

Quoted 8 lines · Peter Korsgaard
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

"Yann" == Yann E MORIN <[email protected]> writes:

Hi,

Quoted 2 lines

Also, I wonder if it ever makes sense to provide systemd-boot to non-systemd init systems to begin with.

Quoted 7 lines

I agree with everything Yann wrote.

One feature of systemd-boot that some people (E.G. me) might find interesting even if they do not use systemd as init system is the fact that it comes with an EFI stub loader that allows you to combine Linux kernel, hardcoded command line and initramfs into a single (potentially signed) EFI PE image with objcopy:

Yeah, could be a useful option.

Quoted 11 lines

objcopy \
--add-section .cmdline=cmdline --change-section-vma .osrel=0x20000 \
--add-section .linux=linux --change-section-vma .linux=0x30000 \
--add-section .initrd=initrd --change-section-vma .initrd=0x3000000 \
stubx64.efi linux.efi

For some use cases (E.G. if these are not built by the same defconfigs or for A/B boot with different Linux command line) this late binding may be preferable to just building a Linux kernel with compile time hardcoded command line and embedded initramfs.

Yeah, maybe there should be a config option for that as well, I'm just using the kernel compile time options.

Quoted 3 lines

--
Bye, Peter Korsgaard

#6 lore raw

PATCH v2 1/1 boot/systemd-boot: new package

In reply to Peter Korsgaard

Peter, All,

On 2018-12-15 11:43 +0100, Peter Korsgaard spake thusly:

Quoted 15 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Also, I wonder if it ever makes sense to provide systemd-boot to non-systemd init systems to begin with.

One feature of systemd-boot that some people (E.G. me) might find interesting even if they do not use systemd as init system is the fact that it comes with an EFI stub loader that allows you to combine Linux kernel, hardcoded command line and initramfs into a single (potentially signed) EFI PE image with objcopy:

objcopy \
--add-section .cmdline=cmdline --change-section-vma .osrel=0x20000 \
--add-section .linux=linux --change-section-vma .linux=0x30000 \
--add-section .initrd=initrd --change-section-vma .initrd=0x3000000 \
stubx64.efi linux.efi

Quoted 4 lines

For some use cases (E.G. if these are not built by the same defconfigs or for A/B boot with different Linux command line) this late binding may be preferable to just building a Linux kernel with compile time hardcoded command line and embedded initramfs.

Ok, then it makes sense we can have systemd-boot without systemd init.

Let's try to find a solution for that, then.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#7 lore raw

PATCH v2 1/1 boot/systemd-boot: new package

In reply to Yann E. MORIN
Quoted 81 lines · Yann E. MORIN

James, All,

On 2018-12-15 02:12 -0700, James Hilliard spake thusly:

Quoted 10 lines · Yann E. MORIN
Quoted 9 lines

On 2018-12-14 19:42 +0800, james.hilliard1 at gmail.com spake thusly:

Quoted 3 lines

From: James Hilliard <[email protected]>

This is essentially the successor to gummiboot.

First, this patch is huge, it does many tricky things, so the commit log can't be that short. You need to explain in the commit log what this patch does, why it needs to do it.

Quoted 5 lines
Quoted 2 lines

Second, the patch basically does three different things:
- change stuff in the meson-packae infrastructure

Yeah, this can def be split off, it's to fix an issue with meson requiring cpu family to be normalized(it only seems to be an issue for meson.build files that have cpu family detection however).

Then just submit it as a separate patch of its own.

If this change was needed because of systemd-boot, then you can send a patch series to make it explicit that they are part of a same job, with the front patches needed by later patches in the series.

Quoted 4 lines
Quoted 2 lines

- change stuff in the systemd package
- adds a new virtual boot package

These kind of go together, all the changes in the systemd package are essentially adding systemd-boot package infrastructure.

No, sorry, I don't buy it. You can do changes in a package in a patch, that paves the way for another patch to use those changes.

In this case (but read below [*]), a first patch would change systemd so that it can be built without being the init system; then a second patch would add systemd-boot, that relies on building systemd even if it is not an init system.

Quoted 11 lines
Quoted 9 lines

This is a good indication that there should be _at least_ three patches, one for each of the above changes, each with a detailed commit log that explains what the change does and why it has to be done). Patches should do a complete change of their own, yet be atomic (i.e. can't be split). Here it is obvious that the patch can be split. And if it can't then you have to say why in the commit log, again.

Third, the new virtual boot package has no provider, so that's a indication that something is wrong with that patch.

So the virtual package is really just there so that there's an entry in the boot menu instead of packages for systemd-boot.

[*] Sorry, but I am still not convinced that we need all that complexity and why we can't just build systemd-boot as yet anotehr component of systemd *in* the systemd package, i.e. in package/systemd/systemd.mk, like we do for the other components (e.g. systemd-networkd or -resolved, etc...)

Quoted 9 lines
Quoted 7 lines

You need to clearly explain what is going on here, because all I can think is, why can't we simply build the systemd-boot component of systemd directly from the systemd package itself? (Yeah, I think I know the answer, but you have to explain it in the commit log. And no, it can't just be "but this is a bootloader, it has to have an entry in boot/": we have other bootloaders elsewhere, e.g. rpi-firmware, which do not live in boot/ (to my own dismay, but that's another story.))

I did it this way so that it's clear that systemd-boot can be built without a systemd init system.

There, _that_ is the reason for all this complexity.

So, let me suggest two alternative options that avoid all this mess:

1- make systemd-boot available only for systemd-based init,

2- just do a systemd-boot package (in boot/) that is a whole package on
its own, and just happens to build just the systemd-boot part of systemd.

I would very much favour the first option, because it is very simple, as it just requires a *few* tweaks in the existing sytemd.mk, i.e. basically:

Quoted 9 lines
    ifeq ($()BR2_PACKAGES_SYSTEMD_BOOT,y)
    SYSTEMD_CONF_OPTS += \
        -Defi=true \
        -Dgnu-efi=true \
        -Dcc-efi=blabla \
        [...]
    else
    SYSTEMD_CONF_OPTS += -Defi=false -Dgnu-efi=false
    endif

it would also need the SYSTEMD_INSTALL_IMAGES_CMDS part.

Quoted 3 lines

Also, I wonder if it ever makes sense to provide systemd-boot to non-systemd init systems to begin with.

I think it does, systemd-boot is even designed to boot operating systems without systemd, including windows.

Quoted 4 lines

Baring that, option 2 is pretty simple as well. It's a separate package that just happens to share its source code with another one, like we have with mesa3d and mesa3d-headers (just as an example).

I tried that approach first in my v1 patch, I abandoned it since systemd-boot needed to be built at the same time as the userspace tools for systems that have a systemd init system for the integration to work properly.

Quoted 558 lines
Quoted 3 lines

Would it make sense to move all
bootloaders to be under the boot menu?

No, that ship has long sailed now, let's not revisit this.

Regards,
Yann E. MORIN.

Quoted 529 lines
Quoted 529 lines

Regards,
Yann E. MORIN.

Quoted 525 lines
---
 DEVELOPERS                              |  1 +
 boot/Config.in                          |  1 +
 boot/systemd-boot/Config.in             | 23 ++++++++++++++
 boot/systemd-boot/systemd-boot.mk       |  7 +++++
 package/meson/cross-compilation.conf.in |  1 +
 package/meson/meson.mk                  | 41 ++++++++++++++++++++++++-
 package/systemd/Config.in               | 54 +++++++++++++++++++++++++--------
 package/systemd/buildroot.conf          |  3 ++
 package/systemd/loader.conf             |  2 ++
 package/systemd/systemd.mk              | 53 ++++++++++++++++++++++++++++++--
 system/Config.in                        |  1 +
 11 files changed, 171 insertions(+), 16 deletions(-)
 create mode 100644 boot/systemd-boot/Config.in
 create mode 100644 boot/systemd-boot/systemd-boot.mk
 create mode 100644 package/systemd/buildroot.conf
 create mode 100644 package/systemd/loader.conf
DEVELOPERS +1 -0
index 4192681..93599fe 100644
@@ -995,6 +995,7 @@ F:        configs/pine64_defconfig
 F:   configs/pine64_sopine_defconfig
 
 N:   James Hilliard <[email protected]>
+F:   boot/systemd-boot/
 F:   package/python-aiodns/
 F:   package/python-aiohttp/
 F:   package/python-aiohttp-jinja2/
boot/Config.in +1 -0
index 8e0c8e5..5b7f606 100644
@@ -16,6 +16,7 @@ source "boot/mxs-bootlets/Config.in"
 source "boot/riscv-pk/Config.in"
 source "boot/s500-bootloader/Config.in"
 source "boot/syslinux/Config.in"
+source "boot/systemd-boot/Config.in"
 source "boot/ts4800-mbrboot/Config.in"
 source "boot/uboot/Config.in"
 source "boot/vexpress-firmware/Config.in"
boot/systemd-boot/Config.in new file +23 -0
new file mode 100644
index 0000000..7c64cef
@@ -0,0 +1,23 @@
+config BR2_TARGET_SYSTEMD_BOOT
+     bool "systemd-boot"
+     depends on BR2_i386 || BR2_x86_64
+     select BR2_PACKAGE_BUILD_SYSTEMD
+     select BR2_PACKAGE_SYSTEMD
+     select BR2_PACKAGE_GNU_EFI
+     help
+       systemd-boot is a simple UEFI boot manager which executes
+       configured EFI images. The default entry is selected by a
+       configured pattern (glob) or an on-screen menu.
+
+       systemd-boot operates on the EFI System Partition (ESP)
+       only. Configuration file fragments, kernels, initrds, other
+       EFI images need to reside on the ESP. Linux kernels need to
+       be built with CONFIG_EFI_STUB to be able to be directly
+       executed as an EFI image.
+
+       See the Grub2 help text for details on preparing an EFI
+       capable disk image using systemd-boot: the instructions are
+       exactly the same, except that the systemd-boot configuration
+       files will be located in /loader/ inside the EFI partition.
+
+       https://www.freedesktop.org/wiki/Software/systemd/systemd-boot/
\ No newline at end of file
boot/systemd-boot/systemd-boot.mk new file +7 -0
new file mode 100644
index 0000000..5854024
@@ -0,0 +1,7 @@
+################################################################################
+#
+# systemd-boot
+#
+################################################################################
+
+$(eval $(virtual-package))
package/meson/cross-compilation.conf.in +1 -0
index 0eec740..fc8e27f 100644
@@ -11,6 +11,7 @@ strip = '@TARGET_CROSS at strip'
 pkgconfig = '@HOST_DIR@/usr/bin/pkg-config'
 
 [properties]
+needs_exe_wrapper = true
 c_args = [@TARGET_CFLAGS@]
 c_link_args = [@TARGET_LDFLAGS@]
 cpp_args = [@TARGET_CXXFLAGS@]
package/meson/meson.mk +40 -1
index e1675c2..d9ad2fc 100644
@@ -15,6 +15,45 @@ HOST_MESON_NEEDS_HOST_PYTHON = python3
 
 HOST_MESON_TARGET_ENDIAN = $(call LOWERCASE,$(BR2_ENDIAN))
 HOST_MESON_TARGET_CPU = $(GCC_TARGET_CPU)
+ifeq ($(BR2_arcle),y)
+HOST_MESON_TARGET_CPU_FAMILY = arc
+else ifeq ($(BR2_arceb),y)
+HOST_MESON_TARGET_CPU_FAMILY = arc
+else ifeq ($(BR2_arm),y)
+HOST_MESON_TARGET_CPU_FAMILY = arm
+else ifeq ($(BR2_armeb),y)
+HOST_MESON_TARGET_CPU_FAMILY = arm
+else ifeq ($(BR2_aarch64),y)
+HOST_MESON_TARGET_CPU_FAMILY = aarch64
+else ifeq ($(BR2_aarch64_be),y)
+HOST_MESON_TARGET_CPU_FAMILY = aarch64
+else ifeq ($(BR2_i386),y)
+HOST_MESON_TARGET_CPU_FAMILY = x86
+else ifeq ($(BR2_mips),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips
+else ifeq ($(BR2_mipsel),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips
+else ifeq ($(BR2_mips64),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips64
+else ifeq ($(BR2_mips64el),y)
+HOST_MESON_TARGET_CPU_FAMILY = mips64
+else ifeq ($(BR2_powerpc),y)
+HOST_MESON_TARGET_CPU_FAMILY = ppc
+else ifeq ($(BR2_powerpc64),y)
+HOST_MESON_TARGET_CPU_FAMILY = ppc64
+else ifeq ($(BR2_powerpc64le),y)
+HOST_MESON_TARGET_CPU_FAMILY = ppc64
+else ifeq ($(BR2_riscv),y)
+HOST_MESON_TARGET_CPU_FAMILY = riscv32
+else ifeq ($(BR2_sparc),y)
+HOST_MESON_TARGET_CPU_FAMILY = sparc
+else ifeq ($(BR2_sparc64),y)
+HOST_MESON_TARGET_CPU_FAMILY = sparc64
+else ifeq ($(BR2_x86_64),y)
+HOST_MESON_TARGET_CPU_FAMILY = x86_64
+else
+HOST_MESON_TARGET_CPU_FAMILY = $(ARCH)
+endif
 
 HOST_MESON_SED_CFLAGS = $(if $(TARGET_CFLAGS),`printf '"%s"$(comma) ' $(TARGET_CFLAGS)`)
 HOST_MESON_SED_LDFLAGS = $(if $(TARGET_LDFLAGS),`printf '"%s"$(comma) ' $(TARGET_LDFLAGS)`)
@@ -23,7 +62,7 @@ HOST_MESON_SED_CXXFLAGS = $(if $(TARGET_CXXFLAGS),`printf '"%s"$(comma) ' $(TARG
 define HOST_MESON_INSTALL_CROSS_CONF
      mkdir -p $(HOST_DIR)/etc/meson
      sed -e "s%@TARGET_CROSS@%$(TARGET_CROSS)%g" \
-         -e "s%@TARGET_ARCH@%$(ARCH)%g" \
+         -e "s%@TARGET_ARCH@%$(HOST_MESON_TARGET_CPU_FAMILY)%g" \
          -e "s%@TARGET_CPU@%$(HOST_MESON_TARGET_CPU)%g" \
          -e "s%@TARGET_ENDIAN@%$(HOST_MESON_TARGET_ENDIAN)%g" \
          -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)%g" \
package/systemd/Config.in +42 -12
index 25f322e..c8fa786 100644
@@ -7,27 +7,30 @@ config BR2_PACKAGE_SYSTEMD_ARCH_SUPPORTS
              BR2_sh4a || BR2_sh4aeb || BR2_sparc || BR2_x86_64 || \
              BR2_aarch64 || BR2_m68k || BR2_arc
 
+config BR2_PACKAGE_BUILD_SYSTEMD
+     bool
+
 menuconfig BR2_PACKAGE_SYSTEMD
      bool "systemd"
-     depends on BR2_INIT_SYSTEMD
+     depends on BR2_PACKAGE_BUILD_SYSTEMD
      depends on !BR2_STATIC_LIBS # kmod
      depends on BR2_TOOLCHAIN_HAS_THREADS # dbus
      depends on BR2_USE_MMU # dbus
-     select BR2_PACKAGE_HAS_UDEV
-     select BR2_PACKAGE_DBUS # runtime dependency only
+     select BR2_PACKAGE_HAS_UDEV if BR2_INIT_SYSTEMD
+     select BR2_PACKAGE_DBUS if BR2_INIT_SYSTEMD # runtime dependency only
      select BR2_PACKAGE_LIBCAP
      select BR2_PACKAGE_UTIL_LINUX
-     select BR2_PACKAGE_UTIL_LINUX_LIBBLKID
+     select BR2_PACKAGE_UTIL_LINUX_LIBBLKID if BR2_INIT_SYSTEMD
      select BR2_PACKAGE_UTIL_LINUX_LIBMOUNT
-     select BR2_PACKAGE_UTIL_LINUX_BINARIES
+     select BR2_PACKAGE_UTIL_LINUX_BINARIES if BR2_INIT_SYSTEMD
      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
-     select BR2_PACKAGE_KMOD_TOOLS
-     select BR2_TARGET_TZ_INFO
-     select BR2_NEEDS_HOST_UTF8_LOCALE
+     select BR2_PACKAGE_UTIL_LINUX_NOLOGIN if BR2_INIT_SYSTEMD
+     select BR2_PACKAGE_UTIL_LINUX_FSCK if BR2_INIT_SYSTEMD
+     select BR2_PACKAGE_KMOD if BR2_INIT_SYSTEMD
+     select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS if BR2_INIT_SYSTEMD # kmod-tools
+     select BR2_PACKAGE_KMOD_TOOLS if BR2_INIT_SYSTEMD
+     select BR2_TARGET_TZ_INFO if BR2_INIT_SYSTEMD
+     select BR2_NEEDS_HOST_UTF8_LOCALE if BR2_INIT_SYSTEMD
      help
        systemd is a system and service manager for Linux,
        compatible with SysV and LSB init scripts. systemd provides
@@ -76,9 +79,11 @@ if BR2_PACKAGE_SYSTEMD
 
 config BR2_PACKAGE_PROVIDES_UDEV
      default "systemd"
+     depends on BR2_INIT_SYSTEMD
 
 config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
      bool "HTTP server for journal events"
+     depends on BR2_INIT_SYSTEMD
      select BR2_PACKAGE_LIBMICROHTTPD
      help
        systemd-journal-gatewayd serves journal events over the
@@ -89,6 +94,7 @@ config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
 
 config BR2_PACKAGE_SYSTEMD_BACKLIGHT
      bool "enable backlight support"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-backlight is a service that restores the display
        backlight brightness at early boot and saves it at shutdown.
@@ -97,6 +103,7 @@ config BR2_PACKAGE_SYSTEMD_BACKLIGHT
 
 config BR2_PACKAGE_SYSTEMD_BINFMT
      bool "enable binfmt tool"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-binfmt is an early boot service that registers
        additional binary formats for executables in the kernel.
@@ -105,6 +112,7 @@ config BR2_PACKAGE_SYSTEMD_BINFMT
 
 config BR2_PACKAGE_SYSTEMD_COREDUMP
      bool "enable coredump hook"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-coredump can be used as a helper binary by the
        kernel when a user space program receives a fatal signal and
@@ -114,6 +122,7 @@ config BR2_PACKAGE_SYSTEMD_COREDUMP
 
 config BR2_PACKAGE_SYSTEMD_FIRSTBOOT
      bool "enable firstboot support"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-firstboot initializes the most basic system settings
        interactively on the first boot.
@@ -122,6 +131,7 @@ config BR2_PACKAGE_SYSTEMD_FIRSTBOOT
 
 config BR2_PACKAGE_SYSTEMD_HIBERNATE
      bool "enable hibernation support"
+     depends on BR2_INIT_SYSTEMD
      help
        When this features is enabled, additional tools and services
        are built to support suspending and resuming the system.
@@ -131,6 +141,7 @@ config BR2_PACKAGE_SYSTEMD_HIBERNATE
 config BR2_PACKAGE_SYSTEMD_HOSTNAMED
      bool "enable hostname daemon"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-hostnamed is a system service that may be used as a
        mechanism to change the system's hostname.
@@ -140,6 +151,7 @@ config BR2_PACKAGE_SYSTEMD_HOSTNAMED
 config BR2_PACKAGE_SYSTEMD_HWDB
      bool "enable hwdb installation"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        Enables hardware database installation to /usr/lib/udev/hwdb.d
 
@@ -150,6 +162,7 @@ config BR2_PACKAGE_SYSTEMD_HWDB
 
 config BR2_PACKAGE_SYSTEMD_IMPORTD
      bool "enable import daemon"
+     depends on BR2_INIT_SYSTEMD
      depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS # libgcrypt
      select BR2_PACKAGE_LIBCURL
      select BR2_PACKAGE_LIBGCRYPT
@@ -166,6 +179,7 @@ config BR2_PACKAGE_SYSTEMD_IMPORTD
 
 config BR2_PACKAGE_SYSTEMD_LOCALED
      bool "enable locale daemon"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-localed is a system service that may be used as
        mechanism to change the system locale settings, as well as
@@ -175,6 +189,7 @@ config BR2_PACKAGE_SYSTEMD_LOCALED
 
 config BR2_PACKAGE_SYSTEMD_LOGIND
      bool "enable login daemon"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-logind is a system service that manages user logins.
 
@@ -182,6 +197,7 @@ config BR2_PACKAGE_SYSTEMD_LOGIND
 
 config BR2_PACKAGE_SYSTEMD_MACHINED
      bool "enable machine daemon"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-machined is a system service that keeps track of
        virtual machines and containers, and processes belonging to
@@ -192,6 +208,7 @@ config BR2_PACKAGE_SYSTEMD_MACHINED
 config BR2_PACKAGE_SYSTEMD_MYHOSTNAME
      bool "enable myhostname NSS plugin"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        nss-myhostname is a plug-in module for the GNU Name Service
        Switch (NSS) functionality of the GNU C Library (glibc),
@@ -203,6 +220,7 @@ config BR2_PACKAGE_SYSTEMD_MYHOSTNAME
 config BR2_PACKAGE_SYSTEMD_NETWORKD
      bool "enable network manager"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-networkd is a system service that manages networks.
        It detects and configures network devices as they appear, as
@@ -215,6 +233,7 @@ config BR2_PACKAGE_SYSTEMD_NETWORKD
 
 config BR2_PACKAGE_SYSTEMD_POLKIT
      bool "enable polkit support"
+     depends on BR2_INIT_SYSTEMD
      depends on BR2_TOOLCHAIN_USES_GLIBC # polkit
      select BR2_PACKAGE_POLKIT
      help
@@ -226,10 +245,12 @@ config BR2_PACKAGE_SYSTEMD_POLKIT
        http://wiki.freedesktop.org/www/Software/polkit/
 
 comment "polkit support needs a glibc toolchain"
+     depends on BR2_INIT_SYSTEMD
      depends on !BR2_TOOLCHAIN_USES_GLIBC
 
 config BR2_PACKAGE_SYSTEMD_QUOTACHECK
      bool "enable quotacheck tools"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-quotacheck is a service responsible for file system
        quota checks. It is run once at boot after all necessary
@@ -240,6 +261,7 @@ config BR2_PACKAGE_SYSTEMD_QUOTACHECK
 
 config BR2_PACKAGE_SYSTEMD_RANDOMSEED
      bool "enable random-seed support"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-random-seed is a service that restores the random
        seed of the system at early boot and saves it at
@@ -251,6 +273,7 @@ config BR2_PACKAGE_SYSTEMD_RANDOMSEED
 config BR2_PACKAGE_SYSTEMD_RESOLVED
      bool "enable resolve daemon"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-resolved is a system service that provides network
        name resolution to local applications. It implements a
@@ -261,6 +284,7 @@ config BR2_PACKAGE_SYSTEMD_RESOLVED
 
 config BR2_PACKAGE_SYSTEMD_RFKILL
      bool "enable rfkill tools"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-rfkill is a service that restores the RF kill switch
        state at early boot and saves it at shutdown.
@@ -269,6 +293,7 @@ config BR2_PACKAGE_SYSTEMD_RFKILL
 
 config BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT
      bool "enable SMACK support"
+     depends on BR2_INIT_SYSTEMD
      select BR2_PACKAGE_ATTR
      select BR2_PACKAGE_SMACK
      help
@@ -283,6 +308,7 @@ config BR2_PACKAGE_SYSTEMD_SMACK_SUPPORT
 
 config BR2_PACKAGE_SYSTEMD_SYSUSERS
      bool "enable sysusers support"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-sysusers creates system users and groups, based on
        the file format and location specified in sysusers.d(5).
@@ -292,6 +318,7 @@ config BR2_PACKAGE_SYSTEMD_SYSUSERS
 config BR2_PACKAGE_SYSTEMD_TIMEDATED
      bool "enable timedate daemon"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-timedated is a system service that may be used as a
        mechanism to change the system clock and timezone, as well
@@ -302,6 +329,7 @@ config BR2_PACKAGE_SYSTEMD_TIMEDATED
 config BR2_PACKAGE_SYSTEMD_TIMESYNCD
      bool "enable timesync daemon"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-timesyncd is a service that may be used to
        synchronize the local system clock with a Network Time
@@ -315,6 +343,7 @@ config BR2_PACKAGE_SYSTEMD_TIMESYNCD
 config BR2_PACKAGE_SYSTEMD_TMPFILES
      bool "enable tmpfiles support"
      default y
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-tmpfiles creates, deletes, and cleans up volatile
        and temporary files and directories, based on the
@@ -325,6 +354,7 @@ config BR2_PACKAGE_SYSTEMD_TMPFILES
 
 config BR2_PACKAGE_SYSTEMD_VCONSOLE
      bool "enable vconsole tool"
+     depends on BR2_INIT_SYSTEMD
      help
        systemd-vconsole-setup is an early boot service that
        configures the virtual console font and console keymap.
package/systemd/buildroot.conf new file +3 -0
new file mode 100644
index 0000000..16d4d85
@@ -0,0 +1,3 @@
+title        Buildroot
+linux        /bzImage
+options      root=/dev/sda2 rootwait console=tty1
package/systemd/loader.conf new file +2 -0
new file mode 100644
index 0000000..93b77b8
@@ -0,0 +1,2 @@
+timeout 3
+default buildroot
package/systemd/systemd.mk +50 -3
index e53f0b6..b7234be 100644
@@ -8,15 +8,31 @@ SYSTEMD_VERSION = 239
 SYSTEMD_SITE = $(call github,systemd,systemd,v$(SYSTEMD_VERSION))
 SYSTEMD_LICENSE = LGPL-2.1+, GPL-2.0+ (udev), Public Domain (few source files, see README)
 SYSTEMD_LICENSE_FILES = LICENSE.GPL2 LICENSE.LGPL2.1 README
+ifeq ($(BR2_INIT_SYSTEMD),y)
 SYSTEMD_INSTALL_STAGING = YES
+else
+SYSTEMD_INSTALL_STAGING = NO
+SYSTEMD_INSTALL_TARGET = NO
+endif
+ifeq ($(BR2_TARGET_SYSTEMD_BOOT),y)
+SYSTEMD_INSTALL_IMAGES = YES
+ifeq ($(BR2_i386),y)
+SYSTEMD_IMGARCH = ia32
+else ifeq ($(BR2_x86_64),y)
+SYSTEMD_IMGARCH = x64
+endif
+endif
 SYSTEMD_DEPENDENCIES = \
      host-gperf \
      host-intltool \
-     kmod \
      libcap \
      util-linux
 
+ifeq ($(BR2_INIT_SYSTEMD),y)
+SYSTEMD_DEPENDENCIES += \
+     kmod
 SYSTEMD_PROVIDES = udev
+endif
 
 SYSTEMD_CONF_OPTS += \
      -Drootlibdir='/usr/lib' \
@@ -24,8 +40,6 @@ SYSTEMD_CONF_OPTS += \
      -Dman=false \
      -Dima=false \
      -Dlibcryptsetup=false \
-     -Defi=false \
-     -Dgnu-efi=false \
      -Dldconfig=false \
      -Ddefault-dnssec=no \
      -Dtests=false \
@@ -404,4 +418,37 @@ endef
 SYSTEMD_CONF_ENV = $(HOST_UTF8_LOCALE_ENV)
 SYSTEMD_NINJA_ENV = $(HOST_UTF8_LOCALE_ENV)
 
+ifeq ($(BR2_TARGET_SYSTEMD_BOOT),y)
+SYSTEMD_DEPENDENCIES += gnu-efi
+SYSTEMD_CONF_OPTS += \
+     -Defi=true \
+     -Dgnu-efi=true \
+     -Defi-cc=$(TARGET_CC) \
+     -Defi-ld=$(TARGET_LD) \
+     -Defi-libdir=$(STAGING_DIR)/usr/lib \
+     -Defi-ldsdir=$(STAGING_DIR)/usr/lib \
+     -Defi-includedir=$(STAGING_DIR)/usr/include/efi \
+
+ifneq ($(BR2_INIT_SYSTEMD),y)
+define SYSTEMD_BUILD_CMDS
+     $(TARGET_MAKE_ENV) $(SYSTEMD_NINJA_ENV) \
+             $(NINJA) $(NINJA_OPTS) -C $(SYSTEMD_SRCDIR)/build \
+             src/boot/efi/{systemd-boot$(SYSTEMD_IMGARCH).efi,linux$(SYSTEMD_IMGARCH).efi.stub}
+endef
+endif
+
+define SYSTEMD_INSTALL_IMAGES_CMDS
+     $(INSTALL) -D -m 0644 $(@D)/build/src/boot/efi/systemd-boot$(SYSTEMD_IMGARCH).efi \
+             $(BINARIES_DIR)/efi-part/EFI/BOOT/boot$(SYSTEMD_IMGARCH).efi
+     echo "boot$(SYSTEMD_IMGARCH).efi" > \
+             $(BINARIES_DIR)/efi-part/startup.nsh
+     $(INSTALL) -D -m 0644 $(SYSTEMD_PKGDIR)/loader.conf \
+             $(BINARIES_DIR)/efi-part/loader/loader.conf
+     $(INSTALL) -D -m 0644 $(SYSTEMD_PKGDIR)/buildroot.conf \
+             $(BINARIES_DIR)/efi-part/loader/entries/buildroot.conf
+endef
+else
+SYSTEMD_CONF_OPTS += -Defi=false -Dgnu-efi=false
+endif
+
 $(eval $(meson-package))
system/Config.in +1 -0
index 9e34f11..773a2cc 100644
@@ -133,6 +133,7 @@ config BR2_INIT_SYSTEMD
      depends on !BR2_STATIC_LIBS
      depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10
      select BR2_ROOTFS_MERGED_USR
+     select BR2_PACKAGE_BUILD_SYSTEMD
      select BR2_PACKAGE_SYSTEMD
 
Quoted 12 lines
Quoted 5 lines
Quoted 4 lines
system/Config.in +0 -1
 comment "systemd needs a glibc toolchain w/ SSP, headers >= 3.10"
--

2.7.4

Quoted 7 lines

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |

'------------------------------^-------^------------------^--------------------'

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |

'------------------------------^-------^------------------^--------------------'

#8 lore raw

PATCH v2 1/1 boot/systemd-boot: new package

James, All,

On 2018-12-15 03:43 -0700, James Hilliard spake thusly:

Quoted 2 lines · Yann E. MORIN
Quoted 1 line

On 2018-12-15 02:12 -0700, James Hilliard spake thusly:

[--SNIP--]

Quoted 26 lines
Quoted 17 lines
Quoted 2 lines

I did it this way so that it's clear that systemd-boot can be built without a systemd init system.

There, _that_ is the reason for all this complexity.

So, let me suggest two alternative options that avoid all this mess:

1- make systemd-boot available only for systemd-based init,

2- just do a systemd-boot package (in boot/) that is a whole package on
its own, and just happens to build just the systemd-boot part of systemd.

I would very much favour the first option, because it is very simple, as it just requires a *few* tweaks in the existing sytemd.mk, i.e. basically:

Quoted 9 lines
    ifeq ($()BR2_PACKAGES_SYSTEMD_BOOT,y)
    SYSTEMD_CONF_OPTS += \
        -Defi=true \
        -Dgnu-efi=true \
        -Dcc-efi=blabla \
        [...]
    else
    SYSTEMD_CONF_OPTS += -Defi=false -Dgnu-efi=false
    endif
Quoted 1 line

it would also need the SYSTEMD_INSTALL_IMAGES_CMDS part.

Yes, obviously my code snippet was there just as a seed for a proper, complete change...

Quoted 3 lines
Quoted 2 lines

Also, I wonder if it ever makes sense to provide systemd-boot to non-systemd init systems to begin with.

I think it does,

Yes, Peter provided a good use-case, indeed.

Quoted 2 lines

systemd-boot is even designed to boot operating
systems without systemd, including windows.

Aha, you almost got me there, I almost thought you were serious (in the Buildroot context, I mean). ;-)

Quoted 4 lines
Quoted 3 lines

Baring that, option 2 is pretty simple as well. It's a separate package that just happens to share its source code with another one, like we have with mesa3d and mesa3d-headers (just as an example).

I tried that approach first in my v1 patch, I abandoned it since

Yet, I think we should really go that route.

Quoted 3 lines

systemd-boot needed to be built at the same time as the userspace tools for systems that have a systemd init system for the integration to work properly.

OK, so we need to think it a bit, then. Is it the boot part that needs the userland part, of the userland that needs the boot part, of they both need to know each other?

One option I can think of quickly, is that we could have a systemd-boot package that is only available when systemd is not enabled, and an option in systemd to install the boot part when systemd is enabled.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#9 lore raw

PATCH v2 1/1 boot/systemd-boot: new package

Quoted 42 lines · Yann E. MORIN

James, All,

On 2018-12-15 03:43 -0700, James Hilliard spake thusly:

Quoted 2 lines · Yann E. MORIN
Quoted 1 line

On 2018-12-15 02:12 -0700, James Hilliard spake thusly:

[--SNIP--]

Quoted 26 lines
Quoted 17 lines
Quoted 2 lines

I did it this way so that it's clear that systemd-boot can be built without a systemd init system.

There, _that_ is the reason for all this complexity.

So, let me suggest two alternative options that avoid all this mess:

1- make systemd-boot available only for systemd-based init,

2- just do a systemd-boot package (in boot/) that is a whole package on
its own, and just happens to build just the systemd-boot part of systemd.

I would very much favour the first option, because it is very simple, as it just requires a *few* tweaks in the existing sytemd.mk, i.e. basically:

Quoted 9 lines
    ifeq ($()BR2_PACKAGES_SYSTEMD_BOOT,y)
    SYSTEMD_CONF_OPTS += \
        -Defi=true \
        -Dgnu-efi=true \
        -Dcc-efi=blabla \
        [...]
    else
    SYSTEMD_CONF_OPTS += -Defi=false -Dgnu-efi=false
    endif
Quoted 1 line

it would also need the SYSTEMD_INSTALL_IMAGES_CMDS part.

Yes, obviously my code snippet was there just as a seed for a proper, complete change...

Quoted 3 lines
Quoted 2 lines

Also, I wonder if it ever makes sense to provide systemd-boot to non-systemd init systems to begin with.

I think it does,

Quoted 7 lines

Yes, Peter provided a good use-case, indeed.

Quoted 2 lines

systemd-boot is even designed to boot operating
systems without systemd, including windows.

Aha, you almost got me there, I almost thought you were serious (in the Buildroot context, I mean). ;-)

Heh, was just making a point that it wasn't dependent on a systemd userspace.

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

Baring that, option 2 is pretty simple as well. It's a separate package that just happens to share its source code with another one, like we have with mesa3d and mesa3d-headers (just as an example).

I tried that approach first in my v1 patch, I abandoned it since

Yet, I think we should really go that route.

Quoted 7 lines
Quoted 3 lines

systemd-boot needed to be built at the same time as the userspace tools for systems that have a systemd init system for the integration to work properly.

OK, so we need to think it a bit, then. Is it the boot part that needs the userland part, of the userland that needs the boot part, of they both need to know each other?

Mostly userland that needs to know the boot part, the boot part itself doesn't really care what OS it is booting.

Quoted 4 lines

One option I can think of quickly, is that we could have a systemd-boot package that is only available when systemd is not enabled, and an option in systemd to install the boot part when systemd is enabled.

I was trying to avoid having fully separate packages since that would create a lot of maintenance overhead keeping both up to date as well. Is there something wrong with having a fake boot package that configures the appropriate options in the primary systemd package?

Quoted 11 lines

Regards,
Yann E. MORIN.

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |

'------------------------------^-------^------------------^--------------------'

#10 lore raw

PATCH v2 1/1 boot/systemd-boot: new package

James, All,

On 2018-12-15 04:09 -0700, James Hilliard spake thusly:

Quoted 10 lines · Yann E. MORIN
Quoted 7 lines

On 2018-12-15 03:43 -0700, James Hilliard spake thusly:

Quoted 3 lines

systemd-boot needed to be built at the same time as the userspace tools for systems that have a systemd init system for the integration to work properly.

OK, so we need to think it a bit, then. Is it the boot part that needs the userland part, of the userland that needs the boot part, of they both need to know each other?

Mostly userland that needs to know the boot part, the boot part itself doesn't really care what OS it is booting.

OK, so we should be able to build systemd-boot as its own package.

Then, we just configure systemd with boot support.

Quoted 7 lines
Quoted 3 lines

One option I can think of quickly, is that we could have a systemd-boot package that is only available when systemd is not enabled, and an option in systemd to install the boot part when systemd is enabled.

I was trying to avoid having fully separate packages since that would create a lot of maintenance overhead keeping both up to date as well. Is there something wrong with having a fake boot package that configures the appropriate options in the primary systemd package?

What is wrong is that it makes the systemd package *and* the init selectionmuch more copmplex, and this is not acceptable (IMHO).

I'd rather have a second package that is trivial, with mimimum, if at all, changes in the main systemd package.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'