* [PATCH v2 1/3] git: reset our fork to OE upstream for re-forking
2021-08-27 10:25 [PATCH v2 0/3] re-fork wic pcbios plugin Henning Schild
@ 2021-08-27 10:25 ` Henning Schild
2021-08-27 10:25 ` [PATCH v2 2/3] wic: apply the actual fork changes to our pcbios plugin fork Henning Schild
2021-08-27 10:25 ` [PATCH v2 3/3] wic: clean up wic class in terms of isar variables Henning Schild
2 siblings, 0 replies; 4+ messages in thread
From: Henning Schild @ 2021-08-27 10:25 UTC (permalink / raw)
To: isar-users; +Cc: Henning Schild
Note that this commit alone will not work. It is just to get back to a
starting point for clean history.
It takes the original file from our current OE version in this tree as
basis for later changes.
Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
.../wic/plugins/source/bootimg-pcbios-isar.py | 124 +++++++-----------
1 file changed, 47 insertions(+), 77 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 2dc90bd0cd30..f2639e700493 100644
--- a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
+++ b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
@@ -1,24 +1,10 @@
-# ex:ts=4:sw=4:sts=4:et
-# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
#
# Copyright (c) 2014, Intel Corporation.
-# All rights reserved.
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# SPDX-License-Identifier: GPL-2.0-only
#
# DESCRIPTION
-# This implements the 'bootimg-pcbios-isar' source plugin class for 'wic'
+# This implements the 'bootimg-pcbios' source plugin class for 'wic'
#
# AUTHORS
# Tom Zanussi <tom.zanussi (at] linux.intel.com>
@@ -26,36 +12,40 @@
import logging
import os
+import re
from wic import WicError
from wic.engine import get_custom_config
from wic.pluginbase import SourcePlugin
from wic.misc import (exec_cmd, exec_native_cmd,
- get_bitbake_var, BOOTDD_EXTRA_SPACE)
+ get_bitbake_var, BOOTDD_EXTRA_SPACE)
logger = logging.getLogger('wic')
-class BootimgPcbiosIsarPlugin(SourcePlugin):
+class BootimgPcbiosPlugin(SourcePlugin):
"""
Create MBR boot partition and install syslinux on it.
"""
- name = 'bootimg-pcbios-isar'
+ name = 'bootimg-pcbios'
@classmethod
- def _get_syslinux_dir(cls, bootimg_dir):
+ def _get_bootimg_dir(cls, bootimg_dir, dirname):
"""
- Get path to syslinux from either default bootimg_dir
- or wic-tools STAGING_DIR.
+ Check if dirname exists in default bootimg_dir or in STAGING_DIR.
"""
- for path in (bootimg_dir, get_bitbake_var("STAGING_DATADIR", "wic-tools")):
- if not path:
- continue
- syslinux_dir = os.path.join(path, 'syslinux')
- if os.path.exists(syslinux_dir):
- return syslinux_dir
+ staging_datadir = get_bitbake_var("STAGING_DATADIR")
+ for result in (bootimg_dir, staging_datadir):
+ if os.path.exists("%s/%s" % (result, dirname)):
+ return result
+
+ # STAGING_DATADIR is expanded with MLPREFIX if multilib is enabled
+ # but dependency syslinux is still populated to original STAGING_DATADIR
+ nonarch_datadir = re.sub('/[^/]*recipe-sysroot', '/recipe-sysroot', staging_datadir)
+ if os.path.exists(os.path.join(nonarch_datadir, dirname)):
+ return nonarch_datadir
- raise WicError("Couldn't find syslinux directory, exiting")
+ raise WicError("Couldn't find correct bootimg_dir, exiting")
@classmethod
def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir,
@@ -64,11 +54,12 @@ class BootimgPcbiosIsarPlugin(SourcePlugin):
Called after all partitions have been prepared and assembled into a
disk image. In this case, we install the MBR.
"""
- syslinux_dir = cls._get_syslinux_dir(bootimg_dir)
+ bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux')
+ mbrfile = "%s/syslinux/" % bootimg_dir
if creator.ptable_format == 'msdos':
- mbrfile = os.path.join(syslinux_dir, "mbr/mbr.bin")
+ mbrfile += "mbr.bin"
elif creator.ptable_format == 'gpt':
- mbrfile = os.path.join(syslinux_dir, "mbr/gptmbr.bin")
+ mbrfile += "gptmbr.bin"
else:
raise WicError("Unsupported partition table: %s" %
creator.ptable_format)
@@ -131,20 +122,11 @@ class BootimgPcbiosIsarPlugin(SourcePlugin):
syslinux_conf += "DEFAULT boot\n"
syslinux_conf += "LABEL boot\n"
- kernel_file = get_bitbake_var("KERNEL_FILE")
- rootfs_dir = get_bitbake_var("IMAGE_ROOTFS")
- kernel = os.path.basename(os.path.realpath(os.path.join(rootfs_dir, kernel_file)))
- kernel_parts = kernel.split("-")
- kernel_suffix = "-".join(kernel_parts[1:])
- initrd = "initrd.img"
-
- if kernel_suffix:
- initrd += "-%s" % kernel_suffix
-
+ kernel = "/vmlinuz"
syslinux_conf += "KERNEL " + kernel + "\n"
- syslinux_conf += "APPEND label=boot root=%s initrd=%s %s\n" % \
- (creator.rootdev, initrd, bootloader.append)
+ syslinux_conf += "APPEND label=boot root=%s %s\n" % \
+ (creator.rootdev, bootloader.append)
logger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg",
cr_workdir)
@@ -161,40 +143,28 @@ class BootimgPcbiosIsarPlugin(SourcePlugin):
'prepares' the partition to be incorporated into the image.
In this case, prepare content for legacy bios boot partition.
"""
- syslinux_dir = cls._get_syslinux_dir(bootimg_dir)
-
- kernel_file = get_bitbake_var("KERNEL_FILE")
- rootfs_dir = rootfs_dir['ROOTFS_DIR']
- kernel = os.path.basename(os.path.realpath(os.path.join(rootfs_dir, kernel_file)))
- kernel_parts = kernel.split("-")
- kernel_suffix = "-".join(kernel_parts[1:])
- initrd = "initrd.img"
- config = "config"
- mapfile = "System.map"
-
- if kernel_suffix:
- initrd += "-%s" % kernel_suffix
- config += "-%s" % kernel_suffix
- mapfile += "-%s" % kernel_suffix
+ bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux')
+
+ staging_kernel_dir = kernel_dir
hdddir = "%s/hdd/boot" % cr_workdir
- 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" %
- (syslinux_dir, hdddir),
- "install -m 444 %s/modules/bios/libcom32.c32 %s/libcom32.c32" %
- (syslinux_dir, hdddir),
- "install -m 444 %s/modules/bios/libutil.c32 %s/libutil.c32" %
- (syslinux_dir, hdddir))
+ kernel = get_bitbake_var("KERNEL_IMAGETYPE")
+ if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1":
+ if get_bitbake_var("INITRAMFS_IMAGE"):
+ kernel = "%s-%s.bin" % \
+ (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
+
+ cmds = ("install -m 0644 %s/%s %s/vmlinuz" %
+ (staging_kernel_dir, kernel, hdddir),
+ "install -m 444 %s/syslinux/ldlinux.sys %s/ldlinux.sys" %
+ (bootimg_dir, hdddir),
+ "install -m 0644 %s/syslinux/vesamenu.c32 %s/vesamenu.c32" %
+ (bootimg_dir, hdddir),
+ "install -m 444 %s/syslinux/libcom32.c32 %s/libcom32.c32" %
+ (bootimg_dir, hdddir),
+ "install -m 444 %s/syslinux/libutil.c32 %s/libutil.c32" %
+ (bootimg_dir, hdddir))
for install_cmd in cmds:
exec_cmd(install_cmd)
@@ -214,14 +184,14 @@ class BootimgPcbiosIsarPlugin(SourcePlugin):
extra_blocks, part.mountpoint, blocks)
# dosfs image, created by mkdosfs
- bootimg = "%s/boot.img" % cr_workdir
+ bootimg = "%s/boot%s.img" % (cr_workdir, part.lineno)
dosfs_cmd = "mkdosfs -n boot -i %s -S 512 -C %s %d" % \
(part.fsuuid, bootimg, blocks)
exec_native_cmd(dosfs_cmd, native_sysroot)
mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)
- exec_cmd(mcopy_cmd, native_sysroot)
+ exec_native_cmd(mcopy_cmd, native_sysroot)
syslinux_cmd = "syslinux %s" % bootimg
exec_native_cmd(syslinux_cmd, native_sysroot)
--
2.31.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] wic: apply the actual fork changes to our pcbios plugin fork
2021-08-27 10:25 [PATCH v2 0/3] re-fork wic pcbios plugin Henning Schild
2021-08-27 10:25 ` [PATCH v2 1/3] git: reset our fork to OE upstream for re-forking Henning Schild
@ 2021-08-27 10:25 ` Henning Schild
2021-08-27 10:25 ` [PATCH v2 3/3] wic: clean up wic class in terms of isar variables Henning Schild
2 siblings, 0 replies; 4+ messages in thread
From: Henning Schild @ 2021-08-27 10:25 UTC (permalink / raw)
To: isar-users; +Cc: Henning Schild
This aims to be a rather minimal one-commit fork to do isar specific
changes to the forked class. It does things in a way that results in
somehow strange code but pretty clean patching that aims to be easy to
read and mostly about adding lines to get things done. The hope is that
it will make maintaining the fork easier than before.
Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
.../wic/plugins/source/bootimg-pcbios-isar.py | 36 +++++++++++++++++--
1 file changed, 33 insertions(+), 3 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 f2639e700493..3a3a6f09392f 100644
--- a/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
+++ b/meta/scripts/lib/wic/plugins/source/bootimg-pcbios-isar.py
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# DESCRIPTION
-# This implements the 'bootimg-pcbios' source plugin class for 'wic'
+# This implements the 'bootimg-pcbios-isar' source plugin class for 'wic'
#
# AUTHORS
# Tom Zanussi <tom.zanussi (at] linux.intel.com>
@@ -22,12 +22,12 @@ from wic.misc import (exec_cmd, exec_native_cmd,
logger = logging.getLogger('wic')
-class BootimgPcbiosPlugin(SourcePlugin):
+class BootimgPcbiosIsarPlugin(SourcePlugin):
"""
Create MBR boot partition and install syslinux on it.
"""
- name = 'bootimg-pcbios'
+ name = 'bootimg-pcbios-isar'
@classmethod
def _get_bootimg_dir(cls, bootimg_dir, dirname):
@@ -56,6 +56,10 @@ class BootimgPcbiosPlugin(SourcePlugin):
"""
bootimg_dir = cls._get_bootimg_dir(bootimg_dir, 'syslinux')
mbrfile = "%s/syslinux/" % bootimg_dir
+
+ # files have different prefix in debian
+ mbrfile += "mbr/"
+
if creator.ptable_format == 'msdos':
mbrfile += "mbr.bin"
elif creator.ptable_format == 'gpt':
@@ -123,11 +127,27 @@ class BootimgPcbiosPlugin(SourcePlugin):
syslinux_conf += "LABEL boot\n"
kernel = "/vmlinuz"
+
+ # figure out the real filename in /boot/ by following debian symlinks
+ kernel_file = get_bitbake_var("KERNEL_FILE")
+ rootfs_dir = get_bitbake_var("IMAGE_ROOTFS")
+ kernel = os.path.basename(os.path.realpath(os.path.join(rootfs_dir, kernel_file)))
+
syslinux_conf += "KERNEL " + kernel + "\n"
syslinux_conf += "APPEND label=boot root=%s %s\n" % \
(creator.rootdev, bootloader.append)
+ # we are using an initrd, smuggle it in
+ initrd = "initrd.img"
+ kernel_parts = kernel.split("-")
+ kernel_suffix = "-".join(kernel_parts[1:])
+ if kernel_suffix:
+ initrd += "-%s" % kernel_suffix
+
+ syslinux_conf = syslinux_conf.replace(" root=%s " % (creator.rootdev),
+ " root=%s initrd=%s " % (creator.rootdev, initrd))
+
logger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg",
cr_workdir)
cfg = open("%s/hdd/boot/syslinux.cfg" % cr_workdir, "w")
@@ -166,7 +186,17 @@ class BootimgPcbiosPlugin(SourcePlugin):
"install -m 444 %s/syslinux/libutil.c32 %s/libutil.c32" %
(bootimg_dir, hdddir))
+ # install /boot from our debian rootfs completely
+ cmds = cmds + ("cp -a %s/%s %s/.." % (rootfs_dir['ROOTFS_DIR'], "boot", hdddir),)
+
for install_cmd in cmds:
+ # skip the kernel install from OE parts, "cp -a" will bring our kernel
+ if install_cmd == cmds[0]:
+ continue
+ # one file has a different suffix in debian
+ install_cmd = install_cmd.replace("ldlinux.sys", "ldlinux.c32")
+ # files have different prefix in debian
+ install_cmd = install_cmd.replace("/syslinux/", "/syslinux/modules/bios/")
exec_cmd(install_cmd)
du_cmd = "du -bks %s" % hdddir
--
2.31.1
^ permalink raw reply [flat|nested] 4+ messages in thread