Skip to contentSkip to conversation

systemd-boot:grub-efi:wic: add variable APPENDS for multiple boot configuration

PATCH In review [email protected] 2 participants 5 messages Aug 2, 2019 – Aug 11, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 systemd-boot:grub-efi:wic: add variable APPENDS for multiple boot configuration

From: Chee Yang Lee <[email protected]>

introduce new variable APPENDS to define multiple boot configuration for systemd-boot and grub-efi.

APPENDS set the different in kernel option for each .conf file(for systemd-boot) or menuentry(for grub-efi). Include the differences in the title.
Separate each configuration with ";".

e.g.:
APPEND = "console=tty0 rootwait"
APPENDS = " i915.enable_guc=0; i915.enable_guc=2"

for systemd-boot, above setting will produce 2 .conf, boot-1.conf and boot-2.conf which set with below title and option:

boot-1.conf -

	title boot-1 i915.enable_guc=0
	option console=tty0 rootwait i915.enable_guc=0

boot-2.conf -

	title boot-2 i915.enable_guc=2
	option console=tty0 rootwait i915.enable_guc=2

also update oeqa/selftest/wic testcase to fit the new variable.

---
 meta/classes/grub-efi-cfg.bbclass             | 46 +++++++-------
 meta/classes/image_types_wic.bbclass          |  2 +-
 meta/classes/systemd-boot-cfg.bbclass         | 75 +++++++++++++----------
 meta/lib/oeqa/selftest/cases/wic.py           |  2 +-
 scripts/lib/wic/plugins/source/bootimg-efi.py | 86 +++++++++++++++------------
 5 files changed, 118 insertions(+), 93 deletions(-)
meta/classes/grub-efi-cfg.bbclass +24 -22
index f661a69..811c78f 100644
@@ -89,29 +89,31 @@ python build_efi_cfg() {
     for label in labels.split():
         localdata = d.createCopy()
 
+        initrd = localdata.getVar('INITRD')
+        append = localdata.getVar('APPEND')
+        appends = localdata.getVar('APPENDS') if localdata.getVar('APPENDS') else ""
         for btype in btypes:
-            cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0]))
-            lb = label
-            if label == "install":
-                lb = "install-efi"
-            kernel = localdata.getVar('KERNEL_IMAGETYPE')
-            cfgfile.write('linux /%s LABEL=%s' % (kernel, lb))
-
-            cfgfile.write(' %s' % replace_rootfs_uuid(d, root))
-
-            append = localdata.getVar('APPEND')
-            initrd = localdata.getVar('INITRD')
-
-            if append:
-                append = replace_rootfs_uuid(d, append)
-                cfgfile.write(' %s' % (append))
-
-            cfgfile.write(' %s' % btype[1])
-            cfgfile.write('\n')
-
-            if initrd:
-                cfgfile.write('initrd /initrd')
-            cfgfile.write('\n}\n')
+            for apd in appends.split(';'):
+                cfgfile.write('\nmenuentry \'%s%s %s\'{\n' % (label, btype[0],apd))
+                lb = label
+                if label == "install":
+                    lb = "install-efi"
+                kernel = localdata.getVar('KERNEL_IMAGETYPE')
+                cfgfile.write('linux /%s LABEL=%s' % (kernel, lb))
+
+                cfgfile.write(' %s' % replace_rootfs_uuid(d, root))
+
+                ap = append + apd
+                if ap:
+                    append = replace_rootfs_uuid(d, ap)
+                    cfgfile.write(' %s' % (ap))
+
+                cfgfile.write(' %s' % btype[1])
+                cfgfile.write('\n')
+
+                if initrd:
+                    cfgfile.write('initrd /initrd')
+                cfgfile.write('\n}\n')
 
     cfgfile.close()
 }
meta/classes/image_types_wic.bbclass +1 -1
index 519aeb1..4f2bdcc 100644
@@ -3,7 +3,7 @@
 WICVARS ?= "\
            BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD IMAGE_BASENAME IMAGE_BOOT_FILES \
            IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD INITRD_LIVE ISODIR RECIPE_SYSROOT_NATIVE \
-           ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS \
+           ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS APPENDS \
            KERNEL_IMAGETYPE MACHINE INITRAMFS_IMAGE INITRAMFS_IMAGE_BUNDLE INITRAMFS_LINK_NAME"
 
 inherit ${@bb.utils.contains('INITRAMFS_IMAGE_BUNDLE', '1', 'kernel-artifact-names', '', d)}
meta/classes/systemd-boot-cfg.bbclass +45 -30

