Skip to contentSkip to conversation

package/systemd: add systemd-boot build option

PATCH New james.hilliard1 at gmail.com 2 participants 11 messages Dec 18, 2018 – Dec 25, 2018 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/systemd: add systemd-boot build option

From: James Hilliard <[email protected]>

---
 package/systemd/Config.in  | 21 +++++++++++++++++++++
 package/systemd/systemd.mk |  8 ++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)
package/systemd/Config.in +21 -0
index 25f322e..ff71323 100644
@@ -77,6 +77,27 @@ if BR2_PACKAGE_SYSTEMD
 config BR2_PACKAGE_PROVIDES_UDEV
 	default "systemd"
 
+config BR2_PACKAGE_SYSTEMD_BOOT
+	bool "systemd-boot"
+	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/
+
 config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
 	bool "HTTP server for journal events"
 	select BR2_PACKAGE_LIBMICROHTTPD
package/systemd/systemd.mk +6 -2
index e53f0b6..0fa3b83 100644
@@ -24,8 +24,6 @@ SYSTEMD_CONF_OPTS += \
 	-Dman=false \
 	-Dima=false \
 	-Dlibcryptsetup=false \
-	-Defi=false \
-	-Dgnu-efi=false \
 	-Dldconfig=false \
 	-Ddefault-dnssec=no \
 	-Dtests=false \
@@ -332,6 +330,12 @@ else
 SYSTEMD_CONF_OPTS += -Dhibernate=false
 endif
 
+ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
+SYSTEMD_CONF_OPTS += -Defi=true -Dgnu-efi=true
+else
+SYSTEMD_CONF_OPTS += -Defi=false -Dgnu-efi=false
+endif
+
 SYSTEMD_FALLBACK_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
 ifneq ($(SYSTEMD_FALLBACK_HOSTNAME),)
 SYSTEMD_CONF_OPTS += -Dfallback-hostname=$(SYSTEMD_FALLBACK_HOSTNAME)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 boot/systemd-boot: new package

From: James Hilliard <[email protected]>

This is essentially the successor to gummiboot.

This package will use the existing systemd-boot binaries when systemd init is selected.

---
 boot/Config.in                                     |   1 +
 boot/systemd-boot/0001-fix-getty-unit.patch        |   1 +
 .../0002-install-don-t-use-ln-relative.patch       |   1 +
 ...etect-whether-struct-statx-is-defined-in-.patch |   1 +
 ...-linux-stat.h-check-with-other-checks-and.patch |   1 +
 ...sure-we-have-enough-space-for-the-DHCP6-o.patch |   1 +
 ...eson.build-fix-detection-of-Werror-shadow.patch |   1 +
 boot/systemd-boot/Config.in                        |  24 ++++
 boot/systemd-boot/buildroot.conf                   |   3 +
 boot/systemd-boot/loader.conf                      |   2 +
 boot/systemd-boot/systemd-boot.mk                  | 126 +++++++++++++++++++++
 boot/systemd-boot/systemd.hash                     |   1 +
 12 files changed, 163 insertions(+)
 create mode 120000 boot/systemd-boot/0001-fix-getty-unit.patch
 create mode 120000 boot/systemd-boot/0002-install-don-t-use-ln-relative.patch
 create mode 120000 boot/systemd-boot/0003-build-sys-Detect-whether-struct-statx-is-defined-in-.patch
 create mode 120000 boot/systemd-boot/0004-meson-unify-linux-stat.h-check-with-other-checks-and.patch
 create mode 120000 boot/systemd-boot/0005-dhcp6-make-sure-we-have-enough-space-for-the-DHCP6-o.patch
 create mode 120000 boot/systemd-boot/0006-meson.build-fix-detection-of-Werror-shadow.patch
 create mode 100644 boot/systemd-boot/Config.in
 create mode 100644 boot/systemd-boot/buildroot.conf
 create mode 100644 boot/systemd-boot/loader.conf
 create mode 100644 boot/systemd-boot/systemd-boot.mk
 create mode 120000 boot/systemd-boot/systemd.hash
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/0001-fix-getty-unit.patch new file +1 -0
new file mode 120000
index 0000000..ffb5f53
@@ -0,0 +1 @@
+../../package/systemd/0001-fix-getty-unit.patch
\ No newline at end of file
boot/systemd-boot/0002-install-don-t-use-ln-relative.patch new file +1 -0
new file mode 120000
index 0000000..cfe0291
@@ -0,0 +1 @@
+../../package/systemd/0002-install-don-t-use-ln-relative.patch
\ No newline at end of file
boot/systemd-boot/0003-build-sys-Detect-whether-struct-statx-is-defined-in-.patch new file +1 -0
new file mode 120000
index 0000000..ded8b4f
@@ -0,0 +1 @@
+../../package/systemd/0003-build-sys-Detect-whether-struct-statx-is-defined-in-.patch
\ No newline at end of file
boot/systemd-boot/0004-meson-unify-linux-stat.h-check-with-other-checks-and.patch new file +1 -0
new file mode 120000
index 0000000..32bc435
@@ -0,0 +1 @@
+../../package/systemd/0004-meson-unify-linux-stat.h-check-with-other-checks-and.patch
\ No newline at end of file
boot/systemd-boot/0005-dhcp6-make-sure-we-have-enough-space-for-the-DHCP6-o.patch new file +1 -0
new file mode 120000
index 0000000..003d6a7
@@ -0,0 +1 @@
+../../package/systemd/0005-dhcp6-make-sure-we-have-enough-space-for-the-DHCP6-o.patch
\ No newline at end of file
boot/systemd-boot/0006-meson.build-fix-detection-of-Werror-shadow.patch new file +1 -0
new file mode 120000
index 0000000..0e0a5cf
@@ -0,0 +1 @@
+../../package/systemd/0006-meson.build-fix-detection-of-Werror-shadow.patch
\ No newline at end of file
boot/systemd-boot/Config.in new file +24 -0
new file mode 100644
index 0000000..922bb07
@@ -0,0 +1,24 @@
+config BR2_TARGET_SYSTEMD_BOOT
+	bool "systemd-boot"
+	depends on BR2_i386 || BR2_x86_64
+	select BR2_PACKAGE_SYSTEMD_BOOT if BR2_INIT_SYSTEMD
+	select BR2_PACKAGE_GNU_EFI
+	select BR2_PACKAGE_UTIL_LINUX
+	select BR2_PACKAGE_UTIL_LINUX_LIBBLKID
+	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/
boot/systemd-boot/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
boot/systemd-boot/loader.conf new file +2 -0
new file mode 100644
index 0000000..93b77b8
@@ -0,0 +1,2 @@
+timeout 3
+default buildroot
boot/systemd-boot/systemd-boot.mk new file +126 -0

126 lines not on this page · raw message

boot/systemd-boot/systemd.hash new file +1 -0
new file mode 120000
index 0000000..4259f40
@@ -0,0 +1 @@
+../../package/systemd/systemd.hash
\ No newline at end of file
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 boot/systemd-boot: new package

James, All,

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

Quoted 6 lines

From: James Hilliard <[email protected]>

This is essentially the successor to gummiboot.

This package will use the existing systemd-boot binaries when systemd init is selected.

I find this commit log a bit terse...

When the packaging is non trivial, like this one, it is important to write in the commit log all the tricks that are used in the package.

For example, you could start with something simple:

systemd-boot is part of the systemd source tree.

