Commit Graph

306 Commits

Author SHA1 Message Date
Marcus Schäfer
2e409ec189
Fix zipl setup for use with custom btrfs root vol
In the setup case that btrfs is used for the system and
the root partition is on a custom named volume (not /),
this information was not passed to the zipl bootloader
instance and this caused the mounting of the overall
root system to fail. This commit fixes it
2024-03-22 16:35:10 +01:00
Marcus Schäfer
4752a53554
Fixup cleanup of zipl templates
Make sure temporary modifications to the zipl template
and config file are not effective in the later system.
This Fixes bsc#1221469
2024-03-18 16:34:54 +01:00
Marcus Schäfer
3ac0ff72b8
Followup fix for use of /boot/zipl
The mounting of /boot/zipl is also only required if the
bootloader is set to grub2_s390x_emu
2024-03-13 09:33:30 +01:00
Marcus Schäfer
ae497f2504
Lookup distro provided BLS entries for zipl
Check if there is already an entry file name produced by the
distribution logic/policy. If we can find an already present
entry name, prefer this name over the kiwi naming policy
2024-03-12 15:37:16 +01:00
Marcus Schäfer
583f3385df
Add support for BLS zipl
Add support for <bootloader name="zipl" .../> to support BLS
based zipl configuration. This Fixes #2481
2024-03-10 11:28:21 +01:00
Marcus Schäfer
b072cfdc7c
Set default output console to gfxterm for grub
If no console setting is done in the image description for grub
the default output console is set to: gfxterm and the default
input console is set to: console. This Fixes bsc#1219074
2024-02-28 10:42:17 +01:00
Marcus Schäfer
8c6ac25804
Fixed use of custom bootloader
In case no bootloader implementation by kiwi should be
used, users can specify the bootloader="custom" attribute.
Instead of skipping the bootloader stage in the builders
it is better to consistently create an instance of bootloader
but raise if a method of the bootloader interface is called
for which the custom bootloader has no implementation. This
commit adds the consistency bits.
2024-02-12 13:04:29 +01:00
Marcus Schäfer
8aa517eb77
Remove destructor from BootLoaderInstallGrub2
With MountManager as context manager the BootLoaderInstallGrub2
class doesn't need a destructor anymore. This is related
to Issue #2412
2024-02-06 10:28:18 +01:00
Marcus Schäfer
c5b3c83920
Use ExitStack for MountManagers 2024-01-31 15:04:10 +01:00
Marcus Schäfer
09e4758609
Move Disk to context manager
Change the Disk class to be a context manager.
All code using Disk was updated to the following
with statement:

    with Disk(...) as disk:
        disk.some_member()

This is related to Issue #2412
2024-01-31 15:04:10 +01:00
Marcus Schäfer
82d9a6cdcf
Allow to use Literal for all python versions 2024-01-30 17:36:28 +01:00
Dan Čermák
410e6d9e21
Correct type hint of mbrid parameter 2024-01-29 14:08:10 +01:00
Dan Čermák
34934b2f8f
Convert BootLoaderConfigBase into an abstract base class 2024-01-29 14:07:41 +01:00
Dan Čermák
f906704ea5
Convert BootLoaderConfig to free function
The class serves really no purpose except for creating another
namespace. This function now allows us to have more stricter type checking.
2024-01-29 13:56:51 +01:00
Marcus Schäfer
54f92d2a9f
Drop support for syslinux/isolinux
SYSLINUX has been abandoned for several years now, and it does not
even work with modern versions of the filesystems supported in kiwi.
This commit drops it and Fixes #2433
2024-01-26 21:25:37 +01:00
Marcus Schäfer
d209a57910
Move BootLoaderConfig to context manager
Change the BootLoaderConfig class to be a context manager.
All code using BootLoaderConfig was updated to the following
with statement:

    with BootLoaderConfig.new(...) as bootloader_config:
        bootloader_config.some_member()

This is related to Issue #2412
2024-01-23 15:11:21 +01:00
Dan Čermák
af3e9aa924
Correct invalid escape sequence
\/ is not a valid escape sequence, it just needs to be forwarded to the shell
2024-01-19 13:10:32 +01:00
Marcus Schäfer
a1783ffd83
Refactor disk builder for use with context manager
In preparation to further context manager related changes
in VolumeManager, LuksDevice, RaidDevice and more the
disk builder code which uses these classes needs to be
refactored beforehand to allow switching to context
manager based cascading of the storage device classes.
This commit does the refactoring and is related to
Issue #2412
2024-01-18 15:46:08 +01:00
Marcus Schäfer
d9e9a3820b
Follow up fix for drop of hybrid boot snippets
The following is left over code from the drop of the hybrid
boot templates.
2024-01-16 15:50:45 +01:00
Neal Gompa (ニール・ゴンパ)
5ee55aeaf3
Merge pull request #2424 from OSInside/drop-grub2-linuxefi
Drop hybrid boot snippets from the GRUB 2 configuration template
2024-01-16 08:03:30 -05:00
Neal Gompa
a638884192 Drop hybrid boot snippets from the GRUB 2 configuration template
Sometime between GRUB 2.04 and GRUB 2.06, it became no longer
necessary to use "linuxefi"+"initrdefi" for UEFI boot. The
standard "linux"+"initrd" stanzas work for both legacy BIOS boot
and modern UEFI boot.

