All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option
@ 2018-12-18 23:41 james.hilliard1 at gmail.com
  2018-12-18 23:41 ` [Buildroot] [PATCH 2/2] boot/systemd-boot: new package james.hilliard1 at gmail.com
  2018-12-19 17:32 ` [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option Yann E. MORIN
  0 siblings, 2 replies; 11+ messages in thread
From: james.hilliard1 at gmail.com @ 2018-12-18 23:41 UTC (permalink / raw)
  To: buildroot

From: James Hilliard <james.hilliard1@gmail.com>

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 package/systemd/Config.in  | 21 +++++++++++++++++++++
 package/systemd/systemd.mk |  8 ++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/package/systemd/Config.in b/package/systemd/Config.in
index 25f322e..ff71323 100644
--- a/package/systemd/Config.in
+++ b/package/systemd/Config.in
@@ -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
diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
index e53f0b6..0fa3b83 100644
--- a/package/systemd/systemd.mk
+++ b/package/systemd/systemd.mk
@@ -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)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 2/2] boot/systemd-boot: new package
  2018-12-18 23:41 [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option james.hilliard1 at gmail.com
@ 2018-12-18 23:41 ` james.hilliard1 at gmail.com
  2018-12-24 21:26   ` Yann E. MORIN
  2018-12-19 17:32 ` [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option Yann E. MORIN
  1 sibling, 1 reply; 11+ messages in thread
From: james.hilliard1 at gmail.com @ 2018-12-18 23:41 UTC (permalink / raw)
  To: buildroot

From: James Hilliard <james.hilliard1@gmail.com>

This is essentially the successor to gummiboot.

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

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 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

diff --git a/boot/Config.in b/boot/Config.in
index 8e0c8e5..5b7f606 100644
--- a/boot/Config.in
+++ b/boot/Config.in
@@ -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"
diff --git a/boot/systemd-boot/0001-fix-getty-unit.patch b/boot/systemd-boot/0001-fix-getty-unit.patch
new file mode 120000
index 0000000..ffb5f53
--- /dev/null
+++ b/boot/systemd-boot/0001-fix-getty-unit.patch
@@ -0,0 +1 @@
+../../package/systemd/0001-fix-getty-unit.patch
\ No newline at end of file
diff --git a/boot/systemd-boot/0002-install-don-t-use-ln-relative.patch b/boot/systemd-boot/0002-install-don-t-use-ln-relative.patch
new file mode 120000
index 0000000..cfe0291
--- /dev/null
+++ b/boot/systemd-boot/0002-install-don-t-use-ln-relative.patch
@@ -0,0 +1 @@
+../../package/systemd/0002-install-don-t-use-ln-relative.patch
\ No newline at end of file
diff --git a/boot/systemd-boot/0003-build-sys-Detect-whether-struct-statx-is-defined-in-.patch b/boot/systemd-boot/0003-build-sys-Detect-whether-struct-statx-is-defined-in-.patch
new file mode 120000
index 0000000..ded8b4f
--- /dev/null
+++ b/boot/systemd-boot/0003-build-sys-Detect-whether-struct-statx-is-defined-in-.patch
@@ -0,0 +1 @@
+../../package/systemd/0003-build-sys-Detect-whether-struct-statx-is-defined-in-.patch
\ No newline at end of file
diff --git a/boot/systemd-boot/0004-meson-unify-linux-stat.h-check-with-other-checks-and.patch b/boot/systemd-boot/0004-meson-unify-linux-stat.h-check-with-other-checks-and.patch
new file mode 120000
index 0000000..32bc435
--- /dev/null
+++ b/boot/systemd-boot/0004-meson-unify-linux-stat.h-check-with-other-checks-and.patch
@@ -0,0 +1 @@
+../../package/systemd/0004-meson-unify-linux-stat.h-check-with-other-checks-and.patch
\ No newline at end of file
diff --git a/boot/systemd-boot/0005-dhcp6-make-sure-we-have-enough-space-for-the-DHCP6-o.patch b/boot/systemd-boot/0005-dhcp6-make-sure-we-have-enough-space-for-the-DHCP6-o.patch
new file mode 120000
index 0000000..003d6a7
--- /dev/null
+++ b/boot/systemd-boot/0005-dhcp6-make-sure-we-have-enough-space-for-the-DHCP6-o.patch
@@ -0,0 +1 @@
+../../package/systemd/0005-dhcp6-make-sure-we-have-enough-space-for-the-DHCP6-o.patch
\ No newline at end of file
diff --git a/boot/systemd-boot/0006-meson.build-fix-detection-of-Werror-shadow.patch b/boot/systemd-boot/0006-meson.build-fix-detection-of-Werror-shadow.patch
new file mode 120000
index 0000000..0e0a5cf
--- /dev/null
+++ b/boot/systemd-boot/0006-meson.build-fix-detection-of-Werror-shadow.patch
@@ -0,0 +1 @@
+../../package/systemd/0006-meson.build-fix-detection-of-Werror-shadow.patch
\ No newline at end of file
diff --git a/boot/systemd-boot/Config.in b/boot/systemd-boot/Config.in
new file mode 100644
index 0000000..922bb07
--- /dev/null
+++ b/boot/systemd-boot/Config.in
@@ -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/
diff --git a/boot/systemd-boot/buildroot.conf b/boot/systemd-boot/buildroot.conf
new file mode 100644
index 0000000..16d4d85
--- /dev/null
+++ b/boot/systemd-boot/buildroot.conf
@@ -0,0 +1,3 @@
+title	Buildroot
+linux	/bzImage
+options	root=/dev/sda2 rootwait console=tty1
diff --git a/boot/systemd-boot/loader.conf b/boot/systemd-boot/loader.conf
new file mode 100644
index 0000000..93b77b8
--- /dev/null
+++ b/boot/systemd-boot/loader.conf
@@ -0,0 +1,2 @@
+timeout 3
+default buildroot
diff --git a/boot/systemd-boot/systemd-boot.mk b/boot/systemd-boot/systemd-boot.mk
new file mode 100644
index 0000000..7f97ef0
--- /dev/null
+++ b/boot/systemd-boot/systemd-boot.mk
@@ -0,0 +1,126 @@
+################################################################################
+#
+# systemd-boot
+#
+################################################################################
+
+SYSTEMD_BOOT_VERSION = 239
+SYSTEMD_BOOT_SITE = $(call github,systemd,systemd,v$(SYSTEMD_BOOT_VERSION))
+SYSTEMD_BOOT_DL_SUBDIR = systemd
+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
+
+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 \
+	-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 \
+	-Dgnu-efi=true \
+	-Dldconfig=false \
+	-Ddefault-dnssec=no \
+	-Dtests=false \
+	-Dnobody-group=nogroup \
+	-Didn=true \
+	-Dnss-systemd=true \
+	-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
+	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
+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
+	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
+endef
+
+ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
+$(eval $(generic-package))
+else
+$(eval $(meson-package))
+endif
diff --git a/boot/systemd-boot/systemd.hash b/boot/systemd-boot/systemd.hash
new file mode 120000
index 0000000..4259f40
--- /dev/null
+++ b/boot/systemd-boot/systemd.hash
@@ -0,0 +1 @@
+../../package/systemd/systemd.hash
\ No newline at end of file
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option
  2018-12-18 23:41 [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option james.hilliard1 at gmail.com
  2018-12-18 23:41 ` [Buildroot] [PATCH 2/2] boot/systemd-boot: new package james.hilliard1 at gmail.com
@ 2018-12-19 17:32 ` Yann E. MORIN
  2018-12-19 21:40   ` Yann E. MORIN
  2018-12-19 21:55   ` James Hilliard
  1 sibling, 2 replies; 11+ messages in thread
From: Yann E. MORIN @ 2018-12-19 17:32 UTC (permalink / raw)
  To: buildroot

James, All,

On 2018-12-19 07:41 +0800, james.hilliard1 at gmail.com spake thusly:
> From: James Hilliard <james.hilliard1@gmail.com>

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

> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
>  package/systemd/Config.in  | 21 +++++++++++++++++++++
>  package/systemd/systemd.mk |  8 ++++++--
>  2 files changed, 27 insertions(+), 2 deletions(-)
> 
> diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> index 25f322e..ff71323 100644
> --- a/package/systemd/Config.in
> +++ b/package/systemd/Config.in
> @@ -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...)

> +	  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
> diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
> index e53f0b6..0fa3b83 100644
> --- a/package/systemd/systemd.mk
> +++ b/package/systemd/systemd.mk
> @@ -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)

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

    SYSTEMD_DEPENDENCIES += gnu-efi

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

> +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.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option
  2018-12-19 17:32 ` [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option Yann E. MORIN
@ 2018-12-19 21:40   ` Yann E. MORIN
  2018-12-19 21:55   ` James Hilliard
  1 sibling, 0 replies; 11+ messages in thread
From: Yann E. MORIN @ 2018-12-19 21:40 UTC (permalink / raw)
  To: buildroot

James, All,

On 2018-12-19 18:32 +0100, Yann E. MORIN spake thusly:
> On 2018-12-19 07:41 +0800, james.hilliard1 at gmail.com spake thusly:
> > From: James Hilliard <james.hilliard1@gmail.com>
> 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.

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option
  2018-12-19 17:32 ` [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option Yann E. MORIN
  2018-12-19 21:40   ` Yann E. MORIN
@ 2018-12-19 21:55   ` James Hilliard
  2018-12-24 21:30     ` Yann E. MORIN
  1 sibling, 1 reply; 11+ messages in thread
From: James Hilliard @ 2018-12-19 21:55 UTC (permalink / raw)
  To: buildroot

On Wed, Dec 19, 2018 at 10:32 AM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>
> James, All,
>
> On 2018-12-19 07:41 +0800, james.hilliard1 at gmail.com spake thusly:
> > From: James Hilliard <james.hilliard1@gmail.com>
>
> 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.
>
> See also a few comments, below...
>
> > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> > ---
> >  package/systemd/Config.in  | 21 +++++++++++++++++++++
> >  package/systemd/systemd.mk |  8 ++++++--
> >  2 files changed, 27 insertions(+), 2 deletions(-)
> >
> > diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> > index 25f322e..ff71323 100644
> > --- a/package/systemd/Config.in
> > +++ b/package/systemd/Config.in
> > @@ -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?
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.
>
> Furthermore, there is no dependency expressed in the systemd.mk file
> (see continuation [0], below...)
>
> > +       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
> > diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
> > index e53f0b6..0fa3b83 100644
> > --- a/package/systemd/systemd.mk
> > +++ b/package/systemd/systemd.mk
> > @@ -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)
>
> [0] ... here, where you probably need something like:
will add that
>
>     SYSTEMD_DEPENDENCIES += gnu-efi
>
> > +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.
>
> Regards,
> Yann E. MORIN.
>
> > +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.  |
> '------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 2/2] boot/systemd-boot: new package
  2018-12-18 23:41 ` [Buildroot] [PATCH 2/2] boot/systemd-boot: new package james.hilliard1 at gmail.com
@ 2018-12-24 21:26   ` Yann E. MORIN
  2018-12-24 22:44     ` James Hilliard
  0 siblings, 1 reply; 11+ messages in thread
From: Yann E. MORIN @ 2018-12-24 21:26 UTC (permalink / raw)
  To: buildroot

James, All,

On 2018-12-19 07:41 +0800, james.hilliard1 at gmail.com spake thusly:
> From: James Hilliard <james.hilliard1@gmail.com>
> 
> 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...

> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
[--SNIP--]
> diff --git a/boot/systemd-boot/Config.in b/boot/systemd-boot/Config.in
> new file mode 100644
> index 0000000..922bb07
> --- /dev/null
> +++ b/boot/systemd-boot/Config.in
> @@ -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.

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

> +	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--]
> diff --git a/boot/systemd-boot/buildroot.conf b/boot/systemd-boot/buildroot.conf
> new file mode 100644
> index 0000000..16d4d85
> --- /dev/null
> +++ b/boot/systemd-boot/buildroot.conf
> @@ -0,0 +1,3 @@
> +title	Buildroot
> +linux	/bzImage
> +options	root=/dev/sda2 rootwait console=tty1
> diff --git a/boot/systemd-boot/loader.conf b/boot/systemd-boot/loader.conf
> new file mode 100644
> index 0000000..93b77b8
> --- /dev/null
> +++ b/boot/systemd-boot/loader.conf
> @@ -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.

> diff --git a/boot/systemd-boot/systemd-boot.mk b/boot/systemd-boot/systemd-boot.mk
> new file mode 100644
> index 0000000..7f97ef0
> --- /dev/null
> +++ b/boot/systemd-boot/systemd-boot.mk
> @@ -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).

> +SYSTEMD_BOOT_SITE = $(call github,systemd,systemd,v$(SYSTEMD_BOOT_VERSION))
> +SYSTEMD_BOOT_DL_SUBDIR = systemd

Yes! :-)

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

> +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?

> +	-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?

> +	-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?

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

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

> +endef
> +
> +ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
> +$(eval $(generic-package))
> +else
> +$(eval $(meson-package))
> +endif
> diff --git a/boot/systemd-boot/systemd.hash b/boot/systemd-boot/systemd.hash
> new file mode 120000
> index 0000000..4259f40
> --- /dev/null
> +++ b/boot/systemd-boot/systemd.hash
> @@ -0,0 +1 @@
> +../../package/systemd/systemd.hash
> \ No newline at end of file
> -- 
> 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.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option
  2018-12-19 21:55   ` James Hilliard
@ 2018-12-24 21:30     ` Yann E. MORIN
  2018-12-24 22:50       ` James Hilliard
  0 siblings, 1 reply; 11+ messages in thread
From: Yann E. MORIN @ 2018-12-24 21:30 UTC (permalink / raw)
  To: buildroot

James,

On 2018-12-19 14:55 -0700, James Hilliard spake thusly:
> On Wed, Dec 19, 2018 at 10:32 AM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > On 2018-12-19 07:41 +0800, james.hilliard1 at gmail.com spake thusly:
> > > From: James Hilliard <james.hilliard1@gmail.com>
> >
> > 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.

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

> > See also a few comments, below...
> >
> > > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> > > ---
> > >  package/systemd/Config.in  | 21 +++++++++++++++++++++
> > >  package/systemd/systemd.mk |  8 ++++++--
> > >  2 files changed, 27 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> > > index 25f322e..ff71323 100644
> > > --- a/package/systemd/Config.in
> > > +++ b/package/systemd/Config.in
> > > @@ -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?
> 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--]
> > > +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.

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 2/2] boot/systemd-boot: new package
  2018-12-24 21:26   ` Yann E. MORIN
@ 2018-12-24 22:44     ` James Hilliard
  2018-12-25 12:48       ` Yann E. MORIN
  0 siblings, 1 reply; 11+ messages in thread
From: James Hilliard @ 2018-12-24 22:44 UTC (permalink / raw)
  To: buildroot

On Mon, Dec 24, 2018 at 3:26 PM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>
> James, All,
>
> On 2018-12-19 07:41 +0800, james.hilliard1 at gmail.com spake thusly:
> > From: James Hilliard <james.hilliard1@gmail.com>
> >
> > 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...
>
> > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> > ---
> [--SNIP--]
> > diff --git a/boot/systemd-boot/Config.in b/boot/systemd-boot/Config.in
> > new file mode 100644
> > index 0000000..922bb07
> > --- /dev/null
> > +++ b/boot/systemd-boot/Config.in
> > @@ -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.
>
> > +     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.
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.
>
> > +     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?
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.
>
> 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?
>
> [--SNIP--]
> > diff --git a/boot/systemd-boot/buildroot.conf b/boot/systemd-boot/buildroot.conf
> > new file mode 100644
> > index 0000000..16d4d85
> > --- /dev/null
> > +++ b/boot/systemd-boot/buildroot.conf
> > @@ -0,0 +1,3 @@
> > +title        Buildroot
> > +linux        /bzImage
> > +options      root=/dev/sda2 rootwait console=tty1
> > diff --git a/boot/systemd-boot/loader.conf b/boot/systemd-boot/loader.conf
> > new file mode 100644
> > index 0000000..93b77b8
> > --- /dev/null
> > +++ b/boot/systemd-boot/loader.conf
> > @@ -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.
>
> 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.
>
> > diff --git a/boot/systemd-boot/systemd-boot.mk b/boot/systemd-boot/systemd-boot.mk
> > new file mode 100644
> > index 0000000..7f97ef0
> > --- /dev/null
> > +++ b/boot/systemd-boot/systemd-boot.mk
> > @@ -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).
>
> > +SYSTEMD_BOOT_SITE = $(call github,systemd,systemd,v$(SYSTEMD_BOOT_VERSION))
> > +SYSTEMD_BOOT_DL_SUBDIR = systemd
>
> Yes! :-)
>
> > +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.
>
> > +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.
>
> > +     -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?
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/.
>
> > +     -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.
>
> > +     -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
> > +     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.
>
> > +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
> > +     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.
>
> Regards,
> Yann E. MORIN.
>
> > +endef
> > +
> > +ifeq ($(BR2_PACKAGE_SYSTEMD_BOOT),y)
> > +$(eval $(generic-package))
> > +else
> > +$(eval $(meson-package))
> > +endif
> > diff --git a/boot/systemd-boot/systemd.hash b/boot/systemd-boot/systemd.hash
> > new file mode 120000
> > index 0000000..4259f40
> > --- /dev/null
> > +++ b/boot/systemd-boot/systemd.hash
> > @@ -0,0 +1 @@
> > +../../package/systemd/systemd.hash
> > \ No newline at end of file
> > --
> > 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.  |
> '------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option
  2018-12-24 21:30     ` Yann E. MORIN
