Skip to contentSkip to conversation

EFI image enhancements

PATCH In review California Sullivan 4 participants 27 messages Mar 1, 2018 – Mar 6, 2018

lore
Share & tools
lore
#0 lore raw

v3 cover EFI image enhancements

EFI images require a boot partition containing the bootloader, the kernel, the bootloader configuration, and any other EFI binaries that your platform needs. Currently, the boot partition is done at image creation time rather than through packages, making it very difficult to add to its contents. As an example, we currently have no way to make use of the multiple kernel enhancement that was recently added.

We should instead be treating the boot partition like anything else and be installing needed items via packages. This can be done by treating the /boot/ directory as the boot partion, pointing wic at it via the --rootfs-dir option for the EFI partition, and using the new --exclude-path option to not include the contents of /boot/ in the main rootfs. This is the kickstart file in patch 0008.

What's left is installing everything in the correct location, which is what the majority of the remaining patches entails.

I reused the grub-efi and systemd-boot bbclasses to create the configuration files, and one change that was required due to that is the removal of the assumption that kernels are installed as "vmlinuz", which was normal in the past. This change was needed in order to make use of the new normal kernel install, where the default kernel is installed to /boot/ as ${KERNEL_IMAGETYPE}.

This has some cascading effects and required changes in install scripts as well, as they too assumed the kernel would be named vmlinuz. When updating these I also added functionality allowing them to install multiple kernels.

The image enhancements can be tested in qemu by adding the following to your local.conf:
MACHINE="qemux86"

# or qemux86-64
WKS_FILE = "efi-bootdisk.wks.in"
MACHINE_FEATURES_append = " efi"
IMAGE_INSTALL_append = " grub-efi systemd-boot kernel-image-bzimage"
# kernel-image-bzimage is neccessary due to
# RDEPENDS_${KERNEL_PACKAGE_NAME}-base = "" in qemu.inc
IMAGE_FSTYPES_pn-core-image-minimal_append = " wic"

And then running the following:
bitbake core-image-minimal ovmf
runqemu wic ovmf

The image will contain two bootloaders in the boot partition, and will boot successfully with either.

Please note that without setting the EFI_PROVIDER variable, neither bootloader will be installed as the standard boot(x64|ia32), and will have to be ran manually through the EFI shell.

There is still one unfortunate issue with this patchset - I wasn't able to get random UUIDs working completely right before feature freeze, so instead the bootconf recipes assume that the rootfs will be /dev/sda2. This can be changed via the ROOT variable which originated from the grub-efi.bbclass. For this reason, I'm not making the efi-bootdisk kickstart file default for anything, only making it available for this release.

The issue with random UUIDs is that both wic and the bootloader configurations need the same random value, and wic needs it at parse time in order to specify it in a kickstart file. This is doable, but a little nasty, by writing a value to a file and adding helper functions to assign that value to a variable. The issue here is package upgrades. I know of no way to ensure that that file generated at parse time persists between builds, and if someone tries to do a package upgrade on thier configuration file that now has a different UUID, they would no longer have the same UUID as their rootfs, causing boot failures.

One additional issue is that the kernel is installed to /boot/ in iso and hddimgs, when the real kernel and bootloaders are in the separate EFI partition. This can be fixed via the following patch and one additional line of configuration for those image types:
http://lists.openembedded.org/pipermail/openembedded-core/2018-January/146828.html

Please review this patcheset and let me know of any issues you see or encounter. Also, I have a contrib branch available to pull from here:
https://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=clsulliv/image-creation-sda2

A previous iteration including the UUID stuff that's not included here is available at clsulliv/image-creation-exclude-path

Thanks,
Cal

V2 changes:
* ROOT is now overridable. Woops.
* Fix fixup in 'systemd-boot: add package that installs to boot' that belonged in the systemd-bootconf recipe patch.
* Add -bootconf recipes to SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS to avoid rebuilding grub-efi/systemd-boot when not necessary.
* Add basic test case that leverages the generic EFI boot partition.

V3 changes:
* Autobuilder testing revealed two failing tests with this patchset:
https://autobuilder.yocto.io/builders/nightly-oe-selftest/builds/858/steps/Running%20oe-selftest/logs/stdio
Patches 19-21 fix these.

California Sullivan (21):
grub-efi.bbclass: split out configuration portion
grub: create recipe for configuration
grub-efi: install to /boot/
grub-efi: if installed and EFI_PROVIDER, install as bootx64 or
bootia32
packagegroup-core-boot: add bootloader to EFI systems live-vm-common.bbclass: Don't use vmlinuz or VM_DEFAULT_KERNEL grub-efi*.bbclass: don't reference vmlinuz
wic: add wks file to make use of exclude-path functionality init-install-efi.sh: Update to support installing multiple kernels syslinux.bbclass: don't use vmlinuz
systemd-boot.bbclass: break out configuration creation
systemd: add systemd-bootconf recipe systemd-boot*.bbclass: Don't use vmlinuz
systemd-boot: add package that installs to boot
packagegroup-core-boot: add kernel for EFI systems init-install.sh: support multiple kernels and don't assume vmlinuz layer.conf: add -bootconf recipes to SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS
selftests: Add test case for booting a generic EFI boot partition
image
grub-efi-cfg.bbclass: Don't reference or set OVERRIDES systemd-boot-cfg.bbclass: Don't reference or set OVERRIDES maintainers.inc: add myself as -bootconf recipe maintainer

 .../{grub-efi.bbclass => grub-efi-cfg.bbclass}     |  50 +--------
 meta/classes/grub-efi.bbclass                      | 124 +--------------------
 meta/classes/live-vm-common.bbclass                |   9 +-
 meta/classes/syslinux.bbclass                      |   4 +-
 meta/classes/systemd-boot-cfg.bbclass              |  70 ++++++++++++
 meta/classes/systemd-boot.bbclass                  |  72 +-----------
 meta/conf/distro/include/maintainers.inc           |   2 +
 meta/conf/layer.conf                               |   2 +
 meta/lib/oeqa/selftest/cases/efibootpartition.py   |  45 ++++++++
 meta/recipes-bsp/grub/grub-bootconf_1.00.bb        |  29 +++++
 meta/recipes-bsp/grub/grub-efi_2.02.bb             |  43 +++++--
 .../initrdscripts/files/init-install-efi.sh        |  15 ++-
 .../initrdscripts/files/init-install.sh            |  37 +++++-
 .../packagegroups/packagegroup-core-boot.bb        |   3 +
 meta/recipes-core/systemd/systemd-boot_234.bb      |  28 ++++-
 meta/recipes-core/systemd/systemd-bootconf_1.00.bb |  31 ++++++
 scripts/lib/wic/canned-wks/efi-bootdisk.wks.in     |   3 +
 17 files changed, 301 insertions(+), 266 deletions(-)
 copy meta/classes/{grub-efi.bbclass => grub-efi-cfg.bbclass} (70%)
 create mode 100644 meta/classes/systemd-boot-cfg.bbclass
 create mode 100644 meta/lib/oeqa/selftest/cases/efibootpartition.py
 create mode 100644 meta/recipes-bsp/grub/grub-bootconf_1.00.bb
 create mode 100644 meta/recipes-core/systemd/systemd-bootconf_1.00.bb
 create mode 100644 scripts/lib/wic/canned-wks/efi-bootdisk.wks.in
Signature · 1 line
2.14.3
#1 lore raw

