From: Michael Tremer Date: Mon, 10 May 2021 19:40:23 +0000 (+0000) Subject: bootloaders: Create special partitions only if needed X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=140eee624337682fd263ed25d49b39f5935ffd52;p=people%2Fms%2Fbricklayer.git bootloaders: Create special partitions only if needed Signed-off-by: Michael Tremer --- diff --git a/src/python/bootloaders.py b/src/python/bootloaders.py index 9e9f46b..fa122ec 100644 --- a/src/python/bootloaders.py +++ b/src/python/bootloaders.py @@ -41,6 +41,12 @@ class Bootloader(object): # Packages that need to be installed packages = [] + # Requires a BIOS boot partition? + requires_bootldr_partition = False + + # Requires an EFI partition? + requires_efi_partition = False + def __init__(self, bricklayer): self.bricklayer = bricklayer @@ -73,6 +79,8 @@ class Grub(Bootloader): "grub", ] + requires_bootldr_partition = True + def install(self): # Initialize Pakfire pakfire = self.bricklayer.setup_pakfire() @@ -100,6 +108,8 @@ class Grub(Bootloader): class GrubEFI(Grub): name = N_("GRUB EFI") + requires_efi_partition = True + @property def grub_arch(self): if self.bricklayer.arch == "aarch64": diff --git a/src/python/disk.py b/src/python/disk.py index b0ce3fb..c4196f3 100644 --- a/src/python/disk.py +++ b/src/python/disk.py @@ -273,12 +273,14 @@ class Disk(object): log.debug("Creating partition layout on %s" % self.path) # Create a bootloader partition of exactly 1 MiB - self._add_partition("BOOTLDR", DEFAULT_FILESYSTEM, length=1024**2, - flags=[parted.PARTITION_BIOS_GRUB]) + if any((bl.requires_bootldr_partition for bl in self.bricklayer.bootloaders)): + self._add_partition("BOOTLDR", DEFAULT_FILESYSTEM, length=1024**2, + flags=[parted.PARTITION_BIOS_GRUB]) # Create an EFI-partition of exactly 32 MiB - self._add_partition("ESP", "fat32", length=32 * 1024**2, - flags=[parted.PARTITION_ESP]) + if any((bl.requires_efi_partition for bl in self.bricklayer.bootloaders)): + self._add_partition("ESP", "fat32", length=32 * 1024**2, + flags=[parted.PARTITION_ESP]) # Create a swap partition swap_size = self.bricklayer.settings.get("swap-size", 0)