Commit Graph

198 Commits

Author SHA1 Message Date
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
490a9db564
Use pragma: no cover to skip non reachable code
Instead of placing the file into .coveragerc use the
no cover pragma to skip code paths that can never be
reached from being counted in the coverage report.
This affects the abstract constructors in the Factory
classes
2020-09-29 09:58:22 +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
fc09237d05
Cleanup grub adaptions code
The grub setup code has some after grub-mkconfig code that
fixes the written grub.cfg file on certain conditions. For
a better understanding and readability those conditions
and reasons are now put into private _fix* methods that
explains why we need to patch the written grub config file.
We all hope that those methods can go away when grub gets
fixed properly. This Fixes #1527
2020-09-22 11:36:52 +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
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
352865282c
Fixed legacy custom kiwi initrd based image builds
This patch is two fold:

* Image builds that uses the kiwi initrd system did not apply
  the grub config file fixes because the root= parameter is
  an optional information when using a kiwi initrd. However
  this information is required to apply the grub config file
  fixes. Therefore this patch simplifies the kernel commandline
  processing such that it is the same for dracut and custom
  kiwi initrd based systems. This means root= is passed in
  any case.

* The other part of the patch disables the method that strips
  unused libraries from the custom kiwi initrd. It has turned
  out that is safes us almost nothing but could causes corrupted
  initrds missing important libraries e.g libpam which is linked
  against udev and other tools. Therefore libpam is also added
  to the protected strip list