Then, add a quick blurb about the patches:

To avoid duplication, we just symlink the patches from systemd.

Then you should probably explain how you solved the dependency against systemd:

When systemd is enabled (as the init system), enabling the systemd-boot package will simply select the corresponding option in the systemd package. In this case, the systemd-boot package is a generic-package, that builds nothing and isntall othing, delegating everything to the systemd package.

When system is disabled, enabling the systemd-boot package will actually build and install the boot blobs. To avoid building a complete systemd, we explicitly request the build of each individual blobs, and manually copy them at install time.

And now, with this explanations, I will be able to properly question that design! ;-)

See below...

Quoted 2 lines

---

[--SNIP--]

boot/systemd-boot/Config.in line 3

Quoted 9 lines
boot/systemd-boot/Config.in new file +3 -0
new file mode 100644
index 0000000..922bb07
@@ -0,0 +1,24 @@
+config BR2_TARGET_SYSTEMD_BOOT
+	bool "systemd-boot"
+	depends on BR2_i386 || BR2_x86_64

You'll need to get this architecture list in sync with the one in systemd. I would suggest that you limit yourself to what you can test and are interested in.

boot/systemd-boot/Config.in line 4

Quoted 1 line
boot/systemd-boot/Config.in new file +1 -0
+	select BR2_PACKAGE_SYSTEMD_BOOT if BR2_INIT_SYSTEMD

I think it is much more simple if you just do:

depends on !BR2_PACKAGE_SYSTEMD

and then add a comment (at the end of this Config.in)::

comment "systemd-boot is provided by systemd"
depends on BR2_PACKAGE_SYSTEMD

That way, you don't have to need to be schizophrenic about being a generic-package or a meson-package. Just be a meson-package.

boot/systemd-boot/Config.in line 7

Quoted 2 lines
boot/systemd-boot/Config.in new file +2 -0
+	select BR2_PACKAGE_UTIL_LINUX
+	select BR2_PACKAGE_UTIL_LINUX_LIBBLKID

Beware, that libblkid uses fork(), so needs an MMU, so you need to propagate that dependency with (the comment is to indicate that it's an inherited dependency):

depends on BR2_USE_MMU # util-linux' libblkid

But since we're only building the boot blobs, can we do away without util-linux?

Looking at an impothetical situation (e.g. recovery system, or a first-stage initramfs...):

minimalist system with just busybox,
- systemd-boot as bootloader

this would force having util-linux library, even though nothing would use them...

[--SNIP--]

Quoted 15 lines
boot/systemd-boot/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
boot/systemd-boot/loader.conf new file +0 -0
new file mode 100644
index 0000000..93b77b8

boot/systemd-boot/loader.conf line 2

Quoted 2 lines
boot/systemd-boot/loader.conf new file +2 -0
@@ -0,0 +1,2 @@
+timeout 3
+default buildroot

I see that your previous patch in systemd did not provide thoose two files.

Note: we'd need a way to also share those two files (buildroot.conf and loader.conf) between systemd-boot and systemd.

boot/systemd-boot/systemd-boot.mk line 7

Quoted 13 lines
boot/systemd-boot/systemd-boot.mk new file +7 -0
new file mode 100644
index 0000000..7f97ef0
@@ -0,0 +1,126 @@
+################################################################################
+#
+# systemd-boot
+#
+################################################################################
+
+SYSTEMD_BOOT_VERSION = 239

You'll need to add a comment here and in systemd, to keep the versions in sync (like you've seen in mesa3d and mesa3d-headers).

boot/systemd-boot/systemd-boot.mk line 9

Quoted 2 lines
boot/systemd-boot/systemd-boot.mk new file +2 -0
+SYSTEMD_BOOT_SITE = $(call github,systemd,systemd,v$(SYSTEMD_BOOT_VERSION))
+SYSTEMD_BOOT_DL_SUBDIR = systemd

Yes! :-)

boot/systemd-boot/systemd-boot.mk line 20

Quoted 11 lines
boot/systemd-boot/systemd-boot.mk new file +11 -0
+SYSTEMD_BOOT_LICENSE = LGPL-2.1+, GPL-2.0+ (udev), Public Domain (few source files, see README)
+SYSTEMD_BOOT_LICENSE_FILES = LICENSE.GPL2 LICENSE.LGPL2.1 README
+SYSTEMD_BOOT_INSTALL_STAGING = NO
+SYSTEMD_BOOT_INSTALL_TARGET = NO
+SYSTEMD_BOOT_INSTALL_IMAGES = YES
+SYSTEMD_BOOT_DEPENDENCIES = \
+	gnu-efi \
+	util-linux
+ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
+SYSTEMD_BOOT_DEPENDENCIES += systemd
+endif

You can get rid of this dependency, once you switch to a depends on !SYSTEMD in the Config.in.

boot/systemd-boot/systemd-boot.mk line 31

Quoted 10 lines
boot/systemd-boot/systemd-boot.mk new file +10 -0
+ifeq ($(BR2_i386),y)
+SYSTEMD_BOOT_IMGARCH = ia32
+else ifeq ($(BR2_x86_64),y)
+SYSTEMD_BOOT_IMGARCH = x64
+endif
+
+ifneq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
+SYSTEMD_BOOT_CONF_OPTS += \
+	-Drootlibdir='/usr/lib' \
+	-Dblkid=true \

Can we get rid of libblkid here?

boot/systemd-boot/systemd-boot.mk line 40

Quoted 9 lines
boot/systemd-boot/systemd-boot.mk new file +9 -0
+	-Dman=false \
+	-Dima=false \
+	-Dlibcryptsetup=false \
+	-Defi=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 \

As far as I could see from the code, those 5 last options already default to the proper values. Why did you need to force them?

boot/systemd-boot/systemd-boot.mk line 47

Quoted 7 lines
boot/systemd-boot/systemd-boot.mk new file +7 -0
+	-Dgnu-efi=true \
+	-Dldconfig=false \
+	-Ddefault-dnssec=no \
+	-Dtests=false \
+	-Dnobody-group=nogroup \
+	-Didn=true \
+	-Dnss-systemd=true \

Since we're only building the boot blobs, why do we need to have those two set to 'true', when all the rest is set to false?

Quoted 45 lines
boot/systemd-boot/systemd-boot.mk new file +45 -0
+	-Dacl=false \
+	-Daudit=false \
+	-Delfutils=false \
+	-Dlibidn=false \
+	-Dlibidn2=false \
+	-Dseccomp=false \
+	-Dxkbcommon=false \
+	-Dbzip2=false \
+	-Dlz4=false \
+	-Dpam=false \
+	-Dxz=false \
+	-Dzlib=false \
+	-Dlibcurl=false \
+	-Dgcrypt=false \
+	-Dpcre2=false \
+	-Dmicrohttpd=false \
+	-Dqrencode=false \
+	-Dselinux=false \
+	-Dhwdb=false \
+	-Dbinfmt=false \
+	-Dvconsole=false \
+	-Dquotacheck=false \
+	-Dtmpfiles=false \
+	-Dsysusers=false \
+	-Dfirstboot=false \
+	-Drandomseed=false \
+	-Dbacklight=false \
+	-Drfkill=false \
+	-Dlogind=false \
+	-Dmachined=false \
+	-Dimportd=false \
+	-Dhostnamed=false \
+	-Dmyhostname=false \
+	-Dtimedated=false \
+	-Dlocaled=false \
+	-Dcoredump=false \
+	-Dpolkit=false \
+	-Dnetworkd=false \
+	-Dresolve=false \
+	-Dtimesyncd=false \
+	-Dsmack=false \
+	-Dhibernate=false
+endif
+
+SYSTEMD_BOOT_CONF_ENV = $(HOST_UTF8_LOCALE_ENV)

