[PATCHv2] wic/plugins: fix kernel version detection for bios

Message ID 20210204163912.31570-1-henning.schild@siemens.com
State Superseded, archived
Headers show
Series [PATCHv2] wic/plugins: fix kernel version detection for bios | expand

Commit Message

Henning Schild Feb. 4, 2021, 6:39 a.m. UTC
From: Henning Schild <henning.schild@siemens.com>

The mechanism used to "cut off the end" seems to cut off too much.

>>> "vmlinuz-4.19.0-14-amd64".strip('-' + 'amd64')
'vmlinuz-4.19.0-1'

But indeed we would hope for 'vmlinuz-4.19.0-14'. This is a fix that
should be aplied asap, it seems to affect all "even" kernel revisions,
"odd" is odly enough no problem.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Henning Schild Feb. 4, 2021, 6:51 a.m. UTC | #1
Seems like a kernel update in buster found a bug in our wic plugin for
legacy bios. I would like to ask for a quick review of this, since it
currently breaks building bios wic images.

Henning

Am Thu, 4 Feb 2021 17:39:12 +0100
schrieb Henning Schild <henning.schild@siemens.com>:

> From: Henning Schild <henning.schild@siemens.com>
> 
> The mechanism used to "cut off the end" seems to cut off too much.
> 
> >>> "vmlinuz-4.19.0-14-amd64".strip('-' + 'amd64')  
> 'vmlinuz-4.19.0-1'
> 
> But indeed we would hope for 'vmlinuz-4.19.0-14'. This is a fix that
> should be aplied asap, it seems to affect all "even" kernel revisions,
> "odd" is odly enough no problem.
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>  meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> 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
> 493615b481..ece08efa76 100644 ---
> a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py +++
> b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py @@
> -135,7 +135,7 @@ class BootimgPcbiosIsarPlugin(SourcePlugin):
> kernel_name = get_bitbake_var("KERNEL_NAME") rootfs_dir =
> get_bitbake_var("IMAGE_ROOTFS") kernel =
> os.path.basename(os.path.realpath(os.path.join(rootfs_dir,
> kernel_file)))
> -            kernel_version = kernel.strip('-' +
> kernel_name).strip(kernel_file + '-')
> +            kernel_version =
> kernel[len(kernel_file)+1:-(len(kernel_name)+1)] initrd =
> "initrd.img-%s-%s" % (kernel_version, kernel_name) 
>              syslinux_conf += "KERNEL " + kernel + "\n"
> @@ -165,7 +165,7 @@ class BootimgPcbiosIsarPlugin(SourcePlugin):
>          kernel_name = get_bitbake_var("KERNEL_NAME")
>          rootfs_dir = rootfs_dir['ROOTFS_DIR']
>          kernel =
> os.path.basename(os.path.realpath(os.path.join(rootfs_dir,
> kernel_file)))
> -        kernel_version = kernel.strip('-' +
> kernel_name).strip(kernel_file + '-')
> +        kernel_version =
> kernel[len(kernel_file)+1:-(len(kernel_name)+1)] initrd =
> "initrd.img-%s-%s" % (kernel_version, kernel_name) config =
> "config-%s-%s" % (kernel_version, kernel_name) mapfile =
> "System.map-%s-%s" % (kernel_version, kernel_name)
Baurzhan Ismagulov Feb. 4, 2021, 7:04 a.m. UTC | #2
On Thu, Feb 04, 2021 at 05:51:23PM +0100, Henning Schild wrote:
> Seems like a kernel update in buster found a bug in our wic plugin for
> legacy bios. I would like to ask for a quick review of this, since it
> currently breaks building bios wic images.

Thanks for heads up, will check.

With kind regards,
Baurzhan.
Henning Schild Feb. 4, 2021, 9:37 a.m. UTC | #3
Am Thu, 4 Feb 2021 18:04:57 +0100
schrieb Baurzhan Ismagulov <ibr@radix50.net>:

> On Thu, Feb 04, 2021 at 05:51:23PM +0100, Henning Schild wrote:
> > Seems like a kernel update in buster found a bug in our wic plugin
> > for legacy bios. I would like to ask for a quick review of this,
> > since it currently breaks building bios wic images.  
> 
> Thanks for heads up, will check.

I would assume all pipelines to fail without it, since "yesterday".
Applying it should hopefully fix that. If it gets merged people will
hopefully find it and bump to latest next or backport to whichever isar
version they might be on.

Henning

> With kind regards,
> Baurzhan.
Baurzhan Ismagulov Feb. 4, 2021, 10:41 p.m. UTC | #4
On Thu, Feb 04, 2021 at 05:39:12PM +0100, Henning Schild wrote:
> From: Henning Schild <henning.schild@siemens.com>
> 
> The mechanism used to "cut off the end" seems to cut off too much.
> 
> >>> "vmlinuz-4.19.0-14-amd64".strip('-' + 'amd64')
> 'vmlinuz-4.19.0-1'
> 
> But indeed we would hope for 'vmlinuz-4.19.0-14'. This is a fix that
> should be aplied asap, it seems to affect all "even" kernel revisions,
> "odd" is odly enough no problem.
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>

Regarding the commit message, I'd suggest:

* Mentioning the user-visible failure.

* Dropping the "This is a fix that should be aplied asap" part.

* "odly" -> "oddly".

We'll provide an update regarding the code.

With kind regards,
Baurzhan.

Patch

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 493615b481..ece08efa76 100644
--- a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
+++ b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
@@ -135,7 +135,7 @@  class BootimgPcbiosIsarPlugin(SourcePlugin):
             kernel_name = get_bitbake_var("KERNEL_NAME")
             rootfs_dir = get_bitbake_var("IMAGE_ROOTFS")
             kernel = os.path.basename(os.path.realpath(os.path.join(rootfs_dir, kernel_file)))
-            kernel_version = kernel.strip('-' + kernel_name).strip(kernel_file + '-')
+            kernel_version = kernel[len(kernel_file)+1:-(len(kernel_name)+1)]
             initrd = "initrd.img-%s-%s" % (kernel_version, kernel_name)
 
             syslinux_conf += "KERNEL " + kernel + "\n"
@@ -165,7 +165,7 @@  class BootimgPcbiosIsarPlugin(SourcePlugin):
         kernel_name = get_bitbake_var("KERNEL_NAME")
         rootfs_dir = rootfs_dir['ROOTFS_DIR']
         kernel = os.path.basename(os.path.realpath(os.path.join(rootfs_dir, kernel_file)))
-        kernel_version = kernel.strip('-' + kernel_name).strip(kernel_file + '-')
+        kernel_version = kernel[len(kernel_file)+1:-(len(kernel_name)+1)]
         initrd = "initrd.img-%s-%s" % (kernel_version, kernel_name)
         config = "config-%s-%s" % (kernel_version, kernel_name)
         mapfile = "System.map-%s-%s" % (kernel_version, kernel_name)