diff options
author | David Edmondson <dme@dme.org> | 2020-10-29 07:35:49 +0000 |
---|---|---|
committer | David Edmondson <dme@dme.org> | 2020-11-02 08:42:02 +0000 |
commit | 9dce4c68d8e854c685df5e6ad7ab522611af6029 (patch) | |
tree | e39b1d555266bc2524f2caffebe8489c38651f66 | |
parent | a6eb7b83d77313f9309ec1fac8a7c6f6424ea8e5 (diff) | |
download | vmdb2-9dce4c68d8e854c685df5e6ad7ab522611af6029.tar.gz |
feat(grub): add support for multiple architectures
Choose which GRUB UEFI package to install and the target to pass to
grub-install based on the target architecture.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | vmdb/plugins/grub.mdwn | 10 | ||||
-rw-r--r-- | vmdb/plugins/grub_plugin.py | 21 |
3 files changed, 23 insertions, 10 deletions
@@ -4,6 +4,8 @@ NEWS for vmdb2, the Debian disk image builder Version 0.20+git, not yet released ----------------------------------------------------------------------------- +* The grub plugin is able to install the UEFI version of grub on arm64 + targets, patch from David Edmondson. Version 0.20, released 2020-10-18 diff --git a/vmdb/plugins/grub.mdwn b/vmdb/plugins/grub.mdwn index 645caf0..037d4d3 100644 --- a/vmdb/plugins/grub.mdwn +++ b/vmdb/plugins/grub.mdwn @@ -1,17 +1,17 @@ Step: grub ----------------------------------------------------------------------------- -Install the GRUB bootloader to the image. Works on a PC, for -traditional BIOS booting or modern UEFI booting. Does not (yet?) -support Secure Boot. +Install the GRUB bootloader to the image. Works on a PC for +traditional BIOS booting and both a PC and arm64 machines for modern +UEFI booting. Does not (yet?) support Secure Boot. Warning: This is the least robust part of vmdb2. Step keys: * `grub` — REQUIRED; value MUST be one of `uefi` and `bios`, for - a UEFI or a BIOS boot, respectively. (FIXME: these are valid for a - PC; not sure what other archs require, if grub even works there.) + a UEFI or a BIOS boot, respectively. Only PC systems support the + `bios` option. * `tag` — REQUIRED; value is the tag for the root filesystem. diff --git a/vmdb/plugins/grub_plugin.py b/vmdb/plugins/grub_plugin.py index b081098..b46efab 100644 --- a/vmdb/plugins/grub_plugin.py +++ b/vmdb/plugins/grub_plugin.py @@ -51,9 +51,9 @@ # For cleanliness, we also undo any bind mounts into the chroot. Don't # want to leave them in case they cause trouble. # -# Note that this is currently rather strongly assuming that UEFI and -# the amd64 (a.k.a. x86_64) architecture are being used. These should -# probably not be hardcoded. Patch welcome. +# Note that this is currently assuming that UEFI and either the amd64 +# (a.k.a. x86_64) or arm64 (a.k.a. aarch64) architectures are being +# used. These should probably not be hardcoded. Patch welcome. # To use this plugin: write steps to create a root filesystem, and an # VFAT filesystem to be mounted as /boot/efi. Install Debian onto the @@ -105,6 +105,18 @@ class GrubStepRunner(vmdb.StepRunnerInterface): else: raise Exception("Unknown GRUB flavor {}".format(flavor)) + def grub_uefi_variant(self, state): + variants = { + "amd64": ("grub-efi-amd64", "x86_64-efi"), + "arm64": ("grub-efi-arm64", "arm64-efi"), + } + try: + return variants[state.arch] + except KeyError: + raise Exception( + 'GRUB UEFI package and target for "{}" unknown'.format(state.arch) + ) + def install_uefi(self, values, settings, state): efi = values["efi"] or None efi_part = values["efi-part"] or None @@ -112,8 +124,7 @@ class GrubStepRunner(vmdb.StepRunnerInterface): raise Exception('"efi" or "efi-part" required in UEFI GRUB installation') vmdb.progress("Installing GRUB for UEFI") - grub_package = "grub-efi-amd64" - grub_target = "x86_64-efi" + (grub_package, grub_target) = self.grub_uefi_variant(state) self.install_grub(values, settings, state, grub_package, grub_target) def install_bios(self, values, settings, state): |