PATCH v3 1/21 grub-efi.bbclass: split out configuration portion

This part is useful on its own, whereas the whole class together is specific for image-live.

---
 .../{grub-efi.bbclass => grub-efi-cfg.bbclass}     |  40 -------
 meta/classes/grub-efi.bbclass                      | 122 +--------------------
 2 files changed, 1 insertion(+), 161 deletions(-)
 copy meta/classes/{grub-efi.bbclass => grub-efi-cfg.bbclass} (76%)
meta/classes/grub-efi-cfg.bbclass renamed from meta/classes/grub-efi.bbclass +0 -40
similarity index 76%
copy from meta/classes/grub-efi.bbclass
copy to meta/classes/grub-efi-cfg.bbclass
index 610479b85d1..730323c72e6 100644
@@ -16,8 +16,6 @@
 # ${GRUB_TIMEOUT} - timeout before executing the deault label (optional)
 # ${GRUB_ROOT} - grub's root device.
 
-do_bootimg[depends] += "${MLPREFIX}grub-efi:do_deploy"
-
 GRUB_SERIAL ?= "console=ttyS0,115200"
 GRUB_CFG_VM = "${S}/grub_vm.cfg"
 GRUB_CFG_LIVE = "${S}/grub_live.cfg"
@@ -32,44 +30,6 @@ APPEND ?= ""
 # Need UUID utility code.
 inherit fs-uuid
 
-efi_populate() {
-	# DEST must be the root of the image so that EFIDIR is not
-	# nested under a top level directory.
-	DEST=$1
-
-	install -d ${DEST}${EFIDIR}
-
-	GRUB_IMAGE="grub-efi-bootia32.efi"
-	DEST_IMAGE="bootia32.efi"
-	if [ "${TARGET_ARCH}" = "x86_64" ]; then
-		GRUB_IMAGE="grub-efi-bootx64.efi"
-		DEST_IMAGE="bootx64.efi"
-	fi
-	install -m 0644 ${DEPLOY_DIR_IMAGE}/${GRUB_IMAGE} ${DEST}${EFIDIR}/${DEST_IMAGE}
-	EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
-	printf 'fs0:%s\%s\n' "$EFIPATH" "$DEST_IMAGE" >${DEST}/startup.nsh
-
-	install -m 0644 ${GRUB_CFG} ${DEST}${EFIDIR}/grub.cfg
-}
-
-efi_iso_populate() {
-	iso_dir=$1
-	efi_populate $iso_dir
-	# Build a EFI directory to create efi.img
-	mkdir -p ${EFIIMGDIR}/${EFIDIR}
-	cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
-	cp $iso_dir/vmlinuz ${EFIIMGDIR}
-	EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
-	printf 'fs0:%s\%s\n' "$EFIPATH" "$GRUB_IMAGE" > ${EFIIMGDIR}/startup.nsh
-	if [ -f "$iso_dir/initrd" ] ; then
-		cp $iso_dir/initrd ${EFIIMGDIR}
-	fi
-}
-
-efi_hddimg_populate() {
-	efi_populate $1
-}
-
 python build_efi_cfg() {
     import sys
 
meta/classes/grub-efi.bbclass +1 -121

128 lines not on this page · raw message

Signature · 1 line
2.14.3
#2 lore raw

PATCH v3 2/21 grub: create recipe for configuration

In reply to California Sullivan

This makes use of the grub-efi-cfg bbclass that was split out to create a grub.cfg file just like the old one.

---
 meta/recipes-bsp/grub/grub-bootconf_1.00.bb | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 meta/recipes-bsp/grub/grub-bootconf_1.00.bb
meta/recipes-bsp/grub/grub-bootconf_1.00.bb new file +29 -0
new file mode 100644
index 00000000000..d376fde68b1
@@ -0,0 +1,29 @@
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+SUMMARY = "Basic grub.cfg for use in EFI systems"
+
+RPROVIDES_${PN} += "virtual/grub-bootconf"
+
+inherit grub-efi-cfg
+
+S = "${WORKDIR}"
+
+GRUB_CFG = "${S}/grub-bootconf"
+LABELS = "boot"
+
+ROOT ?= "root=/dev/sda2"
+
+python do_configure() {
+    bb.build.exec_func('build_efi_cfg', d)
+}
+
+do_configure[vardeps] += "APPEND ROOT"
+
+do_install() {
+	install -d ${D}/boot
+	install -d ${D}/boot/EFI
+	install -d ${D}/boot/EFI/BOOT
+	install -m 0744 grub-bootconf ${D}/boot/EFI/BOOT/grub.cfg
+}
+
+FILES_${PN} = "/boot/EFI/BOOT/grub.cfg"
Signature · 1 line
2.14.3
#3 lore raw

PATCH v3 3/21 grub-efi: install to /boot/

In reply to California Sullivan

Since /boot/ will be recipe/package controlled now we can't just deploy.

---
 meta/recipes-bsp/grub/grub-bootconf_1.00.bb |  2 +-
 meta/recipes-bsp/grub/grub-efi_2.02.bb      | 34 +++++++++++++++++++++++------
 2 files changed, 28 insertions(+), 8 deletions(-)
meta/recipes-bsp/grub/grub-bootconf_1.00.bb +1 -1
index d376fde68b1..750f8c808a8 100644
@@ -23,7 +23,7 @@ do_install() {
 	install -d ${D}/boot
 	install -d ${D}/boot/EFI
 	install -d ${D}/boot/EFI/BOOT
-	install -m 0744 grub-bootconf ${D}/boot/EFI/BOOT/grub.cfg
+	install grub-bootconf ${D}/boot/EFI/BOOT/grub.cfg
 }
 
 FILES_${PN} = "/boot/EFI/BOOT/grub.cfg"
meta/recipes-bsp/grub/grub-efi_2.02.bb +27 -7
index d5aa64c75f7..c5a68f01cef 100644
@@ -3,7 +3,7 @@ require grub2.inc
 GRUBPLATFORM = "efi"
 
 DEPENDS_append_class-target = " grub-efi-native"
-RDEPENDS_${PN}_class-target = "diffutils freetype grub-common"
+RDEPENDS_${PN}_class-target = "diffutils freetype grub-common virtual/grub-bootconf"
 
 SRC_URI += " \
            file://cfg \
@@ -36,6 +36,28 @@ EXTRA_OECONF += "--enable-efiemu=no"
 # and many other places in the grub code when compiled with some native gcc compilers (specifically, gentoo)
 CFLAGS_append_class-native = " -Wno-error=trampolines"
 
+do_mkimage() {
+	cd ${B}
+	# Search for the grub.cfg on the local boot media by using the
+	# built in cfg file provided via this recipe
+	grub-mkimage -c ../cfg -p /EFI/BOOT -d ./grub-core/ \
+	               -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE} \
+	               ${GRUB_BUILDIN}
+}
+
+addtask mkimage before do_install after do_compile
+
+do_mkimage_class-native() {
+	:
+}
+
+do_install_append_class-target() {
+	install -d ${D}/boot
+	install -d ${D}/boot/EFI
+	install -d ${D}/boot/EFI/BOOT
+	install -m 644 ${B}/${GRUB_IMAGE} ${D}/boot/EFI/BOOT/
+}
+
 do_install_class-native() {
 	install -d ${D}${bindir}
 	install -m 755 grub-mkimage ${D}${bindir}
@@ -57,11 +79,6 @@ GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \
                  efi_gop iso9660 configfile search loadenv test"
 
 do_deploy() {
-	# Search for the grub.cfg on the local boot media by using the
-	# built in cfg file provided via this recipe
-	grub-mkimage -c ../cfg -p /EFI/BOOT -d ./grub-core/ \
-	               -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE} \
-	               ${GRUB_BUILDIN}
 	install -m 644 ${B}/${GRUB_IMAGE} ${DEPLOYDIR}
 }
 
