]> git.ipfire.org Git - people/ms/bricklayer.git/commitdiff
bootloaders: Create special partitions only if needed
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 May 2021 19:40:23 +0000 (19:40 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 May 2021 19:40:23 +0000 (19:40 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/bootloaders.py
src/python/disk.py

index 9e9f46bc53493f78d7c34d72ce3ae81ec4bfc0e1..fa122ec96c7e5301f052aba3fd95ca188051f251 100644 (file)
@@ -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":
index b0ce3fb3a2612bfee2b4f4fbd5da1a44bb48fa60..c4196f3370af33bf160c70bbe5750f30f6289abe 100644 (file)
@@ -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)