From: Henning Schild <henning.schild@siemens.com>
To: isar-users@googlegroups.com
Cc: Florian Bezdeka <florian.bezdeka@siemens.com>,
Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>,
jan.kiszka@siemens.com,
Henning Schild <henning.schild@siemens.com>
Subject: [PATCH v2 5/7] wic: apply the actual fork changes to our efi plugin fork
Date: Fri, 3 Sep 2021 14:53:53 +0200 [thread overview]
Message-ID: <20210903125355.12279-6-henning.schild@siemens.com> (raw)
In-Reply-To: <20210903125355.12279-1-henning.schild@siemens.com>
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.
Note that it changes the way we deal with grub, we now do it like OE and
consistent with systemd-boot and syslinux. Meaning we have the
bootloader, its config and kernel+initrd in the /boot partition.
While that breaks kernel updates with "apt-get" it gets things
consistent and less hacky. Such kernel updates anyways only worked with
grub-efi and should rather be solved differently covering all possible
bootloaders.
Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
RECIPE-API-CHANGELOG.md | 9 +++
.../wic/plugins/source/bootimg-efi-isar.py | 62 +++++++++++++++++--
2 files changed, 65 insertions(+), 6 deletions(-)
diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md
index 806c2914f13f..7312d4d4baa9 100644
--- a/RECIPE-API-CHANGELOG.md
+++ b/RECIPE-API-CHANGELOG.md
@@ -292,3 +292,12 @@ Migrate your patches so they can be applied with "git am", or
Kernel image name for arm64 platforms is vmlinux now. Image format was
not changed (uncompressed executable) but now it is named correctly.
+
+### wic plugins for efi and pcbios use seperate /boot partition
+
+It used to depend on the bootloader whether stuff was in in the root partition or in the boot partition, now it will always be in the boot partition.
+
+Kernel update with "apt-get" will not work since bootloader configuration will
+not be updated. It used to "kind of work" for grub and efi, that hack is gone.
+
+When using the plugins it is advised to name the partition "/boot" and to exclude boot from the follwing rootfs to not waste space.
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 cdc72543c200..d97125481155 100644
--- a/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
+++ b/meta/scripts/lib/wic/plugins/source/bootimg-efi-isar.py
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# DESCRIPTION
-# This implements the 'bootimg-efi' source plugin class for 'wic'
+# This implements the 'bootimg-efi-isar' source plugin class for 'wic'
#
# AUTHORS
# Tom Zanussi <tom.zanussi (at] linux.intel.com>
@@ -23,6 +23,10 @@ from wic.pluginbase import SourcePlugin
from wic.misc import (exec_cmd, exec_native_cmd,
get_bitbake_var, BOOTDD_EXTRA_SPACE)
+import sys
+sys.path[0] = os.path.dirname(os.path.abspath(__file__)) + "/.."
+from isarpluginbase import (isar_get_filenames, isar_populate_boot_cmd)
+
logger = logging.getLogger('wic')
class BootimgEFIPlugin(SourcePlugin):
@@ -31,7 +35,7 @@ class BootimgEFIPlugin(SourcePlugin):
This plugin supports GRUB 2 and systemd-boot bootloaders.
"""
- name = 'bootimg-efi'
+ name = 'bootimg-efi-isar'
@classmethod
def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params):
@@ -72,6 +76,9 @@ class BootimgEFIPlugin(SourcePlugin):
grubefi_conf = ""
grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n"
+ grubefi_conf += "terminal_input --append serial\n"
+ grubefi_conf += "terminal_output --append serial\n"
+ grubefi_conf += "\n"
grubefi_conf += "default=boot\n"
grubefi_conf += "timeout=%s\n" % bootloader.timeout
grubefi_conf += "menuentry '%s'{\n" % (title if title else "boot")
@@ -87,6 +94,7 @@ class BootimgEFIPlugin(SourcePlugin):
if label:
label_conf = "LABEL=%s" % label
+ kernel, initrd = isar_get_filenames(get_bitbake_var("IMAGE_ROOTFS"))
grubefi_conf += "linux /%s %s rootwait %s\n" \
% (kernel, label_conf, bootloader.append)
@@ -166,6 +174,8 @@ class BootimgEFIPlugin(SourcePlugin):
title = source_params.get('title')
+ kernel, initrd = isar_get_filenames(get_bitbake_var("IMAGE_ROOTFS"))
+
boot_conf = ""
boot_conf += "title %s\n" % (title if title else "boot")
boot_conf += "linux /%s\n" % kernel
@@ -208,9 +218,9 @@ class BootimgEFIPlugin(SourcePlugin):
elif source_params['loader'] == 'systemd-boot':
cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params)
else:
- raise WicError("unrecognized bootimg-efi loader: %s" % source_params['loader'])
+ raise WicError("unrecognized bootimg-efi-isar loader: %s" % source_params['loader'])
except KeyError:
- raise WicError("bootimg-efi requires a loader, none specified")
+ raise WicError("bootimg-efi-isar requires a loader, none specified")
if get_bitbake_var("IMAGE_EFI_BOOT_FILES") is None:
logger.debug('No boot files defined in IMAGE_EFI_BOOT_FILES')
@@ -290,6 +300,8 @@ class BootimgEFIPlugin(SourcePlugin):
install_cmd = "install -m 0644 %s/%s %s/%s" % \
(staging_kernel_dir, kernel, hdddir, kernel)
+
+ install_cmd = isar_populate_boot_cmd(rootfs_dir['ROOTFS_DIR'], hdddir)
exec_cmd(install_cmd)
if get_bitbake_var("IMAGE_EFI_BOOT_FILES"):
@@ -308,15 +320,53 @@ class BootimgEFIPlugin(SourcePlugin):
exec_cmd(cp_cmd, True)
shutil.move("%s/grub.cfg" % cr_workdir,
"%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir)
+
+ distro_arch = get_bitbake_var("DISTRO_ARCH")
+ if not distro_arch:
+ raise WicError("Couldn't find target architecture")
+
+ if distro_arch == "amd64":
+ grub_target = 'x86_64-efi'
+ grub_image = "bootx64.efi"
+ grub_modules = "multiboot efi_uga iorw ata "
+ elif distro_arch == "i386":
+ grub_target = 'i386-efi'
+ grub_image = "bootia32.efi"
+ grub_modules = "multiboot efi_uga iorw ata "
+ elif distro_arch == "arm64":
+ grub_target = 'arm64-efi'
+ grub_image = "bootaa64.efi"
+ grub_modules = ""
+ else:
+ raise WicError("grub-efi is incompatible with target %s" %
+ distro_arch)
+
+ bootimg_dir = "%s/hdd/boot" % cr_workdir
+ if not os.path.isfile("%s/EFI/BOOT/%s" \
+ % (bootimg_dir, grub_image)):
+
+ # TODO: check that grub-mkimage is available
+ grub_cmd = "grub-mkimage -p /EFI/BOOT "
+ grub_cmd += "-O %s -o %s/EFI/BOOT/%s " \
+ % (grub_target, bootimg_dir, grub_image)
+ grub_cmd += "part_gpt part_msdos ntfs ntfscomp fat ext2 "
+ grub_cmd += "normal chain boot configfile linux "
+ grub_cmd += "search efi_gop font gfxterm gfxmenu "
+ grub_cmd += "terminal minicmd test loadenv echo help "
+ grub_cmd += "reboot serial terminfo iso9660 loopback tar "
+ grub_cmd += "memdisk ls search_fs_uuid udf btrfs xfs lvm "
+ grub_cmd += "reiserfs regexp " + grub_modules
+ exec_cmd(grub_cmd)
elif source_params['loader'] == 'systemd-boot':
+ kernel_dir = os.path.join(rootfs_dir['ROOTFS_DIR'], "usr/lib/systemd/boot/efi/")
for mod in [x for x in os.listdir(kernel_dir) if x.startswith("systemd-")]:
cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, mod[8:])
exec_cmd(cp_cmd, True)
else:
- raise WicError("unrecognized bootimg-efi loader: %s" %
+ raise WicError("unrecognized bootimg-efi-isar loader: %s" %
source_params['loader'])
except KeyError:
- raise WicError("bootimg-efi requires a loader, none specified")
+ raise WicError("bootimg-efi-isar requires a loader, none specified")
startup = os.path.join(kernel_dir, "startup.nsh")
if os.path.exists(startup):
--
2.32.0
next prev parent reply other threads:[~2021-09-03 12:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-03 12:53 [PATCH v2 0/7] re-fork wic pcbios and efi plugins Henning Schild
2021-09-03 12:53 ` [PATCH v2 1/7] wic: reset our plugin forks to OE upstream for re-forking Henning Schild
2021-09-03 12:53 ` [PATCH v2 2/7] wic: add utility library for common bits of isar plugins Henning Schild
2021-09-03 12:53 ` [PATCH v2 3/7] wic: apply the actual fork changes to our pcbios plugin fork Henning Schild
2021-09-03 12:53 ` [PATCH v2 4/7] wic: clean up wic class in terms of isar variables Henning Schild
2021-09-03 12:53 ` Henning Schild [this message]
2021-09-03 12:53 ` [PATCH v2 6/7] wic: mount /boot and exlude it from root for efi Henning Schild
2021-09-03 16:06 ` Henning Schild
2021-09-03 12:53 ` [PATCH v2 7/7] meta-isar: use "systemd-boot" for one test target Henning Schild
2021-09-06 5:05 ` [PATCH v2 0/7] re-fork wic pcbios and efi plugins Jan Kiszka
2021-09-06 8:59 ` Henning Schild
2021-09-06 9:48 ` Anton Mikanovich
2021-09-06 10:51 ` Henning Schild
2021-09-07 7:15 ` Bezdeka, Florian
2021-09-07 8:00 ` Henning Schild
2021-09-13 13:05 ` Anton Mikanovich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210903125355.12279-6-henning.schild@siemens.com \
--to=henning.schild@siemens.com \
--cc=Vijaikumar_Kanagarajan@mentor.com \
--cc=florian.bezdeka@siemens.com \
--cc=isar-users@googlegroups.com \
--cc=jan.kiszka@siemens.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox