From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7003689951757860864 X-Received: by 2002:a05:651c:17a5:: with SMTP id bn37mr563997ljb.514.1630673640127; Fri, 03 Sep 2021 05:54:00 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:651c:503:: with SMTP id o3ls1176448ljp.0.gmail; Fri, 03 Sep 2021 05:53:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2vrM/X7IH0dUf4wX8Nu1Lbzlz0vv5Ycr6jYYUS68iF54ba0q4dytzffxnEQnSHF6/5ip1 X-Received: by 2002:a05:651c:113b:: with SMTP id e27mr2927562ljo.6.1630673639093; Fri, 03 Sep 2021 05:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630673639; cv=none; d=google.com; s=arc-20160816; b=GmRzF0a0Z7dPIzRgZAWG85B05hSNRl4hXPpg/5gcdgZOh8wQPQq1PiYnqxllvqWedW Hlh4yx8KKTYgoce713HAPWN28E+VnkCuoR0oN6pGYdrrRHM2cFpvgtn9tvGj+UuGsV+u 75NHhqDqwWS26SCqYHb1HWBjJvUSQc9awh9PfRTWqKNOlRlqYeZp3tHQw9BkxFmerh2L TA/F9SldRtJ3vCVc7LWQVQk8ZtxFf7NZUwmWNw8wwTzRH33M5gmQfo+nWy0PR2RTDbeb /y+NsL8jVu69hTDZeLOdrLr0ZJ+L2rY/TYiVbUkZK/xcvhfkMyfnKuIsJV7SGham48uY h72A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=umOxQzdXvEE5xexvITdL1i8uDKQ6kFNmX+EoRHeCT1U=; b=U4yxVLTrSdWdCaClmlQ4mgCZCtJgcB32TITqNnDI09umLqWKOO9ZSdO5L4grPyt09O pGJe9O5SC33O3Ajel2S5kN09MOzsiPiX6OdEFK1VBbfsAZ7OchPzD1ZEmeLrlX0dp/MM v+bX1z21SxBp8AglVuO8bbJkM+njcAJsET2f/6p9ah1e5Fdon0Mu4V/YimyZIkPEJ6xS 9cOqoLKathyV59fWuKmjZsmsD2tdYaaNcfTkabZML77k46H0DlfyUGOnJFL0XZyuKXDR ChQdclWHBoYZCswC/NYoataHqjNGF6Y3XHc5Gd1dLdN7tE22tJsBG2PBh2D2R2FW01Xq bCLQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=henning.schild@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from lizzard.sbs.de (lizzard.sbs.de. [194.138.37.39]) by gmr-mx.google.com with ESMTPS id h11si235342lfc.4.2021.09.03.05.53.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Sep 2021 05:53:59 -0700 (PDT) Received-SPF: pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) client-ip=194.138.37.39; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=henning.schild@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id 183Crw8n013619 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Sep 2021 14:53:58 +0200 Received: from md1za8fc.ad001.siemens.net ([139.25.0.59]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id 183CrvB3029234; Fri, 3 Sep 2021 14:53:58 +0200 From: Henning Schild To: isar-users@googlegroups.com Cc: Florian Bezdeka , Vijai Kumar K , jan.kiszka@siemens.com, Henning Schild 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 Message-Id: <20210903125355.12279-6-henning.schild@siemens.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210903125355.12279-1-henning.schild@siemens.com> References: <20210903125355.12279-1-henning.schild@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: 9Lm46XACBH7p 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 --- 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 @@ -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