@ 2018-12-24 22:50       ` James Hilliard
  0 siblings, 0 replies; 11+ messages in thread
From: James Hilliard @ 2018-12-24 22:50 UTC (permalink / raw)
  To: buildroot

On Mon, Dec 24, 2018 at 3:30 PM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>
> James,
>
> On 2018-12-19 14:55 -0700, James Hilliard spake thusly:
> > On Wed, Dec 19, 2018 at 10:32 AM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > > On 2018-12-19 07:41 +0800, james.hilliard1 at gmail.com spake thusly:
> > > > From: James Hilliard <james.hilliard1@gmail.com>
> > >
> > > 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.
>
> > > 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.
>
> > > See also a few comments, below...
> > >
> > > > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> > > > ---
> > > >  package/systemd/Config.in  | 21 +++++++++++++++++++++
> > > >  package/systemd/systemd.mk |  8 ++++++--
> > > >  2 files changed, 27 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/package/systemd/Config.in b/package/systemd/Config.in
> > > > index 25f322e..ff71323 100644
> > > > --- a/package/systemd/Config.in
> > > > +++ b/package/systemd/Config.in
> > > > @@ -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?
> > 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--]
> > > > +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.
>
> 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.  |
> '------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 2/2] boot/systemd-boot: new package
  2018-12-24 22:44     ` James Hilliard