@@ -72,7 +89,10 @@ do_deploy_class-native() {
 addtask deploy after do_install before do_build
 
 FILES_${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
-                "
+               ${datadir}/grub \
+               /boot/EFI/BOOT/${GRUB_IMAGE} \
+               "
+
 
 # 64-bit binaries are expected for the bootloader with an x32 userland
 INSANE_SKIP_${PN}_append_linux-gnux32 = " arch"
Signature · 1 line
2.14.3
#4 lore raw

PATCH v3 4/21 grub-efi: if installed and EFI_PROVIDER, install as bootx64 or bootia32

In reply to California Sullivan

This way we could theoretically support multiple bootloaders, and we keep the convention of boot(x64|ia32).

---
 meta/recipes-bsp/grub/grub-efi_2.02.bb | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
meta/recipes-bsp/grub/grub-efi_2.02.bb +8 -5
index c5a68f01cef..ed27b90fdbc 100644
@@ -15,16 +15,19 @@ S = "${WORKDIR}/grub-${PV}"
 python __anonymous () {
     import re
     target = d.getVar('TARGET_ARCH')
+    prefix = "" if d.getVar('EFI_PROVIDER') == "grub-efi" else "grub-efi-"
     if target == "x86_64":
         grubtarget = 'x86_64'
-        grubimage = "grub-efi-bootx64.efi"
+        grubimage = prefix + "bootx64.efi"
     elif re.match('i.86', target):
         grubtarget = 'i386'
-        grubimage = "grub-efi-bootia32.efi"
+        grubimage = prefix + "bootia32.efi"
     else:
         raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target)
     d.setVar("GRUB_TARGET", grubtarget)
     d.setVar("GRUB_IMAGE", grubimage)
+    prefix = "grub-efi-" if prefix == "" else ""
+    d.setVar("GRUB_IMAGE_PREFIX", prefix)
 }
 
 inherit deploy
@@ -41,7 +44,7 @@ do_mkimage() {
 	# Search for the grub.cfg on the local boot media by using the
 	# built in cfg file provided via this recipe
 	grub-mkimage -c ../cfg -p /EFI/BOOT -d ./grub-core/ \
-	               -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE} \
+	               -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \
 	               ${GRUB_BUILDIN}
 }
 
@@ -55,7 +58,7 @@ do_install_append_class-target() {
 	install -d ${D}/boot
 	install -d ${D}/boot/EFI
 	install -d ${D}/boot/EFI/BOOT
-	install -m 644 ${B}/${GRUB_IMAGE} ${D}/boot/EFI/BOOT/
+	install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}/boot/EFI/BOOT/${GRUB_IMAGE}
 }
 
 do_install_class-native() {
@@ -79,7 +82,7 @@ GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \
                  efi_gop iso9660 configfile search loadenv test"
 
 do_deploy() {
-	install -m 644 ${B}/${GRUB_IMAGE} ${DEPLOYDIR}
+	install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR}
 }
 
 do_deploy_class-native() {
Signature · 1 line
2.14.3
#5 lore raw

Re: [PATCH v3 04/21] grub-efi: if installed and EFI_PROVIDER, install as bootx64 or bootia32

Hi Cal,

Quoted 54 lines · California Sullivan

This way we could theoretically support multiple bootloaders, and we keep the convention of boot(x64|ia32).

---
 meta/recipes-bsp/grub/grub-efi_2.02.bb | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
meta/recipes-bsp/grub/grub-efi_2.02.bb +7 -4
index c5a68f01cef..ed27b90fdbc 100644
@@ -15,16 +15,19 @@ S = "${WORKDIR}/grub-${PV}"
 python __anonymous () {
     import re
     target = d.getVar('TARGET_ARCH')
+    prefix = "" if d.getVar('EFI_PROVIDER') == "grub-efi" else "grub-efi-"
     if target == "x86_64":
         grubtarget = 'x86_64'
-        grubimage = "grub-efi-bootx64.efi"
+        grubimage = prefix + "bootx64.efi"
     elif re.match('i.86', target):
         grubtarget = 'i386'
-        grubimage = "grub-efi-bootia32.efi"
+        grubimage = prefix + "bootia32.efi"
     else:
         raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target)
     d.setVar("GRUB_TARGET", grubtarget)
     d.setVar("GRUB_IMAGE", grubimage)
+    prefix = "grub-efi-" if prefix == "" else ""
+    d.setVar("GRUB_IMAGE_PREFIX", prefix)
 }
 
 inherit deploy
@@ -41,7 +44,7 @@ do_mkimage() {
 	# Search for the grub.cfg on the local boot media by using the
 	# built in cfg file provided via this recipe
 	grub-mkimage -c ../cfg -p /EFI/BOOT -d ./grub-core/ \
-	               -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE} \
+	               -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \
 	               ${GRUB_BUILDIN}
 }
 
@@ -55,7 +58,7 @@ do_install_append_class-target() {
 	install -d ${D}/boot
 	install -d ${D}/boot/EFI
 	install -d ${D}/boot/EFI/BOOT
-	install -m 644 ${B}/${GRUB_IMAGE} ${D}/boot/EFI/BOOT/
+	install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}/boot/EFI/BOOT/${GRUB_IMAGE}
 }
 
 do_install_class-native() {

meta/recipes-bsp/grub/grub-efi_2.02.bb GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \ · line 88

Quoted 8 lines
meta/recipes-bsp/grub/grub-efi_2.02.bb +1 -1
@@ -79,7 +82,7 @@ GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \
                  efi_gop iso9660 configfile search loadenv test"
 
 do_deploy() {
-	install -m 644 ${B}/${GRUB_IMAGE} ${DEPLOYDIR}
+	install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR}
 }
 
 do_deploy_class-native() {

Should FILES_${PN} also be changed to add prefix?

Thanks,
Anuj

#6 lore raw

Re: [PATCH v3 04/21] grub-efi: if installed and EFI_PROVIDER, install as bootx64 or bootia32

Quoted 58 lines · Anuj Mittal

Hi Cal,

Quoted 55 lines · California Sullivan

This way we could theoretically support multiple bootloaders, and we keep the convention of boot(x64|ia32).

---
  meta/recipes-bsp/grub/grub-efi_2.02.bb | 13 ++++++++-----
  1 file changed, 8 insertions(+), 5 deletions(-)
meta/recipes-bsp/grub/grub-efi_2.02.bb +7 -4
index c5a68f01cef..ed27b90fdbc 100644
@@ -15,16 +15,19 @@ S = "${WORKDIR}/grub-${PV}"
  python __anonymous () {
      import re
      target = d.getVar('TARGET_ARCH')
+    prefix = "" if d.getVar('EFI_PROVIDER') == "grub-efi" else "grub-efi-"
      if target == "x86_64":
          grubtarget = 'x86_64'
-        grubimage = "grub-efi-bootx64.efi"
+        grubimage = prefix + "bootx64.efi"
      elif re.match('i.86', target):
          grubtarget = 'i386'
-        grubimage = "grub-efi-bootia32.efi"
+        grubimage = prefix + "bootia32.efi"
      else:
          raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target)
      d.setVar("GRUB_TARGET", grubtarget)
      d.setVar("GRUB_IMAGE", grubimage)
+    prefix = "grub-efi-" if prefix == "" else ""
+    d.setVar("GRUB_IMAGE_PREFIX", prefix)
  }
 
  inherit deploy