boot/systemd-boot/systemd-boot.mk line 102

Quoted 10 lines
boot/systemd-boot/systemd-boot.mk new file +10 -0
+SYSTEMD_BOOT_NINJA_ENV = $(HOST_UTF8_LOCALE_ENV)
+
+ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
+define SYSTEMD_BOOT_BUILD_CMDS
+	mkdir -p $(@D)/build/src/boot/efi
+	cp $(TARGET_DIR)/usr/lib/systemd/boot/efi/systemd-boot$(SYSTEMD_BOOT_IMGARCH).efi \
+		$(@D)/build/src/boot/efi/systemd-boot$(SYSTEMD_BOOT_IMGARCH).efi
+	cp $(TARGET_DIR)/usr/lib/systemd/boot/efi/linux$(SYSTEMD_BOOT_IMGARCH).efi.stub \
+		$(@D)/build/src/boot/efi/linux$(SYSTEMD_BOOT_IMGARCH).efi.stub
+endef

You can now also get rid of this trick.

Quoted 7 lines
boot/systemd-boot/systemd-boot.mk new file +7 -0
+else
+define SYSTEMD_BOOT_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(SYSTEMD_BOOT_NINJA_ENV) \
+		$(NINJA) $(NINJA_OPTS) -C $(@D)/build \
+		src/boot/efi/{systemd-boot$(SYSTEMD_BOOT_IMGARCH).efi,linux$(SYSTEMD_BOOT_IMGARCH).efi.stub}
+endef
+endif

boot/systemd-boot/systemd-boot.mk line 119

Quoted 10 lines
boot/systemd-boot/systemd-boot.mk new file +10 -0
+
+define SYSTEMD_BOOT_INSTALL_IMAGES_CMDS
+	$(INSTALL) -D -m 0644 $(@D)/build/src/boot/efi/systemd-boot$(SYSTEMD_BOOT_IMGARCH).efi \
+		$(BINARIES_DIR)/efi-part/EFI/BOOT/boot$(SYSTEMD_BOOT_IMGARCH).efi
+	echo "boot$(SYSTEMD_BOOT_IMGARCH).efi" > \
+		$(BINARIES_DIR)/efi-part/startup.nsh
+	$(INSTALL) -D -m 0644 $(SYSTEMD_BOOT_PKGDIR)/loader.conf \
+		$(BINARIES_DIR)/efi-part/loader/loader.conf
+	$(INSTALL) -D -m 0644 $(SYSTEMD_BOOT_PKGDIR)/buildroot.conf \
+		$(BINARIES_DIR)/efi-part/loader/entries/buildroot.conf

Should you not be doing the same in the systemd case?

Regards,
Yann E. MORIN.

Quoted 18 lines
boot/systemd-boot/systemd-boot.mk new file +7 -0
+endef
+
+ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
+$(eval $(generic-package))
+else
+$(eval $(meson-package))
+endif
boot/systemd-boot/systemd.hash new file +1 -0
new file mode 120000
index 0000000..4259f40
@@ -0,0 +1 @@
+../../package/systemd/systemd.hash
\ No newline at end of file
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.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH 2/2 boot/systemd-boot: new package

Quoted 47 lines · Yann E. MORIN

James, All,

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

Quoted 6 lines

From: James Hilliard <[email protected]>

This is essentially the successor to gummiboot.

This package will use the existing systemd-boot binaries when systemd init is selected.

I find this commit log a bit terse...

When the packaging is non trivial, like this one, it is important to write in the commit log all the tricks that are used in the package.

For example, you could start with something simple:

systemd-boot is part of the systemd source tree.

Then, add a quick blurb about the patches:

To avoid duplication, we just symlink the patches from systemd.

Then you should probably explain how you solved the dependency against systemd:

When systemd is enabled (as the init system), enabling the systemd-boot package will simply select the corresponding option in the systemd package. In this case, the systemd-boot package is a generic-package, that builds nothing and isntall othing, delegating everything to the systemd package.

When system is disabled, enabling the systemd-boot package will actually build and install the boot blobs. To avoid building a complete systemd, we explicitly request the build of each individual blobs, and manually copy them at install time.

And now, with this explanations, I will be able to properly question that design! ;-)

See below...

Quoted 2 lines

---

[--SNIP--]

Quoted 13 lines

boot/systemd-boot/Config.in line 3

Quoted 9 lines
boot/systemd-boot/Config.in new file +3 -0
new file mode 100644
index 0000000..922bb07
@@ -0,0 +1,24 @@
+config BR2_TARGET_SYSTEMD_BOOT
+     bool "systemd-boot"
+     depends on BR2_i386 || BR2_x86_64

You'll need to get this architecture list in sync with the one in systemd. I would suggest that you limit yourself to what you can test and are interested in.

Since systemd-boot only supports a few architectures here
https://github.com/systemd/systemd/blob/06da5c63dd697ea4087e76c6d809b60b5780b87c/meson.build#L1386-L1395
I should be able to add support for the others fairly easily in my next version.

Quoted 7 lines

boot/systemd-boot/Config.in line 4

Quoted 2 lines
boot/systemd-boot/Config.in new file +1 -0
+     select BR2_PACKAGE_SYSTEMD_BOOT if BR2_INIT_SYSTEMD

I think it is much more simple if you just do:

depends on !BR2_PACKAGE_SYSTEMD

Quoted 7 lines

and then add a comment (at the end of this Config.in)::

comment "systemd-boot is provided by systemd"
depends on BR2_PACKAGE_SYSTEMD

That way, you don't have to need to be schizophrenic about being a generic-package or a meson-package. Just be a meson-package.

So I ended up doing things this way so that the systemd-boot package is used for the image installation regardless of where the bootloader is compiled.

Quoted 4 lines

boot/systemd-boot/Config.in line 7

Quoted 3 lines
boot/systemd-boot/Config.in new file +2 -0
+     select BR2_PACKAGE_UTIL_LINUX
+     select BR2_PACKAGE_UTIL_LINUX_LIBBLKID
Quoted 8 lines