Some distributions no longer support "linuxefi"+"initrdefi" at all
anymore, so let's just use "linux"+"initrd" for everything now.
2024-01-16 04:37:16 -05:00
Marcus Schäfer
8551ebca7a
Don't create default entry for sd-boot loader.conf 2024-01-15 17:57:51 +01:00
Marcus Schäfer
bddf25559d
Compat entry name for kernel-install in sd-boot
systemd-boot tools like kernel-install expect a certain
entry naming policy. This commit adapts kiwi to adapt to
this policy. The name for the default entry is constructed
out of the ID information from /etc/os-release followed
by the name of the kernel as it is represented by the
directory name in /lib/modules/... This Fixes #2417
2024-01-13 23:25:41 +01:00
Marcus Schäfer
cdbe5060ca
Move LoopDevice class to context manager
Change the LoopDevice class to be a context manager.
All code using LoopDevice was updated to the following
with statement:

with LoopDevice(...) as loop_provider:
    loop_provider.some_member()

This is related to Issue #2412
2024-01-11 19:18:01 +01:00
Marcus Schäfer
9ac01da5de
Fixed regression in GRUB_SERIAL_COMMAND setup
The condition to write the serial line setup was broken.
This commit fixes it. Related to Issue #2419
2024-01-09 11:18:30 +01:00
Marcus Schäfer
c6d8235fa6
Fixed grub terminal setup
The grub terminal setup is divided into the setting for the output
and the input console. For both settings different parameters exists.
So far kiwi did not differentiate between the two parts of the
console setup and that could lead to a wrong setting if only one
value is provided in kiwi's console= attribute which lead to the
grub setting, GRUB_TERMINAL=value. If value is set to e.g gfxterm
grub takes this for both input and output and it's obviously
wrong for the input. To make this less error prune the kiwi code
changes with this commit to set GRUB_TERMINAL_INPUT and
GRUB_TERMINAL_OUTPUT rather than GRUB_TERMINAL and also runs sanity
checks on the provided values if they are applicable. The information
for setting up the console in the schema stays untouched though.
That's because it's used for all bootloaders and also because grub
supports multiple values for the console in/out setting in one
GRUB_TERMINAL variable even though kiwi does no longer use it.
To make this clear for the users also the documentation for the
console attribute setup has been updated. If we want to wish two
distinct attributes for input and output console settings a schema
change and also differentiation between bootloaders is needed and
that I only see for the kiwi-10 branch if at all. This Fixes #2419
2024-01-08 18:02:27 +01:00
Marcus Schäfer
1976546cc4
Merge pull request #2392 from OSInside/fix_niche_case_mbrid_setup
Fix mbrid setup for read-only systems
2023-11-11 13:02:32 +01:00
Kali
24fe960c98
Replace the regex-based loader entry fix with string parsing (#2388)
A user building RHEL images ran into issues with the initrd. 
It turns out that RHEL uses some patches that mean the
initrd/linux files in RHEL are not installed to /boot, which trips
up the original regex. The new fix doesn't rely on matching the
path in boot, instead just finding the initrd/linux files and rewriting
them in place.

This change also adds the pre-and-post fix loader entries to the debug logs.

Reference: https://bugzilla.suse.com/1208701

Fixes suse bsc#1208701
2023-11-10 07:08:26 -05:00
Marcus Schäfer
7f64e7aadb
Fix mbrid setup for read-only systems
On filesystems without a UUID (e.g squashfs) the fallback boot id
setup should apply if neither UUID nor MBR ID is present. This
is a followup fix for Issue #2391
2023-11-10 13:05:48 +01:00
Neal Gompa (ニール・ゴンパ)
909667290b
Merge pull request #2390 from OSInside/systemd_iso_support
Add support for ISO boot via systemd-boot
2023-11-08 10:24:48 -05:00
Marcus Schäfer
194414c5a9
Fixed grub mbrid file search
To identify the root device for ISO images (live and install media)
that boots via grub2, kiwi uses a grub2 --file search. The searched
file was named /boot/mbrid, however this is not a unique name and
could be found on other devices of the system as well. To connect
the search to the correct media this commit changes the search to
an ID based method which is unique to the image build process.
This Fixes #2389
2023-11-08 15:25:29 +01:00
Marcus Schäfer
872678ea14
Don't use kernel-install
kernel-install does a lot more then making the kernel available
to the ESP. It calls dracut, it creates loader entries and all
that is unexpected and also breaks the boot because the way
dracut is called in the image build case where host != target
leads to broken results. This commit refactors the systemd-boot
support in kiwi to prevent the use of kernel-install
2023-11-08 12:47:32 +01:00
Marcus Schäfer
d47ce6e70b
Add check_efi_fat_image_has_correct_size
Add runtime check for to check that the efifatimagesize
does not exceed the max El Torito load size
2023-11-08 09:22:16 +01:00
Marcus Schäfer
d6d57ea95b
Add support for ISO boot via systemd-boot
Create proper EFI FAT image via bootctl to be used as
alt loader in xorriso. This allows to boot the ISO
via EFI e.g kvm -bios /usr/share/qemu/ovmf-x86_64.bin -cdrom file.iso
Please note, hybrid boot is done via grub's hybrid MBR and
as systemd-boot does not provide one, hybrid boot is out
of scope yet. This Fixes #2281
2023-11-07 17:41:51 +01:00
Marcus Schäfer
f268a4037b
Added unit test for testing grub prefix
Cover the condition if an extra boot partition is used
2023-09-22 10:39:44 +02:00
Leif Liddy
41771104e2
use / prefix when boot partition is used 2023-09-22 10:38:47 +02:00
Leif Liddy
4f04832e40
use os.path.join to create path
os.path.join to create the path for the early_boot.write functions
this will prevent paths from containing double slashes //
2023-09-06 15:19:32 +02:00
Leif Liddy
b0195b7fda
allow value of GRUB_TERMINAL to be empty
allow value of GRUB_TERMINAL to be empty. When setting grub_console="none"
this now leads to an empty setting of GRUB_TERMINAL in the /etc/default/grub
system configuration file. This Fixes #2261
2023-08-25 09:14:20 +02:00
Marcus Schäfer
1e4687f84d
Fix double grub entries in hybrid ISO images
As consequence of using the "source" grub command instead
of the "configfile" command to load the grub config we now
see double loading of the same file on ISO media. The reason
here is that kiwi ISO media is always hybrid which means it
embeds an MBR into the ISO for which the "source" command now
can read the same file through two different device paths.
This does not happen with the "configfile" grub command.
Thus this patch uses "configfile" if we produce an ISO image
and "source" for all other image types. The commit also fixes
the custom grub template used for ISO images in a way that
we only set the "serial" command if there is a serial
configuration provided along with the image description.
2023-08-09 16:07:34 +02:00
Marcus Schäfer
63735fef21
Limit scope of grub _fix method
Only apply _fix_grub_to_support_dynamic_efi_and_bios_boot for
the x86_64 or ix86 architectures. This Fixes #2343
2023-08-03 11:31:04 +02:00
Neal Gompa
60d7b1f718
Merge pull request #2324 from OSInside/btrfs_no_hardcoded_toplevel_volume
Evaluate the @root volume name also for btrfs
2023-07-31 11:27:00 -04:00
slowpeek
97ac758de8 Use 'source' instead of 'configfile' in generated grub.cfg
Details are outlined in issue #2320
2023-07-27 18:09:36 +03:00
Marcus Schäfer
dd110f63a4
Make sure btrfs root volume is used when needed
With the possibility to switch off setting the default volume
an issue at other parts in the kiwi code which mounted the
btrfs based system were uncovered. Without any default volume
set it's required to transport the root volume if different
from / and pass the respective subvol= option to the mount.
This commit fixes it at the places where kiwi trusted btrfs
to have a correct default volume set
2023-07-27 16:18:48 +02:00
Marcus Schäfer
f97b47e8fb
Fix fallback secure boot setup
Don't copy the same file. This case happens when rebuilding
an image using --allow-existing-root when the fallback setup
has done its job already in the first run
2023-07-26 09:21:09 +02:00
Marcus Schäfer
f223e61344
Cleanup condition for SECURE_BOOT=yes|no
The statement serves the purpose for an if/else construction
to become a better read. In addition delete the probably
left-over print statement from the test
2023-07-24 16:02:23 +02:00
Jesus Bermudez Velazquez
cfb4c8edea
Add SECURE_BOOT no when the firmware is efi
This Fixes bsc#1211102
2023-07-18 17:29:11 +01:00
Marcus Schäfer
7ac14458af Refactor the luks_device class data transport
Also add missing unit tests
2023-07-05 12:30:38 +02:00
Olaf Kirch
95c8edfa99 Add improvements for fully encrypted disk images
This commit adds more flexibility when using LUKS
encrypted images. In addition support for key derivation
on user provided passwords has been added. The following
new attributes were added to the schema:

type.luks_randomize
  allow to enable/disable the data randomizing if luks
  encryption is used

type.luks_pbkdf
  When LUKS unlocks a key slot using a user provided
  password, it uses a so-called key derivation function
  to derive a symmetric encryption key from the password.
  Not all boot loaders support all KDF algorithms, hence
  this attribute can be used to select a specific algorithm

bootloader.use_disk_password
  When /boot is encrypted, make the boot loader store the
  password in its configuration file (in cleartext). This
  is useful for full disk encryption images

Signed-off-by: Olaf Kirch <okir@suse.com>
2023-07-05 12:29:51 +02:00
Neal Gompa
6db103f3e6
Merge pull request #2283 from OSInside/fix_fedora_iso_efi_boot
Fixed Fedora prebuild EFI binary lookup
2023-06-14 04:38:04 -04:00
Marcus Schäfer
7630def003
Add more details about used grub image(s) 2023-06-14 09:55:29 +02:00