2020-08-27 14:52:45 +02:00
Marcus Schäfer
531acc4805
Fixed bootloader grub copy SameFileError exception
Only copy the file if the given source and destination are
not the same file
2020-08-11 11:56:00 +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
d230999a39
Fixed root replace for grub menu entries
The root device spec in the grub boot/loader/entries/*.conf
files when building in OBS is not matching the loop mapped
image root device but matches the root device of the OBS worker.
Very strange behavior and of course wrong. Because of that
the expression to replace the wrong device with the correct
one must be a regular expression and cannot be based on the
loop mapped image root device.
2020-07-22 20:04:04 +02:00
Marcus Schäfer
1ad99e32b8
Fixed path to search for grub menu entries 2020-07-22 15:50:33 +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
Marcus Schäfer
3255264d4c
Fixed grub setup in EFI/BOOT directory
kiwi copied the same grub.cfg file as it exists in boot/grub2
to the efi path. This is wrong as the setup in the efi boot
directory is used to enable normal grub loading and not providing
the user grub configuration. In addition the changes here makes
sure that the early grub boot code is placed into the system
in any EFI case except for secure boot when shim-install is
present. If shim-install is present it also creates the early
grub boot setup such that kiwi doesn't have to do it.
This Fixes #1491 and Fixes bsc#1172908
2020-07-22 09:41:08 +02:00
Marcus Schäfer
6b2c4f88bb
Don't keep copy of grub2-install in the system
To prevent shim-install from calling grub2-install in uefi mode
kiwi temporary replaces the tool by a noop. This acts as a
workaround for an issue in shim-install. However the workaround
left a file copy of grub2-install in the system which should
not happen. This commit Fixes bsc#1173226 and Fixes #1490
2020-07-15 14:38:47 +02:00
Marcus Schäfer
0ae7bbe74e
Fixed check for root device in grub config
There is a code path that fixes the grub2-mkconfig used root device
when building in an environment that does not allow to resolve the
by-X path names, e.g an obs build worker without udev. For images
that explicitly defines a root=... value in the kernelcmdline
attribute the root device check was not called because the
_get_root_cmdline_parameter method returns None. This commit fixes
the method to return the expected root device in any case such that
the grub2-mkconfig root device check has a chance to fix what
grub2-mkconfig has created. This fixes bsc#1172928
2020-06-15 14:57:54 +02:00
David Cassany
70bf9e98de
Fix the patch applied on grub.cfg
This commit fixes the patch applied on grub.cfg when EFI mode is
selected and grub < 2.04. There are some distros that make use of the
`linux16` command instead of `linux` in grub configuration, this commit
extends the regex to also consider `linux16` command.
2020-05-26 12:41:15 +02:00
Marcus Schäfer
024c3b6834
Fix scope for linuxefi grub config adaption
In kiwi we support a one time patch for the grub config file
that changes the static use of linuxefi to be dynamic. In
grub2 >= 2.04 all this has already been fixed but for grub2
version older than this version we applied the patch. The
patch however was only applied based on the presence of a
grub setting named GRUB_USE_LINUXEFI. It has turned out that
this variable is a custom extension not part of grub upstream
which makes the test functional only on distributions that
supports this setting. The use of linuxefi however is code
that belongs to grub upstream. Therefore this patch changes
the scope of the one time patch to be only based on the
version of grub no matter if GRUB_USE_LINUXEFI is supported
by the distro or not. This Fixes #1453
2020-05-25 12:33:19 +02:00
Marcus Schäfer
9218a9abdb
Fixed root device setup in vendor grubenv
In addition to the root device setup in grub.cfg we also
need to patch the vendor grubenv file which contains an
invalid kernelopts value written by grub2-mkconfig under
the conditions explained in Issue #1287. This Fixes
Issue #1454
2020-05-23 19:22:05 +02:00
Marcus Schäfer
01ef6946d6
Cleanup use of machine platform name
in kiwi we handle 32bit x86 architecture names as ix86. This is
done by checking i586 and i686 32bit arch names. However those
checks are spread over the entire kiwi code base and should be
consolidated into one method. The cleanup of those arch name
usage fixes an inconsistency between the arch name used in the
disk builder and the arch name used in the subformat image
formats. This Fixes #1438
2020-05-13 13:47:42 +02:00
Marcus Schäfer
9fddb90a6b
Allow setup of serial line in bootloader
So far kiwi used a static serial line setup of the console
type was configured to use a serial console. However if
different parameters are needed there was no way to change
the static setup. This commit adds a new bootloader attribute
called serial_line which allows to specify the serial line
parameters for the grub bootloader e.g

    serial_line="serial --speed=9600 --unit=0 --word=8 --parity=no --stop=1"

Please note serial_line takes the value as it is given and
adds this as a line to the grub configuration or as content
to the variable GRUB_SERIAL_COMMAND. No further validation
of the information takes place by kiwi. This Fixes #1401
2020-05-13 11:25:42 +02:00
Marcus Schäfer
d276394660
Support grub timeout_style parameter
Grub supports a style setting that influences the display of
the menu depending on the configured timeout value. With this
patch kiwi allows to specify the style via a new bootloader
parameter named timeout_style="hidden|countdown". If not set
the grub default applies which shows the menu in any case.
This Fixes bsc#1165730 and Fixes #1404
2020-05-11 12:38:28 +02:00
Marcus Schäfer
feaf6b0863
Refactor setup of bootloader parameters
The bootloader settings are handled through attributes in the
type element. Over the years some attributes were added and
there are requests for more settings. Therefore the bootloader
setup deservers its own section. With this commit the schema
changes from v7.1 to v7.2 and moves bootloader, bootloader_console
boottimeout and zipl_targettype into a new bootloader subsection
below type. The commit also adds an auto transformation template
such that customers don't have to change their image descriptions.
This is related to Issue #1401
2020-05-08 13:30:43 +02:00
Marcus Schäfer
7e836ad7a5
Do not set GRUB_DISTRIBUTOR
grub mkconfig creates a proper string based on /etc/os-release
if GRUB_DISTRIBUTOR is not set. We assume this to be true
for all distributions. This Fixes #1416
2020-04-28 17:49:20 +02:00
Marcus Schäfer
09c7c7a9b4
Fixed _get_grub2_mkconfig_tool
Last patch on this method breaks the search for alternative
mkconfig names. It returns always on the first lookup which
could be none. This breaks on systems that uses a different
name than grub2-mkconfig, like on Ubuntu.
2020-04-17 10:21:57 +02:00
Marcus Schäfer
f6b3b14020
Fixed return value from _get_grub2_mkconfig_tool
The method returned the basename of the tool if it could
be found by Path.which(). But the method's scope has been
changed in a way that the return value of the method must
be the result from Path.which() to allow working on the
full path name.
2020-04-16 11:24:28 +02:00
Marcus Schäfer
91373ea845
Merge pull request #1398 from OSInside/validate_grub_config_on_linuxefi
Validate use of GRUB_USE_LINUXEFI
2020-04-16 10:25:45 +02:00
Marcus Schäfer
a46c56a546
Validate use of GRUB_USE_LINUXEFI
On systems that uses GRUB_USE_LINUXEFI with grub2 version
less than 2.04 there is no support for dynamic EFI
environment checking. In this condition we extend the grub
setup to add this support. The change kiwi does is as
follows:

* Apply only on grub < 2.04
  1. Modify 10_linux to set linux/initrd as variables
  2. Write hybrid setup as 01_efihybrid

This Fixes bsc#1165960 and bsc#1168480
2020-04-15 15:24:13 +02:00
Marcus Schäfer
0a63d9657f
Merge pull request #1400 from OSInside/fix_check_for_grub_capabilities
Fixed check for grub mkconfig capabilities
2020-04-15 13:54:52 +02:00
Marcus Schäfer
0a668bd694
Fixed check for grub mkconfig capabilities
The check for the capabilities of the tool were applied to
the tool installed on the host but the later call of the
tool will be done with the tool inside the image root
2020-04-15 11:37:23 +02:00
Jan Löser
44c7166da2 Fixed typo in docstring
Istall -> Install
2020-04-14 16:25:48 +02:00
David Cassany
fe3c2f3c73
Add SECURE_BOOT parameter for grub2 in efi mode
This commit adds the SECURE_BOOT parameter on bootloader sysconfig
for grub2.

Fixes bsc#1167746
2020-03-26 15:38:47 +01:00
Marcus Schäfer
e566153138
Fixed bootloader install
Mount EFI partition in any case not only for the shim target
2020-03-20 17:53:28 +01:00
Marcus Schäfer
89226abd46
Addded doc_suse tox target to build docbook target
SUSE documentation is based on docbook or asciidoc. The kiwi
documentation is maintained along with the code and uses the
sphinx system and therefore ReST as markup language. We would
like to keep one source and don't want to move to another markup
language. Thus the sources needs to be structured in a way that
allows translation into sphinx supported targets as well as
into SUSE docbook style. This commit changes the documentation
structure in a way that both is possible. With the use of Sphinx
XML and rstxml2docbook the ReST docs are converted into docbook.
From there the SUSE daps tool can create SUSE documentation
2020-02-14 15:14:30 +01:00
David Cassany
1466a6c69a
Make use of Path.which including root_dir parameter
This commit refactors the use of Path.which in several parts of the
code. Since dd4d2ed78 the Path utility is capable to run Path.which
on certain chroot env, thus no need to adapt the PATH environment
variable.

Fixes #1281
2020-01-22 16:12:08 +01:00
David Cassany
2e271b882d
Fix grub2 configuration for shim fallback setup
If shim fallback setup is enabled the grub.cfg is copied to the EFI
partition. This commit makes sure that the grub.cfg is copied to the EFI
partition according to the efi mount point.

Fixes bsc#1159235
2019-12-18 18:51:59 +01:00
Marcus Schäfer
2ad9fcf743
Fixed root setup when building in OBS
When building in an OBS worker no udevd is running which prevents
grub2-mkconfig from finding the by-* device nodes and it puts the
local loop device in which is wrong. Therefore the patching code
used for overlay disk configurations also applies when building
in an OBS worker environment. This Fixes #1287
2019-12-04 16:35:13 +01:00
386aecb36e
Merge pull request #1284 from OSInside/fix_grub_default_setup
Fixed setup of default grub config
2019-11-29 11:54:06 -05:00
Marcus Schäfer
9a9e62018f
Fixed setup of default grub config
In /etc/default/grub GRUB_CMDLINE_LINUX_DEFAULT also contained
the root= information. If grub2-mkconfig runs with that information
it places the root device information twice because grub2-mkconfig
resolves this information itself. This commit prevents the root=
information to be placed in the default grub config and
Fixes bsc#1156908
2019-11-29 17:36:54 +01:00
Marcus Schäfer
f7d89f9868
Lookup distribution specific grub font dir
In addition to the generic grub font directory also lookup
distribution specific font paths in the system and copy the
grub unicode font into it. This Fixes #1253
2019-11-28 14:43:02 +01:00
David Cassany
dd4d2ed78d
Add new root option in Path.which method
This commit adds to Path utility a couple of methods to manipulate
paths. One to rebase given paths to a new root and another one to
trim the given root path. In addition a new option in Path.which
is added to allow searches into chroot evironments.

Fixes #1276
2019-11-27 11:07:49 +01:00
David Cassany
c8ec226664
Include grub.cfg inside the efi partition
This commit ensures the grub.cfg file is included within the vfat efi
partition.

This fixes #1271 and bsc#1157354
2019-11-22 09:39:59 +01:00
Marcus Schäfer
472cb07d48
Fixed zipl bootloader config template
The targetgeometry value is not allowed for SCSI and FBA
mode. So far we handled only SCSI and failed on FBA mode.
This commit fixes it
2019-11-14 16:59:02 +01:00
Marcus Schäfer
726eeacee5
Fixed zipl bootloader setup for s390 images
The preparation to call zipl and the call itself were wrong.
For whatever reason the kernel image the initrd are moved
to another location prior to calling zipl. That move broke
the system because no kernel/initrd existed at the expected
place anymore. In addition the zipl call itself was issued
from a the wrong directory. Also no config file was written
as an after effect of the refactoring in Issue #1194. This
Fixes #1173 and bsc#1156694
2019-11-14 12:01:06 +01:00
David Cassany
60659a2dde
Ensure grub.cfg is copied in EFI/BOOT folder
This commit fixes the live images in efi mode. Grub configuration file
is copied to the correct location in <boot_dir>/EFI/BOOT.

Fixes bsc#1155815
2019-11-06 12:58:49 +01:00
Javier Martinez Canillas
9d8ce7eedb
Enable BLS configuration if is supported
Fedora now uses a BLS configuration by default, but this is not supported
by all distributions. So check if is supported by the grub2-mkconfig tool
and only enable the option if that's the case.

Fixes: #1248
2019-10-25 18:05:02 +02:00