[v6,7/8] Fix legacy bios boot partition

Message ID 20201014133042.18753-3-Vijaikumar_Kanagarajan@mentor.com
State Accepted, archived
Headers show
Series WIC update | expand

Commit Message

Vijai Kumar K Oct. 14, 2020, 4:30 a.m. UTC
In case of legacy bios, the kernel is required to be present
in a seperate partition with necessary syslinux files. This was
never mounted onto the target and standard kernel update via
apt-get was impossible.

Rename the existing kernel and initrd files in the syslinux
partition to the standard debian naming format. Copy over
System.map and config files to the partition and exclude the
/boot in root partition. The latest wic automatically adds the
necessary entry for /boot partition in fstab which automounts
it during boot.

Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
---
 .../lib/wic/canned-wks/common-isar.wks.inc    |  2 +-
 meta/classes/wic-img.bbclass                  |  3 +-
 .../wic/plugins/source/bootimg-pcbios-isar.py | 31 ++++++++++++++-----
 3 files changed, 26 insertions(+), 10 deletions(-)

Patch

diff --git a/meta-isar/scripts/lib/wic/canned-wks/common-isar.wks.inc b/meta-isar/scripts/lib/wic/canned-wks/common-isar.wks.inc
index c8ea4c2..cc38a01 100644
--- a/meta-isar/scripts/lib/wic/canned-wks/common-isar.wks.inc
+++ b/meta-isar/scripts/lib/wic/canned-wks/common-isar.wks.inc
@@ -1,3 +1,3 @@ 
 # This file is included into 3 canned wks files from this directory
 part /boot --source bootimg-pcbios-isar --ondisk sda --label boot --active --align 1024
-part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024
+part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --exclude-path=boot
diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass
index 985137f..2275ebe 100644
--- a/meta/classes/wic-img.bbclass
+++ b/meta/classes/wic-img.bbclass
@@ -95,7 +95,8 @@  WIC_CREATE_EXTRA_ARGS ?= ""
 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 TRANSLATED_TARGET_ARCH"
+           ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS TRANSLATED_TARGET_ARCH \
+           KERNEL_NAME KERNEL_FILE"
 
 # Isar specific vars used in our plugins
 WICVARS += "KERNEL_IMAGE INITRD_IMAGE DISTRO_ARCH"
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 4d916d6..493615b 100644
--- a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
+++ b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
@@ -131,8 +131,13 @@  class BootimgPcbiosIsarPlugin(SourcePlugin):
             syslinux_conf += "DEFAULT boot\n"
             syslinux_conf += "LABEL boot\n"
 
-            kernel = get_bitbake_var("KERNEL_IMAGE")
-            initrd = get_bitbake_var("INITRD_IMAGE")
+            kernel_file = get_bitbake_var("KERNEL_FILE")
+            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 + '-')
+            initrd = "initrd.img-%s-%s" % (kernel_version, kernel_name)
+
             syslinux_conf += "KERNEL " + kernel + "\n"
 
             syslinux_conf += "APPEND label=boot root=%s initrd=%s %s\n" % \
@@ -156,15 +161,25 @@  class BootimgPcbiosIsarPlugin(SourcePlugin):
         syslinux_dir = cls._get_syslinux_dir(bootimg_dir)
 
         staging_kernel_dir = kernel_dir
-        kernel = get_bitbake_var("KERNEL_IMAGE")
-        initrd = get_bitbake_var("INITRD_IMAGE")
+        kernel_file = get_bitbake_var("KERNEL_FILE")
+        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 + '-')
+        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)
 
         hdddir = "%s/hdd/boot" % cr_workdir
 
-        cmds = ("install -m 0644 %s/%s %s/%s" %
-                (staging_kernel_dir, kernel, hdddir, kernel),
-                "install -m 0644 %s/%s %s/%s" %
-                (staging_kernel_dir, initrd, hdddir, initrd),
+        cmds = ("install -m 0644 %s/%s/%s %s/%s" %
+                (rootfs_dir, "boot", kernel, hdddir, kernel),
+                "install -m 0644 %s/%s/%s %s/%s" %
+                (rootfs_dir, "boot", initrd, hdddir, initrd),
+                "install -m 0644 %s/%s/%s %s/%s" %
+                (rootfs_dir, "boot", config, hdddir, config),
+                "install -m 0644 %s/%s/%s %s/%s" %
+                (rootfs_dir, "boot", mapfile, hdddir, mapfile),
                 "install -m 444 %s/modules/bios/ldlinux.c32 %s/ldlinux.c32" %
                 (syslinux_dir, hdddir),
                 "install -m 0644 %s/modules/bios/vesamenu.c32 %s/vesamenu.c32" %