86 lines not on this page · raw message

meta/lib/oeqa/selftest/cases/wic.py +1 -1
index fcdd550..cee8776 100644
@@ -498,7 +498,7 @@ class Wic2(WicTestCase):
 
         wicvars = set(bb_vars['WICVARS'].split())
         # filter out optional variables
-        wicvars = wicvars.difference(('DEPLOY_DIR_IMAGE', 'IMAGE_BOOT_FILES',
+        wicvars = wicvars.difference(('DEPLOY_DIR_IMAGE', 'IMAGE_BOOT_FILES', 'APPENDS',
                                       'INITRD', 'INITRD_LIVE', 'ISODIR','INITRAMFS_IMAGE',
                                       'INITRAMFS_IMAGE_BUNDLE', 'INITRAMFS_LINK_NAME'))
         with open(path) as envfile:
scripts/lib/wic/plugins/source/bootimg-efi.py +47 -39

114 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw
Quoted 21 lines · On Fri, 2019-08-02 at 20:33 +0800, [email protected] wrote:

From: Chee Yang Lee <[email protected]>

introduce new variable APPENDS to define multiple boot configuration for systemd-boot and grub-efi.

APPENDS set the different in kernel option for each .conf file(for systemd-boot) or menuentry(for grub-efi). Include the differences in the title.
Separate each configuration with ";".

e.g.:
APPEND = "console=tty0 rootwait"
APPENDS = " i915.enable_guc=0; i915.enable_guc=2"

for systemd-boot, above setting will produce 2 .conf, boot-1.conf and boot-2.conf which set with below title and option:

boot-1.conf -

	title boot-1 i915.enable_guc=0
	option console=tty0 rootwait i915.enable_guc=0
Quoted 6 lines

boot-2.conf -

	title boot-2 i915.enable_guc=2
	option console=tty0 rootwait i915.enable_guc=2

also update oeqa/selftest/wic testcase to fit the new variable.

APPEND was a horrible choice of variable name. Lets not compound the problem by adding new versions of it!

Cheers,

Richard

#2 lore raw

Hi Richard,

would KERNEL_CMD_LINES a better variable name for this case?

On 8/2/19, 11:46 PM, "Richard Purdie" <[email protected]> wrote:

On Fri, 2019-08-02 at 20:33 +0800, [email protected] wrote:
> From: Chee Yang Lee <[email protected]>
>
> introduce new variable APPENDS to define multiple
> boot configuration for systemd-boot and grub-efi.
>
> APPENDS set the different in kernel option for each .conf > file(for systemd-boot) or menuentry(for grub-efi).
> Include the differences in the title.
> Separate each configuration with ";".
>
> e.g.:
> APPEND = "console=tty0 rootwait"
> APPENDS = " i915.enable_guc=0; i915.enable_guc=2"
>
> for systemd-boot, above setting will produce 2 .conf, > boot-1.conf and boot-2.conf which set with below title and option:
>
> boot-1.conf -
> title boot-1 i915.enable_guc=0
> option console=tty0 rootwait i915.enable_guc=0
>
> boot-2.conf -
> title boot-2 i915.enable_guc=2
> option console=tty0 rootwait i915.enable_guc=2
>
>
> also update oeqa/selftest/wic testcase to fit the new variable.

APPEND was a horrible choice of variable name. Lets not compound the problem by adding new versions of it!

Cheers,

Richard

#3 lore raw

Hi,

Quoted 1 line · Chee Yang

would KERNEL_CMD_LINES a better variable name for this case?

I'd like to understand which code is using the variable as that might help name it correctly. I'd have said it should be CMDLINE without the space as that is generally how the kernel refers to it. I think the prefix should indicate which code is going to end up using it so KERNEL may be too generic.

Cheers,

Richard

#4 lore raw

This variable would only be use by bootloader to generate boot config file and since it define the differences in kernel command line for multiple boot config. maybe BOOTLOADER_KERNEL_CMDLINES? Or MULTI_KERNEL_CMDLINE?

On 8/8/19, 2:43 AM, "[email protected]" <[email protected]> wrote:

Hi,

On Mon, 2019-08-05 at 08:40 +0000, Lee, Chee Yang wrote:
> would KERNEL_CMD_LINES a better variable name for this case?

I'd like to understand which code is using the variable as that might help name it correctly. I'd have said it should be CMDLINE without the space as that is generally how the kernel refers to it. I think the prefix should indicate which code is going to end up using it so KERNEL may be too generic.

Cheers,

Richard