wic: bootimg-efi: add label source parameter
PATCH 1/1 wic: bootimg-efi: add label source parameter
From: Chee Yang Lee <[email protected]>
Add new source parameter label to allow boot.conf/grub.cfg label option to set as "install-efi", so far it's hardcoded to "Boot".
The label remain to "Boot" for systemd-boot or blank for grub-efi whenever label are not "install-efi".
when label set to "install-efi" the image can boot into image installation.
--- scripts/lib/wic/plugins/source/bootimg-efi.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
scripts/lib/wic/plugins/source/bootimg-efi.py +15 -5
@@ -72,9 +72,14 @@ class BootimgEFIPlugin(SourcePlugin): grubefi_conf += "menuentry '%s'{\n" % (title if title else "boot") kernel = "/bzImage" + label = source_params.get('label') - grubefi_conf += "linux %s root=%s rootwait %s\n" \ - % (kernel, creator.rootdev, bootloader.append) + if label == "install-efi": + grubefi_conf += "linux %s LABEL=%s rootwait %s\n" \ + % (kernel, label, bootloader.append) + else: + grubefi_conf += "linux %s root=%s rootwait %s\n" \ + % (kernel, creator.rootdev, bootloader.append) if initrd: grubefi_conf += "initrd /%s\n" % initrd
@@ -140,12 +145,17 @@ class BootimgEFIPlugin(SourcePlugin): # Create systemd-boot configuration using parameters from wks file kernel = "/bzImage" title = source_params.get('title') - + label = source_params.get('label') boot_conf = "" boot_conf += "title %s\n" % (title if title else "boot") boot_conf += "linux %s\n" % kernel - boot_conf += "options LABEL=Boot root=%s %s\n" % \ - (creator.rootdev, bootloader.append) + + if label == "install-efi": + boot_conf += "options LABEL=%s %s\n" % \ + (label, bootloader.append) + else: + boot_conf += "options LABEL=Boot root=%s %s\n" % \ + (creator.rootdev, bootloader.append) if initrd: boot_conf += "initrd /%s\n" % initrd
Signature · 1 line
2.7.4
Quoted 23 lines · On Mon, 2019-05-27 at 09:26 +0800, [email protected] wrote:
From: Chee Yang Lee <[email protected]>
Add new source parameter label to allow boot.conf/grub.cfg label option to set as "install-efi", so far it's hardcoded to "Boot".
The label remain to "Boot" for systemd-boot or blank for grub-efi whenever label are not "install-efi".
when label set to "install-efi" the image can boot into image installation.
Signed-off-by Chee Yang Lee <[email protected]>--- scripts/lib/wic/plugins/source/bootimg-efi.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)scripts/lib/wic/plugins/source/bootimg-efi.py +0
-0@@ -72,9 +72,14 @@ class BootimgEFIPlugin(SourcePlugin): grubefi_conf += "menuentry '%s'{\n" % (title if title else "boot") kernel = "/bzImage"
scripts/lib/wic/plugins/source/bootimg-efi.py class BootimgEFIPlugin(SourcePlugin): · line 82
Quoted 10 lines
scripts/lib/wic/plugins/source/bootimg-efi.py +7
-2+ label = source_params.get('label') - grubefi_conf += "linux %s root=%s rootwait %s\n" \ - % (kernel, creator.rootdev, bootloader.append) + if label == "install-efi": + grubefi_conf += "linux %s LABEL=%s rootwait %s\n" \ + % (kernel, label, bootloader.append) + else: + grubefi_conf += "linux %s root=%s rootwait %s\n" \ + % (kernel, creator.rootdev, bootloader.append)
I could be missing something as I don't know the wider code but wouldn't it make more sense to have:
label = source_params.get('label')label_conf = "root=%s" % creator.rootdev
if label:
label_conf = "LABEL=%s" % label
grubefi_conf += "linux %s %s rootwait %s\n" \
% (kernel, label_conf,
bootloader.append)
Which would then allow custom labels rather than a special case magic value? (and also reduce code duplication)
Cheers,
Richard