Beware, that libblkid uses fork(), so needs an MMU, so you need to propagate that dependency with (the comment is to indicate that it's an inherited dependency):

depends on BR2_USE_MMU # util-linux' libblkid

But since we're only building the boot blobs, can we do away without util-linux?

The issue I was running into here is that systemd's meson build system will not work without util-linux, even though util-linux does not need to be installed for the bootloader to function.

Quoted 9 lines

Looking at an impothetical situation (e.g. recovery system, or a first-stage initramfs...):

minimalist system with just busybox,
- systemd-boot as bootloader

this would force having util-linux library, even though nothing would use them...

Yeah, this isn't ideal, from my discussions with systemd upstream there would need to be a major refactoring of their meson build system to allow building systemd-boot without util-linux. Is there a way to satisfy the util-linux requirement without actually installing util-linux into the target?

Quoted 14 lines

[--SNIP--]

Quoted 12 lines
boot/systemd-boot/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
boot/systemd-boot/loader.conf new file +0 -0
new file mode 100644
index 0000000..93b77b8
Quoted 8 lines

boot/systemd-boot/loader.conf line 2

Quoted 5 lines
boot/systemd-boot/loader.conf new file +2 -0
@@ -0,0 +1,2 @@
+timeout 3
+default buildroot

I see that your previous patch in systemd did not provide thoose two files.

I think I just had them in a different place, I'm not actually sure how useful it is to provide this since most setups will need to customize them in their post-image.sh. I included them since other packages like grub and gummiboot also provide defaults.

Quoted 3 lines

Note: we'd need a way to also share those two files (buildroot.conf and loader.conf) between systemd-boot and systemd.

With how I currently have things set up systemd-boot will install them for systemd if selected. When building the usespace part by itself these aren't neccesary as they would be expected to be created some time else such as runtime.

Quoted 23 lines
Quoted 7 lines
boot/systemd-boot/systemd-boot.mk new file +0 -0
new file mode 100644
index 0000000..7f97ef0

boot/systemd-boot/systemd-boot.mk line 7

Quoted 7 lines
boot/systemd-boot/systemd-boot.mk new file +7 -0
@@ -0,0 +1,126 @@
+################################################################################
+#
+# systemd-boot
+#
+################################################################################
+
+SYSTEMD_BOOT_VERSION = 239

You'll need to add a comment here and in systemd, to keep the versions in sync (like you've seen in mesa3d and mesa3d-headers).

boot/systemd-boot/systemd-boot.mk line 9

Quoted 2 lines
boot/systemd-boot/systemd-boot.mk new file +2 -0
+SYSTEMD_BOOT_SITE = $(call github,systemd,systemd,v$(SYSTEMD_BOOT_VERSION))
+SYSTEMD_BOOT_DL_SUBDIR = systemd

Yes! :-)

Quoted 14 lines

boot/systemd-boot/systemd-boot.mk line 20

Quoted 11 lines
boot/systemd-boot/systemd-boot.mk new file +11 -0
+SYSTEMD_BOOT_LICENSE = LGPL-2.1+, GPL-2.0+ (udev), Public Domain (few source files, see README)
+SYSTEMD_BOOT_LICENSE_FILES = LICENSE.GPL2 LICENSE.LGPL2.1 README
+SYSTEMD_BOOT_INSTALL_STAGING = NO
+SYSTEMD_BOOT_INSTALL_TARGET = NO
+SYSTEMD_BOOT_INSTALL_IMAGES = YES
+SYSTEMD_BOOT_DEPENDENCIES = \
+     gnu-efi \
+     util-linux
+ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
+SYSTEMD_BOOT_DEPENDENCIES += systemd
+endif

You can get rid of this dependency, once you switch to a depends on !SYSTEMD in the Config.in.

This is intentional since the systemd-boot package will essentially go into an install only mode when BR2_PACKAGE_SYSTEMD_BOOT is present as the bootloader can be simply copied out of the target filesystem.

Quoted 13 lines

boot/systemd-boot/systemd-boot.mk line 31

Quoted 11 lines
boot/systemd-boot/systemd-boot.mk new file +10 -0
+ifeq ($(BR2_i386),y)
+SYSTEMD_BOOT_IMGARCH = ia32
+else ifeq ($(BR2_x86_64),y)
+SYSTEMD_BOOT_IMGARCH = x64
+endif
+
+ifneq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
+SYSTEMD_BOOT_CONF_OPTS += \
+     -Drootlibdir='/usr/lib' \
+     -Dblkid=true \

Can we get rid of libblkid here?

I'll double check this, however I recall the systemd buildsystem would not function without present.

Quoted 11 lines

boot/systemd-boot/systemd-boot.mk line 40

Quoted 10 lines
boot/systemd-boot/systemd-boot.mk new file +9 -0
+     -Dman=false \
+     -Dima=false \
+     -Dlibcryptsetup=false \
+     -Defi=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 \
Quoted 2 lines

As far as I could see from the code, those 5 last options already default to the proper values. Why did you need to force them?

I'll double check if these are actually required, could have been left over testing code I had when trying to trace the meson build system issue https://patchwork.ozlabs.org/patch/1014226/.

Quoted 11 lines

boot/systemd-boot/systemd-boot.mk line 47

Quoted 8 lines
boot/systemd-boot/systemd-boot.mk new file +7 -0
+     -Dgnu-efi=true \
+     -Dldconfig=false \
+     -Ddefault-dnssec=no \
+     -Dtests=false \
+     -Dnobody-group=nogroup \
+     -Didn=true \
+     -Dnss-systemd=true \

Since we're only building the boot blobs, why do we need to have those two set to 'true', when all the rest is set to false?

I'll see if these can be removed.

Quoted 50 lines
Quoted 50 lines
boot/systemd-boot/systemd-boot.mk new file +49 -0
+     -Dacl=false \
+     -Daudit=false \
+     -Delfutils=false \
+     -Dlibidn=false \
+     -Dlibidn2=false \
+     -Dseccomp=false \
+     -Dxkbcommon=false \
+     -Dbzip2=false \
+     -Dlz4=false \
+     -Dpam=false \
+     -Dxz=false \
+     -Dzlib=false \
+     -Dlibcurl=false \
+     -Dgcrypt=false \
+     -Dpcre2=false \
+     -Dmicrohttpd=false \
+     -Dqrencode=false \
+     -Dselinux=false \
+     -Dhwdb=false \
+     -Dbinfmt=false \
+     -Dvconsole=false \
+     -Dquotacheck=false \
+     -Dtmpfiles=false \
+     -Dsysusers=false \
+     -Dfirstboot=false \
+     -Drandomseed=false \
+     -Dbacklight=false \
+     -Drfkill=false \
+     -Dlogind=false \
+     -Dmachined=false \
+     -Dimportd=false \
+     -Dhostnamed=false \
+     -Dmyhostname=false \
+     -Dtimedated=false \
+     -Dlocaled=false \
+     -Dcoredump=false \
+     -Dpolkit=false \
+     -Dnetworkd=false \
+     -Dresolve=false \
+     -Dtimesyncd=false \
+     -Dsmack=false \
+     -Dhibernate=false
+endif
+
+SYSTEMD_BOOT_CONF_ENV = $(HOST_UTF8_LOCALE_ENV)
+SYSTEMD_BOOT_NINJA_ENV = $(HOST_UTF8_LOCALE_ENV)
+
+ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
+define SYSTEMD_BOOT_BUILD_CMDS
Quoted 8 lines

boot/systemd-boot/systemd-boot.mk line 102

Quoted 6 lines
boot/systemd-boot/systemd-boot.mk new file +6 -0
+     mkdir -p $(@D)/build/src/boot/efi
+     cp $(TARGET_DIR)/usr/lib/systemd/boot/efi/systemd-boot$(SYSTEMD_BOOT_IMGARCH).efi \
+             $(@D)/build/src/boot/efi/systemd-boot$(SYSTEMD_BOOT_IMGARCH).efi
+     cp $(TARGET_DIR)/usr/lib/systemd/boot/efi/linux$(SYSTEMD_BOOT_IMGARCH).efi.stub \
+             $(@D)/build/src/boot/efi/linux$(SYSTEMD_BOOT_IMGARCH).efi.stub
+endef

You can now also get rid of this trick.

