Skip to content

Commit

Permalink
Add kickstart/command line control to enable systemd-boot
Browse files Browse the repository at this point in the history
Now, that we have all the infrastructure in place, lets
add and document a 'inst.systemd' option that can be used
on the boot commadline or placed in kickstart files.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
  • Loading branch information
jlintonarm committed Oct 17, 2022
1 parent 29a646d commit 442cbaf
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions data/anaconda.conf
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ selinux = -1
#
# DEFAULT Choose the type by platform.
# EXTLINUX Use extlinux as the bootloader.
# SDBOOT Use systemd-boot as the bootloader.
#
type = DEFAULT

Expand Down
5 changes: 5 additions & 0 deletions data/anaconda_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ Use extlinux as the bootloader. Note that there's no attempt to validate
that this will work for your platform or anything; it assumes that if you
ask for it, you want to try.

sdboot
Use systemd-boot as the bootloader. Note that there's no attempt to validate
that this will work for your platform or anything; it assumes that if you
ask for it, you want to try.

nombr

If nombr is specified the grub2 bootloader will be installed but the
Expand Down
9 changes: 9 additions & 0 deletions docs/boot-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,15 @@ Use extlinux as the bootloader. Note that there's no attempt to validate that
this will work for your platform or anything; it assumes that if you ask for it,
you want to try.

.. inst.sdboot:
inst.sdboot
^^^^^^^^^^^^^

Use systemd-boot as the bootloader. Note that there's no attempt to validate that
this will work for your platform or anything; it assumes that if you ask for it,
you want to try.

.. inst.leavebootorder:
inst.leavebootorder
Expand Down
2 changes: 2 additions & 0 deletions pyanaconda/argument_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,8 @@ def __call__(self, parser, namespace, values, option_string=None):
help=help_parser.help_text("noeject"))
ap.add_argument("--extlinux", action="store_true", default=False,
help=help_parser.help_text("extlinux"))
ap.add_argument("--sdboot", action="store_true", default=False,
help=help_parser.help_text("sdboot"))
ap.add_argument("--nombr", action="store_true", default=False,
help=help_parser.help_text("nombr"))
ap.add_argument("--mpathfriendlynames", dest="multipath_friendly_names", action="store_true",
Expand Down
2 changes: 2 additions & 0 deletions pyanaconda/core/configuration/anaconda.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ def set_from_opts(self, opts):
# Set the bootloader type.
if opts.extlinux:
self.bootloader._set_option("type", BootloaderType.EXTLINUX.value)
if opts.sdboot:
self.bootloader._set_option("type", BootloaderType.SDBOOT.value)

# Set the boot loader flags.
self.bootloader._set_option("nonibft_iscsi_boot", opts.nonibftiscsiboot)
Expand Down
4 changes: 3 additions & 1 deletion pyanaconda/core/configuration/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@

class BootloaderType(Enum):
"""Type of the bootloader."""
DEFAULT = "DEFAULT"
DEFAULT = "DEFAULT"
EXTLINUX = "EXTLINUX"
SDBOOT = "SDBOOT"


class BootloaderSection(Section):
Expand All @@ -38,6 +39,7 @@ def type(self):
DEFAULT Choose the type by platform.
EXTLINUX Use extlinux as the bootloader.
SDBOOT Use systemd-boot as the bootloader.
:return: an instance of BootloaderType
"""
Expand Down
6 changes: 6 additions & 0 deletions pyanaconda/modules/storage/bootloader/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def _set_module_from_kickstart(self, data):
if data.bootloader.extlinux:
self.set_default_type(BootloaderType.EXTLINUX)

if data.bootloader.systemd:
self.set_default_type(BootloaderType.SDBOOT)

if data.bootloader.bootDrive:
self.set_drive(data.bootloader.bootDrive)

Expand Down Expand Up @@ -184,6 +187,9 @@ def setup_kickstart(self, data):
if self.get_default_type() == BootloaderType.EXTLINUX:
data.bootloader.extlinux = True

if self.get_default_type() == BootloaderType.SDBOOT:
data.bootloader.systemd = True

if self.bootloader_mode == BootloaderMode.DISABLED:
data.bootloader.disabled = True
data.bootloader.location = "none"
Expand Down
9 changes: 9 additions & 0 deletions pyanaconda/modules/storage/bootloader/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ def get_class_by_name(cls, name):
from pyanaconda.modules.storage.bootloader.extlinux import EXTLINUX
return EXTLINUX

if name == "SDBOOT":
platform_class = platform.platform.__class__
if platform_class is platform.Aarch64EFI:
from pyanaconda.modules.storage.bootloader.efi import Aarch64EFISystemdBoot
return Aarch64EFISystemdBoot
if platform_class is platform.EFI:
from pyanaconda.modules.storage.bootloader.efi import x64EFISystemdBoot
return x64EFISystemdBoot

return None

@classmethod
Expand Down
6 changes: 5 additions & 1 deletion pyanaconda/modules/storage/bootloader/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
from blivet.devices import BTRFSDevice
from pyanaconda.core.constants import PAYLOAD_TYPE_RPM_OSTREE, PAYLOAD_LIVE_TYPES
from pyanaconda.modules.storage.bootloader import BootLoaderError

from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.core.configuration.bootloader import BootloaderType
from pyanaconda.core.util import execWithRedirect
from pyanaconda.modules.common.errors.installation import BootloaderInstallationError
from pyanaconda.modules.storage.constants import BootloaderMode
Expand Down Expand Up @@ -192,6 +193,9 @@ def run(self):
if self._payload_type == PAYLOAD_TYPE_RPM_OSTREE:
log.debug("Don't regenerate initramfs on rpm-ostree systems.")
return
if conf.bootloader.type == BootloaderType.SDBOOT:
log.debug("Don't regenerate initramfs on systemd-boot systems.")
return

recreate_initrds(
sysroot=self._sysroot,
Expand Down

0 comments on commit 442cbaf

Please sign in to comment.