@@ -41,7 +44,7 @@ do_mkimage() {
  	# Search for the grub.cfg on the local boot media by using the
  	# built in cfg file provided via this recipe
  	grub-mkimage -c ../cfg -p /EFI/BOOT -d ./grub-core/ \
-	               -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE} \
+	               -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \
  	               ${GRUB_BUILDIN}
  }
 
@@ -55,7 +58,7 @@ do_install_append_class-target() {
  	install -d ${D}/boot
  	install -d ${D}/boot/EFI
  	install -d ${D}/boot/EFI/BOOT
-	install -m 644 ${B}/${GRUB_IMAGE} ${D}/boot/EFI/BOOT/
+	install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}/boot/EFI/BOOT/${GRUB_IMAGE}
  }
 
  do_install_class-native() {
@@ -79,7 +82,7 @@ GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \
                   efi_gop iso9660 configfile search loadenv test"
 
Quoted 8 lines

meta/recipes-bsp/grub/grub-efi_2.02.bb GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \ · line 88

Quoted 7 lines
meta/recipes-bsp/grub/grub-efi_2.02.bb +1 -1
  do_deploy() {
-	install -m 644 ${B}/${GRUB_IMAGE} ${DEPLOYDIR}
+	install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR}
  }
 
  do_deploy_class-native() {

Should FILES_${PN} also be changed to add prefix?

Nope, only ${GRUB_IMAGE}. It gets installed as ${GRUB_IMAGE}, which will either be grub-efi-bootx64.efi or bootx64.efi (or ia32 equivalents). ${GRUB_IMAGE_PREFIX} is only used to set the build target, input file for installation, and deploy target. ${GRUB_IMAGE_PREFIX} will always be either "grub-efi" or "", and together ${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} will always create grub-efi-boot(x64|ia32).efi.

The goal of this is to install as boot(x64|ia32).efi if it is selected as the EFI_PROVIDER, and install as the complete name otherwise. This allows one efi bootloader to be installed as the standard boot(x64|ia32).efi, while still being able to coexist with other efi bootloaders.

Thanks,
Cal

Quoted 4 lines

Thanks,
Anuj

#7 lore raw

PATCH v3 5/21 packagegroup-core-boot: add bootloader to EFI systems

In reply to California Sullivan

Since the bootloader is now installed instead of added at image creation time, this is necessary for booting.

Also set the default to grub-efi. This is done because a default of grub-efi is already used by live-vm-common.bbclass, and in the event that EFI_PROVIDER isn't defined errors would occur.

---
 meta/recipes-core/packagegroups/packagegroup-core-boot.bb | 3 +++
 1 file changed, 3 insertions(+)
meta/recipes-core/packagegroups/packagegroup-core-boot.bb +3 -0
index 04bc0f2b693..0fcb8ba9193 100644
@@ -23,6 +23,8 @@ VIRTUAL-RUNTIME_init_manager ?= "sysvinit"
 VIRTUAL-RUNTIME_initscripts ?= "initscripts"
 VIRTUAL-RUNTIME_keymaps ?= "keymaps"
 
+EFI_PROVIDER ??= "grub-efi"
+
 SYSVINIT_SCRIPTS = "${@bb.utils.contains('MACHINE_FEATURES', 'rtc', '${VIRTUAL-RUNTIME_base-utils-hwclock}', '', d)} \
                     modutils-initscripts \
                     init-ifupdown \
@@ -35,6 +37,7 @@ RDEPENDS_${PN} = "\
     ${VIRTUAL-RUNTIME_base-utils} \
     ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "${SYSVINIT_SCRIPTS}", "", d)} \
     ${@bb.utils.contains("MACHINE_FEATURES", "keyboard", "${VIRTUAL-RUNTIME_keymaps}", "", d)} \
+    ${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)} \
     netbase \
     ${VIRTUAL-RUNTIME_login_manager} \
     ${VIRTUAL-RUNTIME_init_manager} \
Signature · 1 line
2.14.3
#8 lore raw

PATCH v3 6/21 live-vm-common.bbclass: Don't use vmlinuz or VM_DEFAULT_KERNEL

In reply to California Sullivan

I can't find VM_DEFAULT_KERNEL used anywhere else, and we should not be statically installing the kernel as vmlinuz.

---
 meta/classes/live-vm-common.bbclass | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
meta/classes/live-vm-common.bbclass +4 -5
index e1d8b1843b6..714d6d4788c 100644
@@ -33,18 +33,17 @@ inherit ${EFI_CLASS}
 inherit ${PCBIOS_CLASS}
 
 KERNEL_IMAGETYPE ??= "bzImage"
-VM_DEFAULT_KERNEL ??= "${KERNEL_IMAGETYPE}"
 
 populate_kernel() {
 	dest=$1
 	install -d $dest
 
 	# Install bzImage, initrd, and rootfs.img in DEST for all loaders to use.
-	bbnote "Trying to install ${DEPLOY_DIR_IMAGE}/${VM_DEFAULT_KERNEL} as $dest/vmlinuz"
-	if [ -e ${DEPLOY_DIR_IMAGE}/${VM_DEFAULT_KERNEL} ]; then
-		install -m 0644 ${DEPLOY_DIR_IMAGE}/${VM_DEFAULT_KERNEL} $dest/vmlinuz
+	bbnote "Trying to install ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} as $dest/${KERNEL_IMAGETYPE}"
+	if [ -e ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} ]; then
+		install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} $dest/${KERNEL_IMAGETYPE}
 	else
-		bbwarn "${DEPLOY_DIR_IMAGE}/${VM_DEFAULT_KERNEL} doesn't exist"
+		bbwarn "${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} doesn't exist"
 	fi
 
 	# initrd is made of concatenation of multiple filesystem images
Signature · 1 line
2.14.3
#9 lore raw

PATCH v3 7/21 grub-efi*.bbclass: don't reference vmlinuz

In reply to California Sullivan

Rather than renaming the kernel to vmlinuz and assuming the name is vmlinuz in the grub.cfg, copy to ${KERNEL_IMAGETYPE} and also use that value in the grub.cfg file.

---
 meta/classes/grub-efi-cfg.bbclass | 4 +++-
 meta/classes/grub-efi.bbclass     | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
meta/classes/grub-efi-cfg.bbclass +3 -1
index 730323c72e6..85173c91fc3 100644
@@ -22,6 +22,7 @@ GRUB_CFG_LIVE = "${S}/grub_live.cfg"
 GRUB_TIMEOUT ?= "10"
 #FIXME: build this from the machine config
 GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
+KERNEL_IMAGETYPE ??= "bzImage"
 
 EFIDIR = "/EFI/BOOT"
 GRUB_ROOT ?= "${ROOT}"