So I have things like this so that the bootloader built by the systemd package can be reused by the systemd-boot package. I could refactor things so that the systemd package has an option to install the bootloader itself although that will increase code duplication which I was trying to avoid, separating the installation stage would also make it harder to find the systemd-boot option in menuconfig when using a systemd init system as the only options for it would then be under the normal systemd package. It seemed to make sense to have the systemd-boot package be used to control whether the bootloader is installed to efi-part and have the systemd boot package merely handle userspace/rootfs bootloader build and installation. A potential use case for building the userspace components without the efi-part component is if one needs to create an installer/bootstrap image that must use an alternate bootloader such as grub while wanting to use the userspace tools to do the actual permanent runtime installation(of course this could also be controlled by the systemd package).

Do you think it makes sense to refactor things so that the bootloader image installation is handled within the systemd package when systemd init is selected or does it make sense to have the systemd-boot package control image installation when using systemd init.

Quoted 12 lines
Quoted 12 lines
boot/systemd-boot/systemd-boot.mk new file +11 -0
+else
+define SYSTEMD_BOOT_BUILD_CMDS
+     $(TARGET_MAKE_ENV) $(SYSTEMD_BOOT_NINJA_ENV) \
+             $(NINJA) $(NINJA_OPTS) -C $(@D)/build \
+             src/boot/efi/{systemd-boot$(SYSTEMD_BOOT_IMGARCH).efi,linux$(SYSTEMD_BOOT_IMGARCH).efi.stub}
+endef
+endif
+
+define SYSTEMD_BOOT_INSTALL_IMAGES_CMDS
+     $(INSTALL) -D -m 0644 $(@D)/build/src/boot/efi/systemd-boot$(SYSTEMD_BOOT_IMGARCH).efi \
+             $(BINARIES_DIR)/efi-part/EFI/BOOT/boot$(SYSTEMD_BOOT_IMGARCH).efi
Quoted 8 lines

boot/systemd-boot/systemd-boot.mk line 119

Quoted 6 lines
boot/systemd-boot/systemd-boot.mk new file +6 -0
+     echo "boot$(SYSTEMD_BOOT_IMGARCH).efi" > \
+             $(BINARIES_DIR)/efi-part/startup.nsh
+     $(INSTALL) -D -m 0644 $(SYSTEMD_BOOT_PKGDIR)/loader.conf \
+             $(BINARIES_DIR)/efi-part/loader/loader.conf
+     $(INSTALL) -D -m 0644 $(SYSTEMD_BOOT_PKGDIR)/buildroot.conf \
+             $(BINARIES_DIR)/efi-part/loader/entries/buildroot.conf

Should you not be doing the same in the systemd case?

Well with how this currently works the installation stage here will work even if systemd-boot is built as part of systemd.

Quoted 30 lines

Regards,
Yann E. MORIN.

Quoted 16 lines
boot/systemd-boot/systemd-boot.mk new file +7 -0
+endef
+
+ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
+$(eval $(generic-package))
+else
+$(eval $(meson-package))
+endif
boot/systemd-boot/systemd.hash new file +1 -1
new file mode 120000
index 0000000..4259f40
@@ -0,0 +1 @@
+../../package/systemd/systemd.hash
\ No newline at end of file
--
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.  |

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

#4 lore raw

PATCH 2/2 boot/systemd-boot: new package

James, All,

On 2018-12-24 16:44 -0600, James Hilliard spake thusly:

Quoted 3 lines · Yann E. MORIN
Quoted 2 lines

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

Quoted 1 line

From: James Hilliard <[email protected]>

[--SNIP--]

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

+ select BR2_PACKAGE_SYSTEMD_BOOT if BR2_INIT_SYSTEMD

I think it is much more simple if you just do:
depends on !BR2_PACKAGE_SYSTEMD

[--SNIP--]

Quoted 5 lines
Quoted 2 lines

That way, you don't have to need to be schizophrenic about being a generic-package or a meson-package. Just be a meson-package.

So I ended up doing things this way so that the systemd-boot package is used for the image installation regardless of where the bootloader is compiled.

Well, I don;t think that is interesting, becasue the duplication is not so big. There are in fact just a very few commands to do.

Besides, with the way you split the patches, if only the first one is applied, then the boot files are in fact not installed. So that is not good. You need to ensure that the series is functional (and makes sense) even if only partially applied.

Quoted 7 lines
Quoted 7 lines

boot/systemd-boot/Config.in line 7

Quoted 2 lines
boot/systemd-boot/Config.in new file +2 -0
+     select BR2_PACKAGE_UTIL_LINUX
+     select BR2_PACKAGE_UTIL_LINUX_LIBBLKID

Beware, that libblkid uses fork(), so needs an MMU, so you need to propagate that dependency with (the comment is to indicate that it's an inherited dependency):

Quoted 7 lines
Quoted 4 lines

depends on BR2_USE_MMU # util-linux' libblkid

But since we're only building the boot blobs, can we do away without util-linux?

The issue I was running into here is that systemd's meson build system will not work without util-linux, even though util-linux does not need to be installed for the bootloader to function.

I made a very small patch to no longer require that, but it is definietely not upstreamable. See below...

Quoted 11 lines
Quoted 8 lines

Looking at an impothetical situation (e.g. recovery system, or a first-stage initramfs...):

minimalist system with just busybox,
- systemd-boot as bootloader

this would force having util-linux library, even though nothing would use them...

Yeah, this isn't ideal, from my discussions with systemd upstream there would need to be a major refactoring of their meson build system to allow building systemd-boot without util-linux.

OK, I found your PR: https://github.com/systemd/systemd/pull/11141
Next time you say "I talked with upstream", please add a pointer, so we can go and see the discussion without asking you to explain all of it again. ;-)

Quoted 3 lines

Is there a way to
satisfy the util-linux requirement without actually installing util-linux into the target?

Needs a patch, see below...

Quoted 8 lines
Quoted 4 lines

boot/systemd-boot/loader.conf

Quoted 2 lines
boot/systemd-boot/buildroot.conf +0 -0
boot/systemd-boot/loader.conf +0 -0

I see that your previous patch in systemd did not provide thoose two files.

I think I just had them in a different place, I'm not actually sure how useful it is to provide this since most setups will need to customize them in their post-image.sh. I included them since other packages like grub and gummiboot also provide defaults.

As I said previously, I don't think it is a good idea. And as explained above, that means your series is not working is only the first patch is applied.

[--SNIP--]

Quoted 3 lines
Quoted 3 lines

boot/systemd-boot/loader.conf

Quoted 2 lines
boot/systemd-boot/loader.conf +2 -0
+SYSTEMD_BOOT_SITE = $(call github,systemd,systemd,v$(SYSTEMD_BOOT_VERSION))
+SYSTEMD_BOOT_DL_SUBDIR = systemd

Yes! :-)

In fact, it does not work as expected, because the generated tarball is named ''systemd-boot-239.tar.gz instead of 'systemd-239.tar.gz'.

But it can be made to work by adding an explicit:

    SYSTEMD_BOOT_SOURCE = systemd-$(SYSTEMD_BOOT_VERSION).tar.gz

[--SNIP--]

Quoted 10 lines
Quoted 10 lines

boot/systemd-boot/loader.conf