@ 2018-12-25 12:48       ` Yann E. MORIN
  2018-12-25 21:26         ` James Hilliard
  0 siblings, 1 reply; 11+ messages in thread
From: Yann E. MORIN @ 2018-12-25 12:48 UTC (permalink / raw)
  To: buildroot

James, All,

On 2018-12-24 16:44 -0600, James Hilliard spake thusly:
> On Mon, Dec 24, 2018 at 3:26 PM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > On 2018-12-19 07:41 +0800, james.hilliard1 at gmail.com spake thusly:
> > > From: James Hilliard <james.hilliard1@gmail.com>
[--SNIP--]
> > > +     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--]
> > 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.

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

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

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

Needs a patch, see below...

> > > diff --git a/boot/systemd-boot/buildroot.conf b/boot/systemd-boot/buildroot.conf
> > > diff --git a/boot/systemd-boot/loader.conf b/boot/systemd-boot/loader.conf
> > 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--]
> > > +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--]
> > > +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.
> 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.

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 2/2] boot/systemd-boot: new package
  2018-12-25 12:48       ` Yann E. MORIN
@ 2018-12-25 21:26         ` James Hilliard
  0 siblings, 0 replies; 11+ messages in thread
From: James Hilliard @ 2018-12-25 21:26 UTC (permalink / raw)
  To: buildroot