@@ -97,7 +98,8 @@ python build_efi_cfg() {
             lb = label
             if label == "install":
                 lb = "install-efi"
-            cfgfile.write('linux /vmlinuz LABEL=%s' % (lb))
+            kernel = localdata.getVar('KERNEL_IMAGETYPE')
+            cfgfile.write('linux /%s LABEL=%s' % (kernel, lb))
 
             cfgfile.write(' %s' % replace_rootfs_uuid(d, root))
 
meta/classes/grub-efi.bbclass +1 -1
index 4b5704c19cc..90badc03a0e 100644
@@ -26,7 +26,7 @@ efi_iso_populate() {
 	# Build a EFI directory to create efi.img
 	mkdir -p ${EFIIMGDIR}/${EFIDIR}
 	cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
-	cp $iso_dir/vmlinuz ${EFIIMGDIR}
+	cp $iso_dir/${KERNEL_IMAGETYPE} ${EFIIMGDIR}
 	EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
 	printf 'fs0:%s\%s\n' "$EFIPATH" "$GRUB_IMAGE" > ${EFIIMGDIR}/startup.nsh
 	if [ -f "$iso_dir/initrd" ] ; then
Signature · 1 line
2.14.3
#10 lore raw

Re: [PATCH v3 07/21] grub-efi*.bbclass: don't reference vmlinuz

Quoted 2 lines · California Sullivan

+KERNEL_IMAGETYPE ??= "bzImage"

You repeat this line in several classes, can we just move the default to default-distrovars or similar?

Ross

#11 lore raw

Re: [PATCH v3 07/21] grub-efi*.bbclass: don't reference vmlinuz

Quoted 6 lines · Ross

On 1 March 2018 at 02:15, California Sullivan <[email protected] <mailto:[email protected]>> wrote:

+KERNEL_IMAGETYPE ??= "bzImage"

You repeat this line in several classes, can we just move the default to default-distrovars or similar?

I was trying to avoid adding to bitbake.conf (or things it inherits from) but I think it makes sense here. With the changes switching away from assuming "vmlinuz" and instead using KERNEL_IMAGETYPE, we now rely on it being set in a number of places, so setting a global default would be best. If I have your blessings I can make that change.

I see this patchset in is master-next and ross/mut. Should I make the change on top of this, or send a v4?

Thanks,
Cal

Quoted 2 lines

Ross

#12 lore raw

Re: [PATCH v3 07/21] grub-efi*.bbclass: don't reference vmlinuz

Quoted 6 lines · Cal Sullivan

On 03/05/2018 04:50 AM, Burton, Ross wrote:

Quoted 2 lines · California Sullivan

+KERNEL_IMAGETYPE ??= "bzImage"

Quoted 8 lines

You repeat this line in several classes, can we just move the default to default-distrovars or similar?

I was trying to avoid adding to bitbake.conf (or things it inherits from) but I think it makes sense here. With the changes switching away from assuming "vmlinuz" and instead using KERNEL_IMAGETYPE, we now rely on it being set in a number of places, so setting a global default would be best. If I have your blessings I can make that change.

Isn't KERNEL_IMAGETYPE now deprecated in favour of KERNEL_IMAGETYPES?

If so, everywhere that's now referencing KERNEL_IMAGETYPE should probably be updated to parse and deal with the list of types in KERNEL_IMAGETYPES so that the legacy variable can eventually be removed.

#13 lore raw

PATCH v3 8/21 wic: add wks file to make use of exclude-path functionality

In reply to California Sullivan

Using --exclude-path and a wks.in file we can create an image that takes the /boot/ directory for the boot partition, has an empty /boot/ directory in the rootfs partition. The boot partition gets mounted to /boot/ after startup.

---
 scripts/lib/wic/canned-wks/efi-bootdisk.wks.in | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 scripts/lib/wic/canned-wks/efi-bootdisk.wks.in
scripts/lib/wic/canned-wks/efi-bootdisk.wks.in new file +3 -0
new file mode 100644
index 00000000000..7300e65e32d
@@ -0,0 +1,3 @@
+bootloader --ptable gpt
+part /boot --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/boot --fstype=vfat --label boot --active --align 1024 --use-uuid --overhead-factor 1.0
+part / --source rootfs --fstype=ext4 --label root --align 1024 --exclude-path boot/
Signature · 1 line
2.14.3
#14 lore raw

PATCH v3 9/21 init-install-efi.sh: Update to support installing multiple kernels

In reply to California Sullivan

We can no longer rely on the kernel having a static name of "vmlinuz". This means we can't use it as a sentinel value in our sed commands, and we can't just copy vmlinuz to the boot directory.

Instead, we'll use "root=" as the sentinel value for our sed commands, and we'll search for common kernel names to copy into our boot directory.

---
 meta/recipes-core/initrdscripts/files/init-install-efi.sh | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
meta/recipes-core/initrdscripts/files/init-install-efi.sh +10 -5
index 706418fa9c5..f946d971d11 100644
@@ -244,10 +244,9 @@ if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then
     sed -i "/initrd /d" $GRUBCFG
     # Delete any LABEL= strings
     sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
-    # Delete any root= strings
-    sed -i "s/ root=[^ ]*/ /g" $GRUBCFG
-    # Add the root= and other standard boot options
-    sed -i "s@linux /vmlinuz *@linux /vmlinuz root=PARTUUID=$root_part_uuid rw $rootwait quiet @" $GRUBCFG
+    # Replace root= and add additional standard boot options
+    # We use root as a sentinel value, as vmlinuz is no longer guaranteed
+    sed -i "s/ root=[^ ]*/ root=PARTUUID=$root_part_uuid rw $rootwait quiet /g" $GRUBCFG
 fi
 
 if [ -d /run/media/$1/loader ]; then
@@ -269,7 +268,13 @@ fi
 
 umount /tgt_root
 
-cp /run/media/$1/vmlinuz /boot
+# Copy kernel artifacts. To add more artifacts just add to types
+# For now just support kernel types already being used by something in OE-core
+for types in bzImage zImage vmlinux vmlinuz fitImage; do
+    for kernel in `find /run/media/$1/ -name $types*`; do
+        cp $kernel /boot
+    done
+done
 
 umount /boot
 
Signature · 1 line
2.14.3
#15 lore raw

PATCH v3 10/21 syslinux.bbclass: don't use vmlinuz

In reply to California Sullivan

We can't guarantee the kernel will be named vmlinuz anymore. Use KERNEL_IMAGETYPE instead.

---
 meta/classes/syslinux.bbclass | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/classes/syslinux.bbclass +3 -1
index d6f882420e4..959aed4fb8f 100644
@@ -21,6 +21,7 @@ do_bootimg[depends] += "${MLPREFIX}syslinux:do_populate_sysroot \
                         syslinux-native:do_populate_sysroot"
 
 ISOLINUXDIR ?= "/isolinux"
+KERNEL_IMAGETYPE ??= "bzImage"
 SYSLINUXDIR = "/"
 # The kernel has an internal default console, which you can override with
 # a console=...some_tty...
@@ -173,8 +174,9 @@ python build_syslinux_cfg () {
         if not root:
             bb.fatal('SYSLINUX_ROOT not defined')
 
+        kernel = localdata.getVar('KERNEL_IMAGETYPE')
         for btype in btypes:
-            cfgfile.write('LABEL %s%s\nKERNEL /vmlinuz\n' % (btype[0], label))
+            cfgfile.write('LABEL %s%s\nKERNEL /%s\n' % (btype[0], label, kernel))
 
             exargs = d.getVar('SYSLINUX_KERNEL_ARGS')
             if exargs:
Signature · 1 line
2.14.3
#16 lore raw

PATCH v3 11/21 systemd-boot.bbclass: break out configuration creation

In reply to California Sullivan

This class is useful on its own and can be used to create configuration recipes.

---
 ...stemd-boot.bbclass => systemd-boot-cfg.bbclass} | 57 ------------------
 meta/classes/systemd-boot.bbclass                  | 70 +---------------------
 2 files changed, 1 insertion(+), 126 deletions(-)
 copy meta/classes/{systemd-boot.bbclass => systemd-boot-cfg.bbclass} (50%)
meta/classes/systemd-boot-cfg.bbclass renamed from meta/classes/systemd-boot.bbclass +0 -57
similarity index 50%
copy from meta/classes/systemd-boot.bbclass
copy to meta/classes/systemd-boot-cfg.bbclass
index 937307076f7..46eeae126ae 100644
@@ -1,18 +1,3 @@
-# Copyright (C) 2016 Intel Corporation
-#
-# Released under the MIT license (see COPYING.MIT)
-
-# systemd-boot.bbclass - The "systemd-boot" is essentially the gummiboot merged into systemd.
-#                        The original standalone gummiboot project is dead without any more
-#                        maintenance.
-#
-# Set EFI_PROVIDER = "systemd-boot" to use systemd-boot on your live images instead of grub-efi
-# (images built by image-live.bbclass)
-
-do_bootimg[depends] += "${MLPREFIX}systemd-boot:do_deploy"
-
-EFIDIR = "/EFI/BOOT"
-
 SYSTEMD_BOOT_CFG ?= "${S}/loader.conf"
 SYSTEMD_BOOT_ENTRIES ?= ""
 SYSTEMD_BOOT_TIMEOUT ?= "10"
@@ -20,48 +5,6 @@ SYSTEMD_BOOT_TIMEOUT ?= "10"
 # Need UUID utility code.
 inherit fs-uuid
 
-efi_populate() {
-        DEST=$1
-
-        EFI_IMAGE="systemd-bootia32.efi"
-        DEST_EFI_IMAGE="bootia32.efi"
-        if [ "${TARGET_ARCH}" = "x86_64" ]; then
-            EFI_IMAGE="systemd-bootx64.efi"
-            DEST_EFI_IMAGE="bootx64.efi"
-        fi
-
-        install -d ${DEST}${EFIDIR}
-        # systemd-boot requires these paths for configuration files
-        # they are not customizable so no point in new vars
-        install -d ${DEST}/loader
-        install -d ${DEST}/loader/entries
-        install -m 0644 ${DEPLOY_DIR_IMAGE}/${EFI_IMAGE} ${DEST}${EFIDIR}/${DEST_EFI_IMAGE}
-        EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
-        printf 'fs0:%s\%s\n' "$EFIPATH" "$DEST_EFI_IMAGE" >${DEST}/startup.nsh
-        install -m 0644 ${SYSTEMD_BOOT_CFG} ${DEST}/loader/loader.conf
-        for i in ${SYSTEMD_BOOT_ENTRIES}; do
-            install -m 0644 ${i} ${DEST}/loader/entries
-        done
-}
-
-efi_iso_populate() {
-        iso_dir=$1
-        efi_populate $iso_dir
-        mkdir -p ${EFIIMGDIR}/${EFIDIR}
-        cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
-        cp -r $iso_dir/loader ${EFIIMGDIR}
-        cp $iso_dir/vmlinuz ${EFIIMGDIR}
-        EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
-        echo "fs0:${EFIPATH}\\${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh
-        if [ -f "$iso_dir/initrd" ] ; then
-            cp $iso_dir/initrd ${EFIIMGDIR}
-        fi
-}
-
-efi_hddimg_populate() {
-        efi_populate $1
-}
-
 python build_efi_cfg() {
     s = d.getVar("S")
     labels = d.getVar('LABELS')
meta/classes/systemd-boot.bbclass +1 -69

79 lines not on this page · raw message

Signature · 1 line
2.14.3
#17 lore raw

PATCH v3 12/21 systemd: add systemd-bootconf recipe

In reply to California Sullivan

Reuses our systemd-boot-cfg bbclass to generate systemd-boot configuration files.

---
 meta/recipes-core/systemd/systemd-bootconf_1.00.bb | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd-bootconf_1.00.bb
meta/recipes-core/systemd/systemd-bootconf_1.00.bb new file +31 -0
new file mode 100644
index 00000000000..e9c2466456c
@@ -0,0 +1,31 @@
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+SUMMARY = "Basic systemd-boot configuration files"
+
+RPROVIDES_${PN} += "virtual/systemd-bootconf"
+
+inherit systemd-boot-cfg
+
+S = "${WORKDIR}"
+
+LABELS = "boot"
+
+ROOT ?= "root=/dev/sda2"
+APPEND_append = " ${ROOT}"
+
+python do_configure() {
+    bb.build.exec_func('build_efi_cfg', d)
+}
+
+do_configure[vardeps] += "APPEND"
+
+do_install() {
+	install -d ${D}/boot
+	install -d ${D}/boot/loader
+	install -d ${D}/boot/loader/entries
+	install loader.conf ${D}/boot/loader/
+	rm loader.conf
+	install *.conf ${D}/boot/loader/entries/
+}
+
+FILES_${PN} = "/boot/loader/* /boot/loader/entries/*"
Signature · 1 line
2.14.3
#18 lore raw

PATCH v3 13/21 systemd-boot*.bbclass: Don't use vmlinuz

In reply to California Sullivan

We can't guarantee vmlinuz anymore. Use KERNEL_IMAGETYPE instead.

---
 meta/classes/systemd-boot-cfg.bbclass | 6 +++++-
 meta/classes/systemd-boot.bbclass     | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)
meta/classes/systemd-boot-cfg.bbclass +5 -1
index 46eeae126ae..360c86cbd34 100644
@@ -1,3 +1,5 @@
+KERNEL_IMAGETYPE ??= "bzImage"
+
 SYSTEMD_BOOT_CFG ?= "${S}/loader.conf"
 SYSTEMD_BOOT_ENTRIES ?= ""
 SYSTEMD_BOOT_TIMEOUT ?= "10"
@@ -52,7 +54,9 @@ python build_efi_cfg() {
         localdata.setVar('OVERRIDES', label + ':' + overrides)
 
         entrycfg.write('title %s\n' % label)
-        entrycfg.write('linux /vmlinuz\n')
+
+        kernel = localdata.getVar("KERNEL_IMAGETYPE")
+        entrycfg.write('linux /%s\n' % kernel)
 
         append = localdata.getVar('APPEND')
         initrd = localdata.getVar('INITRD')
meta/classes/systemd-boot.bbclass +1 -1
index 14538fe2d7a..3cd6811a6ce 100644
@@ -45,7 +45,7 @@ efi_iso_populate() {
         mkdir -p ${EFIIMGDIR}/${EFIDIR}
         cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR}
         cp -r $iso_dir/loader ${EFIIMGDIR}
-        cp $iso_dir/vmlinuz ${EFIIMGDIR}
+        cp $iso_dir/${KERNEL_IMAGETYPE} ${EFIIMGDIR}
         EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
         echo "fs0:${EFIPATH}\\${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh
         if [ -f "$iso_dir/initrd" ] ; then
Signature · 1 line
2.14.3
#19 lore raw

PATCH v3 14/21 systemd-boot: add package that installs to boot

In reply to California Sullivan

If the EFI_PROVIDER is systemd-boot, install as boot(x64|ia32) as per convention. If its not the EFI_PROVIDER, install as systemd-boot(x64|ia32), as to not collide with other possible bootloaders.

---
 meta/recipes-core/systemd/systemd-boot_234.bb | 28 ++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)
meta/recipes-core/systemd/systemd-boot_234.bb +25 -3
index 88a14ac61ec..2d29df8be7c 100644
@@ -18,6 +18,26 @@ EXTRA_OECONF = " --enable-gnuefi \
                  EFI_CC='${EFI_CC}' \
                "
 
+# install to the image as boot*.efi if its the EFI_PROVIDER,
+# otherwise install as the full name.
+# This allows multiple bootloaders to coexist in a single image.
+python __anonymous () {
+    import re
+    target = d.getVar('TARGET_ARCH')
+    prefix = "" if d.getVar('EFI_PROVIDER', True) == "systemd-boot" else "systemd-"
+    if target == "x86_64":
+        systemdimage = prefix + "bootx64.efi"
+    else:
+        systemdimage = prefix + "bootia32.efi"
+    d.setVar("SYSTEMD_BOOT_IMAGE", systemdimage)
+    prefix = "systemd-" if prefix == "" else ""
+    d.setVar("SYSTEMD_BOOT_IMAGE_PREFIX", prefix)
+}
+
+FILES_${PN} = "/boot/EFI/BOOT/${SYSTEMD_BOOT_IMAGE}"
+
+RDEPENDS_${PN} += "virtual/systemd-bootconf"
+
 # Imported from the old gummiboot recipe
 TUNE_CCARGS_remove = "-mfpmath=sse"
 COMPATIBLE_HOST = "(x86_64.*|i.86.*)-linux"
@@ -29,12 +49,14 @@ do_compile() {
 		SYSTEMD_BOOT_EFI_ARCH="x64"
 	fi
 
-	oe_runmake systemd-boot${SYSTEMD_BOOT_EFI_ARCH}.efi
+	oe_runmake ${SYSTEMD_BOOT_IMAGE_PREFIX}${SYSTEMD_BOOT_IMAGE}
 }
 
 do_install() {
-	# Bypass systemd installation with a NOP
-	:
+	install -d ${D}/boot
+	install -d ${D}/boot/EFI
+	install -d ${D}/boot/EFI/BOOT
+	install ${B}/systemd-boot*.efi ${D}/boot/EFI/BOOT/${SYSTEMD_BOOT_IMAGE}
 }
 
 do_deploy () {
Signature · 1 line
2.14.3
#20 lore raw

PATCH v3 15/21 packagegroup-core-boot: add kernel for EFI systems

In reply to California Sullivan

Previously this wasn't needed because the kernel was added at image creation time to the boot partition. Now that the boot partition is created from the /boot/ partition of the rootfs, it needs to be installed there.

---
 meta/recipes-core/packagegroups/packagegroup-core-boot.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/packagegroups/packagegroup-core-boot.bb +1 -1
index 0fcb8ba9193..76cd7fc4ebf 100644
@@ -37,7 +37,7 @@ RDEPENDS_${PN} = "\
     ${VIRTUAL-RUNTIME_base-utils} \
     ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "${SYSVINIT_SCRIPTS}", "", d)} \
     ${@bb.utils.contains("MACHINE_FEATURES", "keyboard", "${VIRTUAL-RUNTIME_keymaps}", "", d)} \
-    ${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)} \
+    ${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER} kernel", "", d)} \
     netbase \
     ${VIRTUAL-RUNTIME_login_manager} \
     ${VIRTUAL-RUNTIME_init_manager} \
Signature · 1 line
2.14.3
#21 lore raw

PATCH v3 16/21 init-install.sh: support multiple kernels and don't assume vmlinuz

In reply to California Sullivan

Since kernels will not necessarily be installed as vmlinuz anymore, don't assume that's its name for either the bootloader config or the copy of the kernel.

Also, allow installing multiple kernels by searching for common kernel names.

---
 .../initrdscripts/files/init-install.sh            | 37 ++++++++++++++++++++--
 1 file changed, 34 insertions(+), 3 deletions(-)
meta/recipes-core/initrdscripts/files/init-install.sh +34 -3
index dade059c8f1..713a83092bf 100644
@@ -256,9 +256,34 @@ fi
 umount /tgt_root
 umount /src_root
 
+echo "Looking for kernels to use as boot target.."
+# Find kernel to boot to
+# Give user options if multiple are found
+kernels="$(find /run/media/$1/ -type f  \
+           -name bzImage* -o -name zImage* \
+           -o -name vmlinux* -o -name vmlinuz* \
+           -o -name fitImage* \
+           | sed s:.*/::)"
+if [ -n "$(echo $kernels)" ]; then
+    # only one kernel entry if no space
+    if [ -z "$(echo $kernels | grep " ")" ]; then
+        kernel=$kernels
+        echo "$kernel will be used as the boot target"
+    else
+        echo "Which kernel do we want to boot by default? The following kernels were found:"
+        echo $kernels
+        read answer
+        kernel=$answer
+    fi
+else
+    echo "No kernels found, exiting..."
+    exit 1
+fi
+
 # Handling of the target boot partition
 mount $bootfs /boot
 echo "Preparing boot partition..."
+
 if [ -f /etc/grub.d/00_header -a $grub_version -ne 0 ] ; then
     echo "Preparing custom grub2 menu..."
     root_part_uuid=$(blkid -o value -s PARTUUID ${rootfs})
@@ -268,7 +293,7 @@ if [ -f /etc/grub.d/00_header -a $grub_version -ne 0 ] ; then
     cat >$GRUBCFG <<_EOF
 menuentry "Linux" {
     search --no-floppy --fs-uuid $boot_uuid --set root
-    linux /vmlinuz root=PARTUUID=$root_part_uuid $rootwait rw $5 $3 $4 quiet
+    linux /$kernel root=PARTUUID=$root_part_uuid $rootwait rw $5 $3 $4 quiet
 }
 _EOF
     chmod 0444 $GRUBCFG
@@ -282,10 +307,16 @@ if [ $grub_version -eq 0 ] ; then
     echo "timeout 30" >> /boot/grub/menu.lst
     echo "title Live Boot/Install-Image" >> /boot/grub/menu.lst
     echo "root  (hd0,0)" >> /boot/grub/menu.lst
-    echo "kernel /vmlinuz root=$rootfs rw $3 $4 quiet" >> /boot/grub/menu.lst
+    echo "kernel /$kernel root=$rootfs rw $3 $4 quiet" >> /boot/grub/menu.lst
 fi
 
-cp /run/media/$1/vmlinuz /boot/
+# Copy kernel artifacts. To add more artifacts just add to types
+# For now just support kernel types already being used by something in OE-core
+for types in bzImage zImage vmlinux vmlinuz fitImage; do
+    for kernel in `find /run/media/$1/ -name $types*`; do
+        cp $kernel /boot
+    done
+done
 
 umount /boot
 
Signature · 1 line
2.14.3
#22 lore raw

PATCH v3 17/21 layer.conf: add -bootconf recipes to SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS

In reply to California Sullivan

The bootloaders depend on these to be functional in the non-deploy case, but changes in them don't require rebuilding of the packages.

---
 meta/conf/layer.conf | 2 ++
 1 file changed, 2 insertions(+)
meta/conf/layer.conf +2 -0
index 67820588d37..7193f113885 100644
@@ -61,10 +61,12 @@ SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \
   initramfs-module-install->grub \
   initramfs-module-install->parted \
   initramfs-module-install->util-linux \
+  grub-efi->grub-bootconf \
   liberation-fonts->fontconfig \
   cantarell-fonts->fontconfig \
   gnome-icon-theme->librsvg \
   font-alias->font-util \
+  systemd-boot->systemd-bootconf \
   weston-init->weston \
   weston-init->kbd \
 "
Signature · 1 line
2.14.3
#23 lore raw

PATCH v3 18/21 selftests: Add test case for booting a generic EFI boot partition image

In reply to California Sullivan

Simple test case that adds 'efi' to MACHINE_FEATURES, sets WKS_FILE to "efi-bootdisk.wks.in", installed required boot items, and attempts to boot the wic image.

Quick check to make sure that the feature actually works.

---
 meta/lib/oeqa/selftest/cases/efibootpartition.py | 45 ++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 meta/lib/oeqa/selftest/cases/efibootpartition.py
meta/lib/oeqa/selftest/cases/efibootpartition.py new file +45 -0
new file mode 100644
index 00000000000..0c832566965
@@ -0,0 +1,45 @@
+# Based on runqemu.py test file
+#
+# Copyright (c) 2017 Wind River Systems, Inc.
+#
+
+import re
+
+from oeqa.selftest.case import OESelftestTestCase
+from oeqa.utils.commands import bitbake, runqemu, get_bb_var
+
+class GenericEFITest(OESelftestTestCase):
+    """EFI booting test class"""
+
+    buffer = True
+    cmd_common = "runqemu nographic serial wic ovmf"
+    efi_provider = "systemd-boot"
+    image = "core-image-minimal"
+    machine = "qemux86-64"
+    recipes_built = False
+
+    @classmethod
+    def setUpLocal(self):
+        super(GenericEFITest, self).setUpLocal(self)
+
+        self.write_config(self,
+"""
+EFI_PROVIDER = "%s"
+IMAGE_FSTYPES_pn-%s_append = " wic"
+MACHINE = "%s"
+MACHINE_FEATURES_append = " efi"
+WKS_FILE = "efi-bootdisk.wks.in"
+IMAGE_INSTALL_append = " grub-efi systemd-boot kernel-image-bzimage"
+"""
+% (self.efi_provider, self.image, self.machine))
+        if not self.recipes_built:
+            bitbake("ovmf")
+            bitbake(self.image)
+            self.recipes_built = True
+
+    @classmethod
+    def test_boot_efi(self):
+        """Test generic boot partition with qemu"""
+        cmd = "%s %s" % (self.cmd_common, self.machine)
+        with runqemu(self.image, ssh=False, launch_cmd=cmd) as qemu:
+            self.assertTrue(qemu.runner.logged, "Failed: %s" % cmd)
Signature · 1 line
2.14.3
#24 lore raw

PATCH v3 19/21 grub-efi-cfg.bbclass: Don't reference or set OVERRIDES

In reply to California Sullivan

There's no need to add to the local copy of overrides and then not do anything with it.

Now that this function is being used in package creation it was causing sstate issues as well, as MACHINE is always in OVERRIDES, so something trivial such as the name of the MACHINE would cause the hash to change.

---
 meta/classes/grub-efi-cfg.bbclass | 6 ------
 1 file changed, 6 deletions(-)
meta/classes/grub-efi-cfg.bbclass +0 -6
index 85173c91fc3..d2226af97a7 100644
@@ -87,13 +87,7 @@ python build_efi_cfg() {
     for label in labels.split():
         localdata = d.createCopy()
 
-        overrides = localdata.getVar('OVERRIDES')
-        if not overrides:
-            bb.fatal('OVERRIDES not defined')
-
         for btype in btypes:
-            localdata.setVar('OVERRIDES', label + ':' + overrides)
-
             cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
             lb = label
             if label == "install":
Signature · 1 line
2.14.3
#25 lore raw

PATCH v3 20/21 systemd-boot-cfg.bbclass: Don't reference or set OVERRIDES

In reply to California Sullivan

There's no need to add to the local copy of overrides and then not do anything with it.

Now that this function is being used in package creation it was causing sstate issues as well, as MACHINE is always in OVERRIDES, so something trivial such as the name of the MACHINE would cause the hash to change.

---
 meta/classes/systemd-boot-cfg.bbclass | 5 -----
 1 file changed, 5 deletions(-)
meta/classes/systemd-boot-cfg.bbclass +0 -5
index 360c86cbd34..107758548c6 100644
@@ -39,10 +39,6 @@ python build_efi_cfg() {
     for label in labels.split():
         localdata = d.createCopy()
 
-        overrides = localdata.getVar('OVERRIDES')
-        if not overrides:
-            bb.fatal('OVERRIDES not defined')
-
         entryfile = "%s/%s.conf" % (s, label)
         if not os.path.exists(s):
             os.makedirs(s)
@@ -51,7 +47,6 @@ python build_efi_cfg() {
             entrycfg = open(entryfile, "w")
         except OSError:
             bb.fatal('Unable to open %s' % entryfile)
-        localdata.setVar('OVERRIDES', label + ':' + overrides)
 
         entrycfg.write('title %s\n' % label)
 
Signature · 1 line
2.14.3
#26 lore raw

PATCH v3 21/21 maintainers.inc: add myself as -bootconf recipe maintainer

In reply to California Sullivan
---
 meta/conf/distro/include/maintainers.inc | 2 ++
 1 file changed, 2 insertions(+)
meta/conf/distro/include/maintainers.inc +2 -0
index 50392487903..ba5e6137e77 100644
@@ -236,6 +236,7 @@ RECIPE_MAINTAINER_pn-gptfdisk = "Alexander Kanavin <[email protected]>
 RECIPE_MAINTAINER_pn-grep = "Denys Dmytriyenko <[email protected]>"
 RECIPE_MAINTAINER_pn-groff = "Hongxu Jia <[email protected]>"
 RECIPE_MAINTAINER_pn-grub = "Alexander Kanavin <[email protected]>"
+RECIPE_MAINTAINER_pn-grub-bootconf = "California Sullivan <[email protected]>"
 RECIPE_MAINTAINER_pn-grub-efi = "Alexander Kanavin <[email protected]>"
 RECIPE_MAINTAINER_pn-gsettings-desktop-schemas = "Maxin B. John <[email protected]>"
 RECIPE_MAINTAINER_pn-gst-examples = "Anuj Mittal <[email protected]>"
@@ -683,6 +684,7 @@ RECIPE_MAINTAINER_pn-sysstat = "Chen Qi <[email protected]>"
 RECIPE_MAINTAINER_pn-systemd = "Chen Qi <[email protected]>"
 RECIPE_MAINTAINER_pn-systemd-boot = "Chen Qi <[email protected]>"
 RECIPE_MAINTAINER_pn-systemd-bootchart = "Chen Qi <[email protected]>"
+RECIPE_MAINTAINER_pn-systemd-bootconf = "California Sullivan <[email protected]>"
 RECIPE_MAINTAINER_pn-systemd-compat-units = "Chen Qi <[email protected]>"
 RECIPE_MAINTAINER_pn-systemd-serialgetty = "Chen Qi <[email protected]>"
 RECIPE_MAINTAINER_pn-systemd-systemctl-native = "Chen Qi <[email protected]>"
Signature · 1 line
2.14.3