Quoted 8 lines
boot/systemd-boot/loader.conf +8 -0
+ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
+define SYSTEMD_BOOT_BUILD_CMDS
+     mkdir -p $(@D)/build/src/boot/efi
+     cp $(TARGET_DIR)/usr/lib/systemd/boot/efi/systemd-boot$(SYSTEMD_BOOT_IMGARCH).efi \
+             $(@D)/build/src/boot/efi/systemd-boot$(SYSTEMD_BOOT_IMGARCH).efi
+     cp $(TARGET_DIR)/usr/lib/systemd/boot/efi/linux$(SYSTEMD_BOOT_IMGARCH).efi.stub \
+             $(@D)/build/src/boot/efi/linux$(SYSTEMD_BOOT_IMGARCH).efi.stub
+endef

You can now also get rid of this trick.

Quoted 2 lines

So I have things like this so that the bootloader built by the systemd package can be reused by the systemd-boot package.

Yeah, I understand why you did that (but you should have said so in the commit log), and I still do not think it is worth the complexity.

Yet, to prove how much more simple it is if you just accept the little duplication, and because I did not have anything better to do during x-mas, please have a look at the series I prepared, last three commits on:
https://git.buildroot.org/~ymorin/git/buildroot/log?h=yem/systemd-boot

I tested building systemd-boot standalone, and it works (not sure it boots, I did not run-test it). I however did not try to test-build the config where it is provided by systemd itself; I'll let it to you as an exercise. ;-)

Feel free to grab those commits and ammend them further if needed; if not, just grab them and resend them (you can git-fetch from
git://git.buildroot.org/~ymorin/git/buildroot).

However, if you do add new features (TPM, more archs), please do so as additional patches, so the whole series is easier to review.

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.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH 2/2 boot/systemd-boot: new package

Quoted 18 lines · Yann E. MORIN

James, All,

On 2018-12-24 16:44 -0600, James Hilliard spake thusly:

Quoted 3 lines · Yann E. MORIN
Quoted 2 lines

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

Quoted 1 line

From: James Hilliard <[email protected]>

[--SNIP--]

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

+ select BR2_PACKAGE_SYSTEMD_BOOT if BR2_INIT_SYSTEMD

I think it is much more simple if you just do:
depends on !BR2_PACKAGE_SYSTEMD

[--SNIP--]

Quoted 5 lines
Quoted 2 lines

That way, you don't have to need to be schizophrenic about being a generic-package or a meson-package. Just be a meson-package.

So I ended up doing things this way so that the systemd-boot package is used for the image installation regardless of where the bootloader is compiled.

Quoted 7 lines

Well, I don;t think that is interesting, becasue the duplication is not so big. There are in fact just a very few commands to do.

Besides, with the way you split the patches, if only the first one is applied, then the boot files are in fact not installed. So that is not good. You need to ensure that the series is functional (and makes sense) even if only partially applied.

It is actually functional but only when used in a somewhat non-standard way, if you don't do the images install step you still have the bootloader installed to the target rootfs where it is useful for runtime installs. This is a somewhat exotic use case, I do use use runtime installs myself but I use systemd-boot for both the image and the runtime install so I don't need this flexibility myself although I could see others potentially needing it. One potential use case for this would be if someone needs to create a runtime installer that will dynamically choose to install grub or systemd-boot depending on the target system configuration but needs to build the image(for say a USB jump drive) which uses grub for booting itself but installs systemd-boot to the internal hard disk.

Quoted 90 lines
Quoted 8 lines
Quoted 8 lines

boot/systemd-boot/Config.in line 7

Quoted 3 lines
boot/systemd-boot/Config.in new file +2 -0
+     select BR2_PACKAGE_UTIL_LINUX
+     select BR2_PACKAGE_UTIL_LINUX_LIBBLKID

Beware, that libblkid uses fork(), so needs an MMU, so you need to propagate that dependency with (the comment is to indicate that it's an inherited dependency):

Quoted 7 lines
Quoted 4 lines

depends on BR2_USE_MMU # util-linux' libblkid

But since we're only building the boot blobs, can we do away without util-linux?

The issue I was running into here is that systemd's meson build system will not work without util-linux, even though util-linux does not need to be installed for the bootloader to function.

I made a very small patch to no longer require that, but it is definietely not upstreamable. See below...

Quoted 11 lines
Quoted 8 lines

Looking at an impothetical situation (e.g. recovery system, or a first-stage initramfs...):

minimalist system with just busybox,
- systemd-boot as bootloader

this would force having util-linux library, even though nothing would use them...

Yeah, this isn't ideal, from my discussions with systemd upstream there would need to be a major refactoring of their meson build system to allow building systemd-boot without util-linux.

OK, I found your PR: https://github.com/systemd/systemd/pull/11141
Next time you say "I talked with upstream", please add a pointer, so we can go and see the discussion without asking you to explain all of it again. ;-)

Quoted 3 lines

Is there a way to
satisfy the util-linux requirement without actually installing util-linux into the target?

Needs a patch, see below...

Quoted 8 lines
Quoted 4 lines

boot/systemd-boot/loader.conf

Quoted 2 lines
boot/systemd-boot/buildroot.conf +0 -0
boot/systemd-boot/loader.conf +0 -0

I see that your previous patch in systemd did not provide thoose two files.

I think I just had them in a different place, I'm not actually sure how useful it is to provide this since most setups will need to customize them in their post-image.sh. I included them since other packages like grub and gummiboot also provide defaults.

As I said previously, I don't think it is a good idea. And as explained above, that means your series is not working is only the first patch is applied.

[--SNIP--]

Quoted 3 lines
Quoted 3 lines

boot/systemd-boot/loader.conf

Quoted 2 lines
boot/systemd-boot/loader.conf +2 -0
+SYSTEMD_BOOT_SITE = $(call github,systemd,systemd,v$(SYSTEMD_BOOT_VERSION))
+SYSTEMD_BOOT_DL_SUBDIR = systemd

Yes! :-)

In fact, it does not work as expected, because the generated tarball is named ''systemd-boot-239.tar.gz instead of 'systemd-239.tar.gz'.

But it can be made to work by adding an explicit:

    SYSTEMD_BOOT_SOURCE = systemd-$(SYSTEMD_BOOT_VERSION).tar.gz

[--SNIP--]

Quoted 10 lines
Quoted 10 lines

boot/systemd-boot/loader.conf

Quoted 8 lines
boot/systemd-boot/loader.conf +8 -0
+ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
+define SYSTEMD_BOOT_BUILD_CMDS
+     mkdir -p $(@D)/build/src/boot/efi
+     cp $(TARGET_DIR)/usr/lib/systemd/boot/efi/systemd-boot$(SYSTEMD_BOOT_IMGARCH).efi \
+             $(@D)/build/src/boot/efi/systemd-boot$(SYSTEMD_BOOT_IMGARCH).efi
+     cp $(TARGET_DIR)/usr/lib/systemd/boot/efi/linux$(SYSTEMD_BOOT_IMGARCH).efi.stub \
+             $(@D)/build/src/boot/efi/linux$(SYSTEMD_BOOT_IMGARCH).efi.stub
+endef

You can now also get rid of this trick.

Quoted 2 lines

So I have things like this so that the bootloader built by the systemd package can be reused by the systemd-boot package.

Yeah, I understand why you did that (but you should have said so in the commit log), and I still do not think it is worth the complexity.

Yet, to prove how much more simple it is if you just accept the little duplication, and because I did not have anything better to do during x-mas, please have a look at the series I prepared, last three commits on:
https://git.buildroot.org/~ymorin/git/buildroot/log?h=yem/systemd-boot

Quoted 8 lines