On Tue, Dec 25, 2018 at 6:48 AM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>
> James, All,
>
> On 2018-12-24 16:44 -0600, James Hilliard spake thusly:
> > On Mon, Dec 24, 2018 at 3:26 PM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > > On 2018-12-19 07:41 +0800, james.hilliard1 at gmail.com spake thusly:
> > > > From: James Hilliard <james.hilliard1@gmail.com>
> [--SNIP--]
> > > > +     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--]
> > > 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.
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.
>
> > > > +     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?
> > 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...
>
> > > 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. ;-)
>
> > Is there a way to
> > satisfy the util-linux requirement without actually installing
> > util-linux into the target?
>
> Needs a patch, see below...
>
> > > > diff --git a/boot/systemd-boot/buildroot.conf b/boot/systemd-boot/buildroot.conf
> > > > diff --git a/boot/systemd-boot/loader.conf b/boot/systemd-boot/loader.conf
> > > 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--]
> > > > +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--]
> > > > +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.
> > 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).
Will do, I agree your approach is simpler and easier to understand.
>
> 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.
>
> 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.  |
> '------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-12-25 21:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-18 23:41 [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option james.hilliard1 at gmail.com
2018-12-18 23:41 ` [Buildroot] [PATCH 2/2] boot/systemd-boot: new package james.hilliard1 at gmail.com
2018-12-24 21:26   ` Yann E. MORIN
2018-12-24 22:44     ` James Hilliard
2018-12-25 12:48       ` Yann E. MORIN
2018-12-25 21:26         ` James Hilliard
2018-12-19 17:32 ` [Buildroot] [PATCH 1/2] package/systemd: add systemd-boot build option Yann E. MORIN
2018-12-19 21:40   ` Yann E. MORIN
2018-12-19 21:55   ` James Hilliard
2018-12-24 21:30     ` Yann E. MORIN
2018-12-24 22:50       ` James Hilliard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.