image: use IMG_FILE_BOOT_DEFAULT_SIZE to calculate shrunk boot partition size

This commit is contained in:
InsanePrawn 2023-07-09 19:57:24 +02:00
parent 68bf43d53a
commit 7d9e48a652
2 changed files with 18 additions and 5 deletions

View file

@ -356,8 +356,11 @@ def create_img_file(image_path: str, size_str: str):
return image_path
def partition_device(device: str):
boot_partition_size = '100MiB'
def partition_device(device: str, boot_partition_size: Optional[str] = None):
if boot_partition_size is None:
boot_partition_size = IMG_FILE_BOOT_DEFAULT_SIZE
if boot_partition_size and boot_partition_size[-1] in ['M', 'G', 'K']:
boot_partition_size = f'{boot_partition_size}iB'
create_partition_table = ['mklabel', 'msdos']
create_boot_partition = ['mkpart', 'primary', 'ext2', '0%', boot_partition_size]
create_root_partition = ['mkpart', 'primary', boot_partition_size, '100%']