I tested building systemd-boot standalone, and it works (not sure it boots, I did not run-test it). I however did not try to test-build the config where it is provided by systemd itself; I'll let it to you as an exercise. ;-)

Feel free to grab those commits and ammend them further if needed; if not, just grab them and resend them (you can git-fetch from
git://git.buildroot.org/~ymorin/git/buildroot).

Will do, I agree your approach is simpler and easier to understand.

Quoted 3 lines

However, if you do add new features (TPM, more archs), please do so as additional patches, so the whole series is easier to review.

I'll follow up on that after initial systemd-boot support is merged.

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.  |

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

#6 lore raw

PATCH 1/2 package/systemd: add systemd-boot build option

In reply to james.hilliard1 at gmail.com

James, All,

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

Quoted 1 line

From: James Hilliard <[email protected]>

This is starting to look nice! Thanks for the respin! :-)

So, this is supposed to replace gummiboot, for which we already do have a package, so I'd have expected a further patch last in the series, which would get rid of gummiboot.

See also a few comments, below...

Quoted 11 lines
---
 package/systemd/Config.in  | 21 +++++++++++++++++++++
 package/systemd/systemd.mk |  8 ++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)
package/systemd/Config.in +0 -0
index 25f322e..ff71323 100644

package/systemd/Config.in if BR2_PACKAGE_SYSTEMD · line 82

Quoted 6 lines
package/systemd/Config.in +3 -0
@@ -77,6 +77,27 @@ if BR2_PACKAGE_SYSTEMD
 config BR2_PACKAGE_PROVIDES_UDEV
 	default "systemd"
 
+config BR2_PACKAGE_SYSTEMD_BOOT
+	bool "systemd-boot"
+	select BR2_PACKAGE_GNU_EFI

So, you select gnu-efi, but you did not propagate the dependencies from it, i.e. you need to add:

    # gnu-efi
    depends on BR2_ARM_CPU_HAS_ARM || BR2_aarch64 || \
            BR2_aarch64_be || BR2_i386 || BR2_x86_64

However, gummi-boot is currently only available for x86 and x86_64. Was that somehow lifted for systemd-boot?

Furthermore, there is no dependency expressed in the systemd.mk file (see continuation [0], below...)

Quoted 30 lines
package/systemd/Config.in +13 -0
+	  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/
+
 config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
 	bool "HTTP server for journal events"
 	select BR2_PACKAGE_LIBMICROHTTPD
package/systemd/systemd.mk +0 -2
index e53f0b6..0fa3b83 100644
@@ -24,8 +24,6 @@ SYSTEMD_CONF_OPTS += \
 	-Dman=false \
 	-Dima=false \
 	-Dlibcryptsetup=false \
-	-Defi=false \
-	-Dgnu-efi=false \
 	-Dldconfig=false \
 	-Ddefault-dnssec=no \
 	-Dtests=false \

package/systemd/systemd.mk else · line 333

Quoted 4 lines
package/systemd/systemd.mk +1 -0
@@ -332,6 +330,12 @@ else
 SYSTEMD_CONF_OPTS += -Dhibernate=false
 endif
 
+ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)

[0] ... here, where you probably need something like:

    SYSTEMD_DEPENDENCIES += gnu-efi

package/systemd/systemd.mk else · line 334

Quoted 1 line
package/systemd/systemd.mk +1 -0
+SYSTEMD_CONF_OPTS += -Defi=true -Dgnu-efi=true

And once you enable gnu-efi, you also unlock -Dtpm and -Dtpm-pcrindex. Would it make sense to at least disable with -Dtpm=false ?

Regards,
Yann E. MORIN.

Quoted 10 lines
package/systemd/systemd.mk +4 -0
+else
+SYSTEMD_CONF_OPTS += -Defi=false -Dgnu-efi=false
+endif
+
 SYSTEMD_FALLBACK_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
 ifneq ($(SYSTEMD_FALLBACK_HOSTNAME),)
 SYSTEMD_CONF_OPTS += -Dfallback-hostname=$(SYSTEMD_FALLBACK_HOSTNAME)
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.  |
'------------------------------^-------^------------------^--------------------'
#7 lore raw

PATCH 1/2 package/systemd: add systemd-boot build option

James, All,

On 2018-12-19 18:32 +0100, Yann E. MORIN spake thusly:

Quoted 3 lines

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

Quoted 1 line

From: James Hilliard <[email protected]>

This is starting to look nice! Thanks for the respin! :-)

I was about to review tyour second patch, but got side-tracked and time passed too fast. I'll come back to it tomorrow, or this WE...

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.  |
'------------------------------^-------^------------------^--------------------'
#8 lore raw

PATCH 1/2 package/systemd: add systemd-boot build option

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

James, All,

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

Quoted 1 line

From: James Hilliard <[email protected]>

This is starting to look nice! Thanks for the respin! :-)

So, this is supposed to replace gummiboot, for which we already do have a package, so I'd have expected a further patch last in the series, which would get rid of gummiboot.

Well I didn't want to do that yet since it's not exactly a drop in replacement. Gummiboot was brought under the systemd-boot project umbrella but because of that the userspace tools became dependent on systemd.

Quoted 24 lines

See also a few comments, below...

Quoted 11 lines
---
 package/systemd/Config.in  | 21 +++++++++++++++++++++
 package/systemd/systemd.mk |  8 ++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)
package/systemd/Config.in +0 -0
index 25f322e..ff71323 100644

package/systemd/Config.in if BR2_PACKAGE_SYSTEMD · line 82

Quoted 6 lines
package/systemd/Config.in +3 -0
@@ -77,6 +77,27 @@ if BR2_PACKAGE_SYSTEMD
 config BR2_PACKAGE_PROVIDES_UDEV
      default "systemd"
 
+config BR2_PACKAGE_SYSTEMD_BOOT
+     bool "systemd-boot"
+     select BR2_PACKAGE_GNU_EFI

So, you select gnu-efi, but you did not propagate the dependencies from it, i.e. you need to add:

Quoted 6 lines
    # gnu-efi
    depends on BR2_ARM_CPU_HAS_ARM || BR2_aarch64 || \
            BR2_aarch64_be || BR2_i386 || BR2_x86_64

However, gummi-boot is currently only available for x86 and x86_64. Was that somehow lifted for systemd-boot?

Appears it also supports arm and aarch64(https://github.com/systemd/systemd/blob/v239/meson.build#L1245-L1256), I'll tweak the build to add support for those.

Quoted 37 lines

Furthermore, there is no dependency expressed in the systemd.mk file (see continuation [0], below...)

Quoted 33 lines
package/systemd/Config.in +13 -0
+       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/
+
 config BR2_PACKAGE_SYSTEMD_JOURNAL_GATEWAY
      bool "HTTP server for journal events"
      select BR2_PACKAGE_LIBMICROHTTPD
package/systemd/systemd.mk +0 -2
index e53f0b6..0fa3b83 100644
@@ -24,8 +24,6 @@ SYSTEMD_CONF_OPTS += \
      -Dman=false \
      -Dima=false \
      -Dlibcryptsetup=false \
-     -Defi=false \
-     -Dgnu-efi=false \
      -Dldconfig=false \
      -Ddefault-dnssec=no \
      -Dtests=false \
@@ -332,6 +330,12 @@ else
 SYSTEMD_CONF_OPTS += -Dhibernate=false
 endif
 
Quoted 3 lines

package/systemd/systemd.mk else · line 333

Quoted 1 line
package/systemd/systemd.mk +1 -0
+ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)

