Message ID | 20241114135506.1467238-1-amikan@ilbers.de |
---|---|
State | Accepted, archived |
Headers | show |
Series | wic: Allow custom kernel image names | expand |
On Thu, 2024-11-14 at 15:55 +0200, Anton Mikanovich wrote: > Some targets can have custom kernel file names specified with > KERNEL_FILE variable. Take this value into account when trying to > autodetect boot files inside WIC plugins. > > Signed-off-by: Anton Mikanovich <amikan@ilbers.de> > --- > meta/classes/imagetypes_wic.bbclass | 2 +- > meta/scripts/lib/wic/plugins/isarpluginbase.py | 8 > ++++++-- > meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py | 8 > ++++++-- > .../scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py | 4 +++- > 4 files changed, 16 insertions(+), 6 deletions(-) > > diff --git a/meta/classes/imagetypes_wic.bbclass > b/meta/classes/imagetypes_wic.bbclass > index 3b697cdd..38b5f0e1 100644 > --- a/meta/classes/imagetypes_wic.bbclass > +++ b/meta/classes/imagetypes_wic.bbclass > @@ -107,7 +107,7 @@ WICVARS += "\ > ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR > TARGET_SYS TRANSLATED_TARGET_ARCH" > > # Isar specific vars used in our plugins > -WICVARS += "DISTRO DISTRO_ARCH" > +WICVARS += "DISTRO DISTRO_ARCH KERNEL_FILE" > > python do_rootfs_wicenv () { > wicvars = d.getVar('WICVARS') > diff --git a/meta/scripts/lib/wic/plugins/isarpluginbase.py > b/meta/scripts/lib/wic/plugins/isarpluginbase.py > index 99e552e0..76df733d 100644 > --- a/meta/scripts/lib/wic/plugins/isarpluginbase.py > +++ b/meta/scripts/lib/wic/plugins/isarpluginbase.py > @@ -15,9 +15,13 @@ def isar_populate_boot_cmd(rootfs_dir, hdddir): > # no not copy symlinks (ubuntu places them here) because > targetfs is fat > return "find %s/boot -type f -exec cp -a {} %s ;" % (rootfs_dir, > hdddir) > > -def isar_get_filenames(rootfs_dir): > + > +def isar_get_filenames(rootfs_dir, kernel_file=None): > # figure out the real filename in /boot by following debian > symlinks > - for kernel_symlink in ["vmlinuz", "vmlinux" ]: > + possible_kernel_files = ["vmlinuz", "vmlinux"] > + if kernel_file: > + possible_kernel_files.insert(0, kernel_file) > + for kernel_symlink in possible_kernel_files: > kernel_file_abs = os.path.join(rootfs_dir, kernel_symlink) > if os.path.isfile(kernel_file_abs): > break > diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py > b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py > index 079b70d6..50f4187d 100644 > --- a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py > +++ b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py > @@ -108,7 +108,9 @@ class BootimgEFIPlugin(SourcePlugin): > if label: > label_conf = "LABEL=%s" % label > > - kernel, initrd = > isar_get_filenames(get_bitbake_var("IMAGE_ROOTFS")) > + kernel, initrd = isar_get_filenames( > + get_bitbake_var("IMAGE_ROOTFS"), > get_bitbake_var("KERNEL_FILE") > + ) > grubefi_conf += "linux /%s %s rootwait %s\n" \ > % (kernel, label_conf, bootloader.append) > > @@ -186,7 +188,9 @@ class BootimgEFIPlugin(SourcePlugin): > title = source_params.get('title') > > temp_initrd = initrd > - kernel, initrd = > isar_get_filenames(get_bitbake_var("IMAGE_ROOTFS")) > + kernel, initrd = isar_get_filenames( > + get_bitbake_var("IMAGE_ROOTFS"), > get_bitbake_var("KERNEL_FILE") > + ) > if temp_initrd: > initrd = temp_initrd > > diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios- > isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py > index 43f4bec4..d5040b72 100644 > --- a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py > +++ b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py > @@ -134,7 +134,9 @@ class BootimgPcbiosIsarPlugin(SourcePlugin): > > kernel = "/vmlinuz" > > - kernel, initrd = > isar_get_filenames(get_bitbake_var("IMAGE_ROOTFS")) > + kernel, initrd = isar_get_filenames( > + get_bitbake_var("IMAGE_ROOTFS"), > get_bitbake_var("KERNEL_FILE") > + ) > > syslinux_conf += "KERNEL " + kernel + "\n" > > -- > 2.34.1 > Applied to next.
diff --git a/meta/classes/imagetypes_wic.bbclass b/meta/classes/imagetypes_wic.bbclass index 3b697cdd..38b5f0e1 100644 --- a/meta/classes/imagetypes_wic.bbclass +++ b/meta/classes/imagetypes_wic.bbclass @@ -107,7 +107,7 @@ WICVARS += "\ ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS TRANSLATED_TARGET_ARCH" # Isar specific vars used in our plugins -WICVARS += "DISTRO DISTRO_ARCH" +WICVARS += "DISTRO DISTRO_ARCH KERNEL_FILE" python do_rootfs_wicenv () { wicvars = d.getVar('WICVARS') diff --git a/meta/scripts/lib/wic/plugins/isarpluginbase.py b/meta/scripts/lib/wic/plugins/isarpluginbase.py index 99e552e0..76df733d 100644 --- a/meta/scripts/lib/wic/plugins/isarpluginbase.py +++ b/meta/scripts/lib/wic/plugins/isarpluginbase.py @@ -15,9 +15,13 @@ def isar_populate_boot_cmd(rootfs_dir, hdddir): # no not copy symlinks (ubuntu places them here) because targetfs is fat return "find %s/boot -type f -exec cp -a {} %s ;" % (rootfs_dir, hdddir) -def isar_get_filenames(rootfs_dir): + +def isar_get_filenames(rootfs_dir, kernel_file=None): # figure out the real filename in /boot by following debian symlinks - for kernel_symlink in ["vmlinuz", "vmlinux" ]: + possible_kernel_files = ["vmlinuz", "vmlinux"] + if kernel_file: + possible_kernel_files.insert(0, kernel_file) + for kernel_symlink in possible_kernel_files: kernel_file_abs = os.path.join(rootfs_dir, kernel_symlink) if os.path.isfile(kernel_file_abs): break diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py index 079b70d6..50f4187d 100644 --- a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py +++ b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py @@ -108,7 +108,9 @@ class BootimgEFIPlugin(SourcePlugin): if label: label_conf = "LABEL=%s" % label - kernel, initrd = isar_get_filenames(get_bitbake_var("IMAGE_ROOTFS")) + kernel, initrd = isar_get_filenames( + get_bitbake_var("IMAGE_ROOTFS"), get_bitbake_var("KERNEL_FILE") + ) grubefi_conf += "linux /%s %s rootwait %s\n" \ % (kernel, label_conf, bootloader.append) @@ -186,7 +188,9 @@ class BootimgEFIPlugin(SourcePlugin): title = source_params.get('title') temp_initrd = initrd - kernel, initrd = isar_get_filenames(get_bitbake_var("IMAGE_ROOTFS")) + kernel, initrd = isar_get_filenames( + get_bitbake_var("IMAGE_ROOTFS"), get_bitbake_var("KERNEL_FILE") + ) if temp_initrd: initrd = temp_initrd diff --git a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py index 43f4bec4..d5040b72 100644 --- a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py +++ b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py @@ -134,7 +134,9 @@ class BootimgPcbiosIsarPlugin(SourcePlugin): kernel = "/vmlinuz" - kernel, initrd = isar_get_filenames(get_bitbake_var("IMAGE_ROOTFS")) + kernel, initrd = isar_get_filenames( + get_bitbake_var("IMAGE_ROOTFS"), get_bitbake_var("KERNEL_FILE") + ) syslinux_conf += "KERNEL " + kernel + "\n"
Some targets can have custom kernel file names specified with KERNEL_FILE variable. Take this value into account when trying to autodetect boot files inside WIC plugins. Signed-off-by: Anton Mikanovich <amikan@ilbers.de> --- meta/classes/imagetypes_wic.bbclass | 2 +- meta/scripts/lib/wic/plugins/isarpluginbase.py | 8 ++++++-- meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py | 8 ++++++-- .../scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py | 4 +++- 4 files changed, 16 insertions(+), 6 deletions(-)