Commit Graph

77 Commits

Author SHA1 Message Date
Marcus Schäfer
39898171b0
Be less strict in boot link to itself
As part of the grub setup a link named 'boot' inside of
/boot is created pointing to itself 'boot -> .'. The reason
is to allow the bootloader config to find its files referenced as
/boot/something independently if /boot is placed into an extra
partition. However if an extra boot partition is used and a
filesystem which does not support symlinks, e.g fat, that
symlink creation should not lead to an error in the image build
process as it is considered an optional safe link and not a
mandatory pre-requisite
2022-04-10 15:25:37 +02:00
Marcus Schäfer
81cae1bae4
Fix test_setup_default_grub_empty_kernelcmdline
The unit test exists to check that GRUB_CMDLINE_LINUX_DEFAULT
is not set depending on the provided cmdline. The test exists
for reasons explained in Issue #1650
2022-04-06 08:46:21 +02:00
Robert Schweikert
deec054cae
Preserve LABEL setting (#2108)
Preserve the LABEL= setting when the grub config file is re-generated.
the GRUB_ENABLE_LINUX_LABEL setting does not exists upstream and
not in any SUSE distribution. Set the grub setting such that LABEL
is preserved on SUSE distros. (bsc#1197616)
2022-04-05 17:22:31 +02:00
Marcus Schäfer
7e3d031b07
Fix grub defaults for PARTUUID use
Make sure to set GRUB_DISABLE_LINUX_PARTUUID to false
when using by-partuuid
2022-03-23 09:47:23 +01:00
Marcus Schäfer
8902f1ccb2
Support mount by PARTUUID
In addition to by-label and by-uuid also support mounting
by PARTUUID. Please note kiwi also makes sure that the grub
generated config file uses the root=PARTUUID= notation and it's
not clear if grub-mkconfig will persist making use of it.
Nevertheless there are also systems which uses different
methods to boot and it makes sense to support partuuid
mappings as well
2022-03-23 09:47:22 +01:00
Marcus Schäfer
9c9250ebc4
Support nose and xunit style tests
The modifications in this commit allows the unit tests
to run on both, pytest 6.x (nose test layout) and the new
pytest 7.x (xunit test layout). This Fixes #2072 in a
much nicer way. Thanks much to @smarlowucf
2022-02-26 20:26:18 +01:00
Marcus Schäfer
1f869e7ca8
Revert "Unit test adaptions to pytest v7"
This reverts commit 0dc2e803e0.
The pytest interface from version v6 to v7 has received
changes which requires the tests to be adapted to work for
either the old or the new interface. As there are still many
distributions which uses v6 as the standard we decided to
revert back the adaptions done to support v7 and create
a version requirement to v6 in .virtualenv.dev-requirements.txt
This Fixes #2072
2022-02-26 20:19:42 +01:00
Marcus Schäfer
0dc2e803e0
Fixed unit tests
The pytest interface setup() method call has changed
in a way that an additional parameter is passed to
the method which leads to a python error at invocation
time if the setup method does not define it.
2022-02-07 21:27:39 +01:00
Fabian Vogt
daad876b6b Don't include the ESP in the ISO9660 partition as well (#1750)
Previously the image for the ESP was created inside the source directory
for the ISO9660 filesystem, so it ended up there as well as a separate
partition. Fix that by creating it as a temporary file instead.
2022-01-24 15:58:17 +01:00
Marcus Schäfer
97e4455028
Fixed grub loader/entries setup
If called in non standard environments like an OBS worker
the grub tooling does not work correctly and produces invalid
results. For these cases kiwi provides a collection of fix_
methods to change the produced results. This commit covers
the invalid path in loader/entries/*.conf files pointing to
the kernel and the initrd as they exist in the image-root
directory. This results for example in settings like:

    linux /usr/src/packages/KIWI-oem/build/image-root/boot/vmlinuz-5.14.0-43.el9.x86_64

when it should be:

    linux /boot/vmlinuz-5.14.0-43.el9.x86_64

This Fixes #2038
2022-01-21 16:19:40 +01:00
2c277aecd5
Merge pull request #2029 from Vogtinator/no-uefi-modules
Don't copy GRUB modules for EFI with secure boot enabled
2022-01-21 06:14:27 -05:00
Matt Coleman
201d46e78f Add support for custom GRUB templates
This allows the user to specify a template file to customize
the bootloader menu. This only applies to oem and iso image
types: other image types use the grub mkconfig toolchain.

This resolves Issue #1970

Co-authored-by: Marcus Schäfer <marcus.schaefer@gmail.com>
2022-01-18 16:52:58 -05:00
Fabian Vogt
e1c3290dc6 Fix booting GRUB submenu entries with hybrid images (linux/linuxefi)
Variables assigned with "set" are not visible in submenus for some reason.
Export $linux and $initrd, so that they also work in submenu entries.

Fixes bsc#1192523
2022-01-14 09:40:10 +01:00
Fabian Vogt
c72ab38755 Don't copy GRUB modules for EFI with secure boot enabled
When booting grub.efi with secure boot enabled, modules can't be loaded
and thus the grub.efi image needs to be complete. Save some space in live
images by not copying them into the ISO filesystem.

Fixes part of #1750
2022-01-13 15:41:31 +01:00
Marcus Schäfer
3d1a5b9b53
Merge pull request #1939 from OSInside/fix_grub_linux_default_setup
Fixed GRUB_CMDLINE_LINUX_DEFAULT setup regression
2021-10-07 09:51:49 +02:00
Marcus Schäfer
7ca20f398a
Fixed creation of loopback config
If an extra boot partition is in use the creation of the config
file for the loopback boot feature was using the wrong path.
This commit fixes it and also introduces integration checks
which builds in this condition
2021-10-06 12:44:10 +02:00
Marcus Schäfer
e297a0f2a2
Fixed GRUB_CMDLINE_LINUX_DEFAULT setup regression
The value for GRUB_CMDLINE_LINUX_DEFAULT should only be
changed if custom kernelcmdline values are provided. In
case there are none kiwi should not change this value.
The test to check for this condition is based on the
result cmdline reduced by the root setting. However the
default cmdline setting in kiwi appends 'rw' in addition
to the root device information. This means the default
kernelcmdline is never empty and therefore the grub
setting GRUB_CMDLINE_LINUX_DEFAULT="rw" is always set.
This commit fixes the conditional change by making sure
the default cmdline only consists out of the root
device information. This Fixes #1650
2021-10-05 19:44:41 +02:00
Marcus Schäfer
2de29ae5bb
Fixed condition for GRUB_DISABLE_LINUX_UUID="true"
The grub config parameter GRUB_DISABLE_LINUX_UUID must only
be set if the device persistence setting is not UUID. However,
in kiwi UUID device names are the default and doesn't have to
be expressed explicitly. Therefore the condition to check
for different than 'by-uuid' is wrong for the default case were
no device persistence setting exists. This results in a wrong
grub option to be set. This commit fixes it in a way to disable
UUID device names in grub if the only other device persistency
setting in kiwi named: 'by-label' is explicitly configured.
This Fixes #1842
2021-09-06 11:35:52 +02:00
Marcus Schäfer
80f3148788
Add missing bootloader tests
Merging #1850 exposed the missing bootloader tests.
This reminds me to move the gitlab driven unit tests
to github actions because for forked repos the gitlab
tests does not run but github actions tests would run
2021-09-02 13:00:51 +02:00
Marcus Schäfer
e9935d01ee
Increase size of efi fat image
For ISO images an embedded efi fat image is needed to boot.
As consequence of adding the mok manager it can happen that
the size of the efi fat image is too small. With this commit
the size is increased to prevent an out of space issue
2021-07-14 12:26:24 +02:00
Marcus Schäfer
218cfa16b0
Fixed secure boot fallback setup
Make sure MokManager gets copied. The name and location of
the mok manager is distribution specific in the same way as
the shim loader. Thus we need to apply a similar concept
for looking it up. This Fixes bsc#1187515
2021-07-12 18:10:22 +02:00
Marcus Schäfer
fb3dc5744d
Allow creation of LUKS system with empty key
To support cloud platforms better we should allow the
creation of an initial(insecure) LUKS encrypted image
with an empty passphrase/keyfile. This Fixes
bsc#1187461 and bsc#1187460
2021-06-17 16:57:40 +02:00
Marcus Schäfer
c080b92710
Added support for UEFI on Debian based distros
The Debian/Ubuntu folks have a different system to support
EFI secure boot. In order to make use of it kiwi needs some
adaptions done in this pull request. This Fixes #1743
2021-04-28 17:04:35 +02:00
Marcus Schäfer
ce9b1ccc08
Added option to set the image target architecture
The option --target-arch allows to set the architecture
used to build the image. By default this is the host
architecture. Please note, if the specified architecture
name does not match the host architecture and is therefore
requesting a cross architecture image build, it's important
to understand that for this process to work a preparatory
step to support the image architecture and binary format
on the building host is required and is not considered a
responsibility of kiwi. There will be a followup effort
on providing a plugin for kiwi which should be used to
manage the needed binfmt settings for cross arch image
builds
2021-04-14 12:53:28 +02:00
Andreas Schwab
1c7e5866cd Add support for riscv64 2021-03-29 15:44:08 +02:00
Marcus Schäfer
791adcfcb7
Fix use of by-label device persistency in grub
If devicepersistency="by-label" is set in the KIWI description
it will correctly operate on the fstab values but still uses
the UUID based setting for root= in the grub config. This commit
allows to set root=LABEL=... in the grub config in case the
devicepersistency requested it. In order for this to work this
commit also had to increase the scope of the grub helper
method _fix_grub_root_device_reference which is now called in
any case. This Fixes #1757
2021-03-09 12:19:51 +01:00
David Cassany
c840474e3a
Refactor grub2 installation
This commit refactors grub2 installation method to split it in two
parts. Former grub2.install method was meant to run the grub2-install
tool, however, in addition it was also running the secure boot
installation shim-install. The install method in KIWI is skipped for
those architectures and firmware combinations for which bios support
doesn't exist. This was leading to skip the secure boot installation.

The current approach strips the secure boot installation logic from the
grub2.install method, so skipping the install method does not
automatically result in skipping the secure boot installation.

Fixes bsc#1182211
2021-03-03 15:19:43 +01:00
Marcus Schäfer
9b8dafed2c
Fixed use of BIOS grub image on ISO media
Not all systems (e.g Debian) creates the boot/grub|grub2 directory.
In kiwi when we need to create a custom grub image because we did
not find the distro provided one, an earlyboot.cfg file is created
and embedded into the grub image. The locaton to store that file
is below boot/grub|grub2. However if the directory does not exist
the build will fail as with the current Debian Live integration
test.
2021-02-11 12:47:35 +01:00
Marcus Schäfer
ab1a69d8b8
Follow up fix, creating custom grub EFI images
Make sure custom EFI grub image is copied to the media
directory if this is different from the root directory
e.g on creation of live images
2021-01-29 15:24:21 +01:00
Marcus Schäfer
fe5977e583
Follow up fix, creating custom grub images
Moving the grub mkimage call as chroot operation also broke
the creation of image builds that uses the legacy custom kiwi
boot image feature instead of dracut. This commit fixes it
2021-01-28 19:02:24 +01:00
Marcus Schäfer
0a4184ec45
Fixed creation of custom bios grub image
The last commit moved the grub mkimage call into the chroot.
As a side effect and when creating install media the earlyboot
script could no longer be found. This commit fixes it
2021-01-27 12:46:55 +01:00
Marcus Schäfer
61abfa4fc7
Fixed creation of custom grub image
If kiwi can't find the distribution provided grub image(s) it
creates them using the respective grub[X]-mkimage tool. However
the tool was called on the build host which could cause an
inconsistency on the used module path. Grub is not packaged
consistently across the distributions and also the provided
modules comes in different versions and patch sets. Therefore
it's required that kiwi calls the grub mkimage tool as chrooted
operation inside of the tree that provides the target image.
As consequence of the change it's required that the image root
tree provides the grub mkimage tool. In addition to the change
we now also log the output from the grub mkimage call in the
kiwi build logfile. This Fixes #1254
2021-01-25 15:50:41 +01:00
Marcus Schäfer
0b28cd3683
Only write GRUB_CMDLINE_LINUX_DEFAULT with content
Only write GRUB_CMDLINE_LINUX_DEFAULT in the grub defaults
file if there are custom options set via the kernelcmdline
attribute. This Fixes #1650
2021-01-18 13:02:22 +01:00
Marcus Schäfer
e3e6535563
Create relative boot link for extra boot partition
If an extra boot partition is used the grub toolchain
still references files from that partition as /boot/...
which fails because they are now at the toplevel. To
avoid this and keep any /boot/some-file reference still
valid we create a symlink 'boot -> .' This Fixes #1611
2020-11-12 23:45:38 +01:00
Marcus Schäfer
65346318dd
Fixed regexp for grub rootdev substitution
The regular expression to match the grub root device
used a lazy glob match ".*?". This however matches a
too long part depending on the rest of the content.
This commit fixes the expression to be strict on
the allowed characters and makes sure the anchor
characters are not part of the matching character
class. This Fixes #1607
2020-11-04 15:09:43 +01:00
Marcus Schäfer
367c252a0a
Set GRUB_DISTRIBUTOR if requested via displayname
If the image description explicitly specifies a displayname
it is expected that the bootloader shows this in the menu.
Therefore in case displayname is set GRUB_DISTRIBUTOR will
be set if grub2 is in use. This partially reverts #1420
and Fixes #1575
2020-11-02 10:06:22 +01:00
Marcus Schäfer
a5425fe575
Add support for s390 CDL DASD disks
On s390 and in CDL mode (4k DASD) the call of grub2-install
does not work because grub2-install is not able to identify
a 4k fdasd partitioned loop device as a grub supported device
and fails. As grub2-install is only used to invoke
grub2-zipl-setup and has no other job to do we can
circumvent this problem by directly calling grub2-zipl-setup
instead. Also delete LDL mode support, IBM no longer supports
this
2020-10-27 11:06:14 +01:00
Marcus Schäfer
31e0ce96cd
Enhance scope of _fix_grub_root_device_reference
In addition to the wrong root=/dev/mapper/loop... reference
fixing, written by grub2-mkconfig when used in obs there is
also the case that grub2-mkconfig writes root=PARTUUID which
is also unwanted and needs fixing. To solve this properly
and also with respect to more unexpected grub2-mkconfig
data, the code changes to use a regular expression for the
root= replacement. The expression matches all root= cases which
we want to fixup:

1. If the local used root device appears in the grub config file.
2. If a linux by-id setting is used in the grub config file.

The replacement happens for overlayroot disk images where we
know grub2-mkconfig cannot handle the layout as well as if kiwi
runs in obs where we know grub2-mkconfig fails due to the absence
of udev.
2020-10-12 09:08:08 +02:00
Marcus Schäfer
836633c7b2
Fix/Refactor s390 support
This changes the s390 support on several stages:

1) On s390 the boot process is based on zipl which boots into an
   initrd from which a userspace grub process is started to support
   the grub capabilities. The implementation of this concept is
   provided via the grub2-s390x-emu package. Once installed the
   setup of the bootloader is done via the grub2-mkconfig and
   grub2-install commands and therefore from a caller perspective
   the same as with any other grub2 setup process. For kiwi this
   means no extra zipl bootloader target code is needed. Therefore
   this commit deletes the zipl setup from kiwi and puts on
   the standard grub2 process. This Fixes bsc#1170863

2) To support different targettypes the grub2-s390x-emu provided
   zipl template must be adapted. Parts of the former zipl bootloader
   setup therefore now applies to an update of the zipl2grub
   template file

3) Support for CDL/LDL DASD targets has been disabled in the schema
   When testing 4k devices and a respective zipl2grub template
   setup for CDL/LDL targettype it has turned out that grub2-install
   is not able to run on such a device. My assumption is that
   the device code in grub2-install does not work for 4k devices
   with an fdasd created partition table. As this needs further
   investigations and most probably adaptions on the grub toolchain
   for s390, we disabled the setup of these modes for now.
   emulated DASD (FBA) and SCSI targets stays supported.
2020-09-30 17:14:30 +02:00
Marcus Schäfer
3c940e5439
Merge pull request #1569 from OSInside/refactor_bootloaderconfig
Refactor BootLoaderConfig
2020-09-29 09:51:51 +02:00
David Cassany
2abcce803b
Refactor BootLoaderInstall
This commit refactors BootLoaderInstall class to make it a proper
factory class. In addition type hints are added for the constructor
method.

Related to #1498
2020-09-28 09:37:05 +02:00
David Cassany
c06a424258
Refactor BootLoaderConfig
This commit refactors BootLoaderConfig to turn it into a proper factory
class and to also include type hints to facilitate it's use from an API
POV.

Related to #1498
2020-09-28 09:35:17 +02:00
Marcus Schäfer
7506c651c6
Merge pull request #1552 from OSInside/oem_superset_of_vmx
Make oem be a superset of vmx
2020-09-16 15:00:37 +02:00
Marcus Schäfer
8d2d9c214c
Make oem be a superset of vmx
A vmx image is the same disk as an oem just without the dracut
repart/resize feature. This difference is better handled with
an oemconfig parameter <oem-resize> which allows to switch resize
on or off. The extra image type vmx will be dropped and an XSLT
stylesheet automatically transforms a vmx description to be a
oem image with the resize feature switched off.
This Fixes #1425
2020-09-16 12:56:14 +02:00
David Cassany
cb7b7673e8
Fix the early boot grub.cfg file
This commit makes sure that the early boot configuration files
for grub make use of the proper boot path and omiting the `/boot`
prefix if there is a dedicated boot partition.

Fixes #1553
2020-09-16 11:35:00 +02:00
David Cassany
3bb2ab77fb
Include loadenv as a default module for grub images
This commit includes the 'loadenv' module to the list of basic grub
modules. This makes sure the module is included in any grub-mkimage
that KIWI does.

Fixes #1547
2020-09-14 22:07:23 +02:00
Marcus Schäfer
988404ff9f
Support dynamic linux/linuxefi in any case
Instead of restricting the dynamic linux vs. linuxefi setup
to a specific grub version, support this setup for any version
of grub. This Fixes bsc#1175729 and bsc#1176134
2020-09-08 18:14:15 +02:00
Marcus Schäfer
d7cd5b555d
Make sure kernel options are respected by grub
Set options variable in grub loader/entries to match the
kiwi image description setup. This adaption currently
happens only when building in OBS because in this env
the options setup done by grub is a complete mess.
2020-07-22 22:33:15 +02:00
Marcus Schäfer
1c5fcfaecd
Merge pull request #1516 from OSInside/fix_grub_setup_in_efi_path
Fixed grub setup in EFI/BOOT directory
2020-07-22 14:16:44 +02:00
Marcus Schäfer
b9824f7b62
Fixed corrections in BootLoaderSpec grub config
Distributions like Fedora RawHide or CentOS8 applies to the
grub BootLoaderSpec as described here:

    https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec

Part of the spec is that menu entries are handled in extra files
below /boot/loader/entries. Unfortunately the grub2-mkconfig code
has still no clue how to find the correct root device in special
environments like obs workers or in overlay systems. To fixup the
result of grub2-mkconfig there is code in kiwi which needs to be
adapted because the file that contains the wrong information is
now no longer grub.cfg but some /boot/loader/entries/*.conf file.
This commit solves the issue.
2020-07-22 10:36:24 +02:00