[0] ... here, where you probably need something like:

will add that

Quoted 7 lines
    SYSTEMD_DEPENDENCIES += gnu-efi

package/systemd/systemd.mk else · line 334

Quoted 1 line
package/systemd/systemd.mk +1 -0
+SYSTEMD_CONF_OPTS += -Defi=true -Dgnu-efi=true

And once you enable gnu-efi, you also unlock -Dtpm and -Dtpm-pcrindex. Would it make sense to at least disable with -Dtpm=false ?

I guess I should probably also add an option for building with tpm support.

Quoted 22 lines

Regards,
Yann E. MORIN.

Quoted 10 lines
package/systemd/systemd.mk +4 -1
+else
+SYSTEMD_CONF_OPTS += -Defi=false -Dgnu-efi=false
+endif
+
 SYSTEMD_FALLBACK_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
 ifneq ($(SYSTEMD_FALLBACK_HOSTNAME),)
 SYSTEMD_CONF_OPTS += -Dfallback-hostname=$(SYSTEMD_FALLBACK_HOSTNAME)
--

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.  |

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

#9 lore raw

PATCH 1/2 package/systemd: add systemd-boot build option

James,

On 2018-12-19 14:55 -0700, James Hilliard spake thusly:

Quoted 5 lines · Yann E. MORIN
Quoted 4 lines

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

Quoted 1 line

From: James Hilliard <[email protected]>

This is starting to look nice! Thanks for the respin! :-)

I did a few other comments in your second patch, that may have an impact on that one.

Quoted 7 lines
Quoted 3 lines

So, this is supposed to replace gummiboot, for which we already do have a package, so I'd have expected a further patch last in the series, which would get rid of gummiboot.

Well I didn't want to do that yet since it's not exactly a drop in replacement. Gummiboot was brought under the systemd-boot project umbrella but because of that the userspace tools became dependent on systemd.

Yes, Ok, so it is not a 100% replacement, so it makes sense to still keep gummiboot for now.

Quoted 27 lines
Quoted 27 lines

See also a few comments, below...

Quoted 11 lines
---
 package/systemd/Config.in  | 21 +++++++++++++++++++++
 package/systemd/systemd.mk |  8 ++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)
package/systemd/Config.in +0 -0
index 25f322e..ff71323 100644

package/systemd/Config.in if BR2_PACKAGE_SYSTEMD · line 82

Quoted 6 lines
package/systemd/Config.in +3 -0
@@ -77,6 +77,27 @@ if BR2_PACKAGE_SYSTEMD
 config BR2_PACKAGE_PROVIDES_UDEV
      default "systemd"
 
+config BR2_PACKAGE_SYSTEMD_BOOT
+     bool "systemd-boot"
+     select BR2_PACKAGE_GNU_EFI

So, you select gnu-efi, but you did not propagate the dependencies from it, i.e. you need to add:

    # gnu-efi
    depends on BR2_ARM_CPU_HAS_ARM || BR2_aarch64 || \
            BR2_aarch64_be || BR2_i386 || BR2_x86_64
Quoted 5 lines
Quoted 2 lines

However, gummi-boot is currently only available for x86 and x86_64. Was that somehow lifted for systemd-boot?

Appears it also supports arm and aarch64(https://github.com/systemd/systemd/blob/v239/meson.build#L1245-L1256), I'll tweak the build to add support for those.

As I said when reviewing patch 2, limit yourself to the architecture you are isnterestd in, and that you can actually test.

If someone else is intrerested in adding support for another arch, they'll submit a patch.

[--SNIP--]

Quoted 5 lines
Quoted 4 lines

package/systemd/Config.in if BR2_PACKAGE_SYSTEMD · line 83

Quoted 1 line
package/systemd/Config.in +1 -0
+SYSTEMD_CONF_OPTS += -Defi=true -Dgnu-efi=true

And once you enable gnu-efi, you also unlock -Dtpm and -Dtpm-pcrindex. Would it make sense to at least disable with -Dtpm=false ?

I guess I should probably also add an option for building with tpm support.

Unless you can use and test it, just default it to false for now. And in anycase, that should be a separate patch.

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.  |
'------------------------------^-------^------------------^--------------------'
#10 lore raw

PATCH 1/2 package/systemd: add systemd-boot build option

Quoted 64 lines · Yann E. MORIN

James,

On 2018-12-19 14:55 -0700, James Hilliard spake thusly:

Quoted 5 lines · Yann E. MORIN
Quoted 4 lines

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

Quoted 1 line

From: James Hilliard <[email protected]>

This is starting to look nice! Thanks for the respin! :-)

I did a few other comments in your second patch, that may have an impact on that one.

Quoted 7 lines
Quoted 3 lines

So, this is supposed to replace gummiboot, for which we already do have a package, so I'd have expected a further patch last in the series, which would get rid of gummiboot.

Well I didn't want to do that yet since it's not exactly a drop in replacement. Gummiboot was brought under the systemd-boot project umbrella but because of that the userspace tools became dependent on systemd.

Yes, Ok, so it is not a 100% replacement, so it makes sense to still keep gummiboot for now.

Quoted 27 lines
Quoted 27 lines

See also a few comments, below...

Quoted 11 lines
---
 package/systemd/Config.in  | 21 +++++++++++++++++++++
 package/systemd/systemd.mk |  8 ++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)
package/systemd/Config.in +0 -0
index 25f322e..ff71323 100644

package/systemd/Config.in if BR2_PACKAGE_SYSTEMD · line 82

Quoted 6 lines
package/systemd/Config.in +3 -0
@@ -77,6 +77,27 @@ if BR2_PACKAGE_SYSTEMD
 config BR2_PACKAGE_PROVIDES_UDEV
      default "systemd"
 
+config BR2_PACKAGE_SYSTEMD_BOOT
+     bool "systemd-boot"
+     select BR2_PACKAGE_GNU_EFI

So, you select gnu-efi, but you did not propagate the dependencies from it, i.e. you need to add:

    # gnu-efi
    depends on BR2_ARM_CPU_HAS_ARM || BR2_aarch64 || \
            BR2_aarch64_be || BR2_i386 || BR2_x86_64
Quoted 5 lines
Quoted 2 lines

However, gummi-boot is currently only available for x86 and x86_64. Was that somehow lifted for systemd-boot?

Appears it also supports arm and aarch64(https://github.com/systemd/systemd/blob/v239/meson.build#L1245-L1256), I'll tweak the build to add support for those.

As I said when reviewing patch 2, limit yourself to the architecture you are isnterestd in, and that you can actually test.

If someone else is intrerested in adding support for another arch, they'll submit a patch.

[--SNIP--]

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

package/systemd/Config.in if BR2_PACKAGE_SYSTEMD · line 83

Quoted 1 line
package/systemd/Config.in +1 -0
+SYSTEMD_CONF_OPTS += -Defi=true -Dgnu-efi=true

And once you enable gnu-efi, you also unlock -Dtpm and -Dtpm-pcrindex. Would it make sense to at least disable with -Dtpm=false ?

I guess I should probably also add an option for building with tpm support.

Unless you can use and test it, just default it to false for now. And in anycase, that should be a separate patch.

I would like to use a tpm when present although my prototyping hardware doesn't currently have one, I should be at least able to verify that tpm support can be built properly however.

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.  |

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