OSInside / kiwi

KIWI - Appliance Builder Next Generation
https://osinside.github.io/kiwi
GNU General Public License v3.0
302 stars 152 forks source link

Do not unconditionally copy theme data to boot directory #2624

Open aplanas opened 2 months ago

aplanas commented 2 months ago

Problem description

The new grub2bls subpackage does already provides an EFI file (grub2bls.efi) that contains in the internal squashfs internal image all the required resources: configuration file, fonts, graphical assets, etc. During the installation this file needs to be copied into the ESP and renamed to grub.efi.

KIWI does expect that the theme packages are also installed, and in the bootloader/config/grub2.py there are unconditional calls to _copy_theme_data_to_boot_directory, making the image fail with:

[   94s] [ INFO    ]: 09:35:44 | Cleaning up Disk instance
[   94s] [ DEBUG   ]: 09:35:44 | EXEC: [partx --delete /dev/loop0]
[   94s] [ DEBUG   ]: 09:35:44 | EXEC: [losetup -d /dev/loop0]
[   94s] [ ERROR   ]: 09:35:44 | KiwiBootLoaderGrubFontError: Setting up unicode font failed with grub path unicode.pf2 not found in ['/usr/src/packages/KIWI-oem/build/image-root/usr/share/grub2/unicode.pf2', '/usr/src/packages/KIWI-oem/build/image-root/usr/lib/grub2/unicode.pf2', '/usr/src/packages/KIWI-oem/build/image-root/usr/share/grub/unicode.pf2', '/usr/src/packages/KIWI-oem/build/image-root/usr/lib/grub/unicode.pf2']
[   94s] Powering off.

Steps to reproduce the behaviour

Create an image with the grub2-x86-efi-bls package, but does not include grub2 or the patterns-base-bootloader

    <packages type="image" profiles="kvm-and-xen-grub-bls">
        <!-- <package name="patterns-base-bootloader"/> -->
        <package name="grub2-x86_64-efi-bls" arch="x86_64"/>
        <package name="grub2-arm-efi-bls" arch="aarch64"/>
    </packages>
aplanas commented 2 months ago

Some approaches:

aplanas commented 2 months ago

as mkconfig and install are also missing, this will requires more changes

schaefi commented 2 months ago

The original idea with _copy_theme_data_to_boot_directory() was as follows

@aplanas The presence of a font so far was always a strict requirement for grub not only for showing a theme but for showing any type of character. So you are saying this requirement has changed ? if it has changed and no font file is required for grub anymore then I'm ok with changing this into a warning

aplanas commented 2 months ago

So you are saying this requirement has changed ?

For the new grub2bls subpackage yes. For the general case no.

As commented in the original post all the elements (configuration files, fonts, modules like bli.mod, and graphic resources) are now deployed inside the EFI file (the squashfs image embedded inside the EFI file)

Changing the the exception into a warning seems a very sensible option. The problem that I found is that also the rest of the tools (grub2-mkconfig, grub2-install, etc) are also optional: the configuration file are inside the EFI and the external one is ignored if present, and the installation is just a copy-and-rename operation from rootfs to the ESP. No other bit (like i386-pc) is not present in the rootfs nor required in the ESP. Basically the grub2bls subpackage just contain a single EFI file and no dependencies.