image: use IMG_FILE_BOOT_DEFAULT_SIZE to calculate shrunk boot partition size
This commit is contained in:
parent
dd4a4212a3
commit
095ecb672f
2 changed files with 18 additions and 5 deletions
16
image/cli.py
16
image/cli.py
|
@ -114,6 +114,16 @@ def cmd_build(
|
|||
profile: Profile = config.get_profile(profile_name)
|
||||
flavour = get_profile_flavour(profile_name)
|
||||
rootfs_size_mb = flavour.parse_flavourinfo().rootfs_size * 1000 + int(profile.size_extra_mb)
|
||||
bootfs_size_str = IMG_FILE_BOOT_DEFAULT_SIZE
|
||||
bootfs_size_mb = -1
|
||||
if bootfs_size_str.endswith('M'):
|
||||
bootfs_size_mb = int(bootfs_size_str.rstrip('M'))
|
||||
elif bootfs_size_str.endswith('G'):
|
||||
bootfs_size_mb = int(bootfs_size_str.rstrip('G')) * 1024
|
||||
elif not bootfs_size_str.isdecimal():
|
||||
raise Exception(f"Couldn't part bootfs target size as megabytes: {bootfs_size_str}")
|
||||
else:
|
||||
bootfs_size_mb = int(bootfs_size_str)
|
||||
|
||||
if encryption is None:
|
||||
encryption = profile.encryption
|
||||
|
@ -142,11 +152,11 @@ def cmd_build(
|
|||
makedir(os.path.dirname(image_path))
|
||||
|
||||
logging.info(f'Creating new file at {image_path}')
|
||||
create_img_file(image_path, f"{rootfs_size_mb}M")
|
||||
create_img_file(image_path, f"{rootfs_size_mb + bootfs_size_mb}M")
|
||||
|
||||
loop_device = losetup_rootfs_image(image_path, sector_size or device.get_image_sectorsize_default())
|
||||
|
||||
partition_device(loop_device)
|
||||
partition_device(loop_device, boot_partition_size=bootfs_size_str)
|
||||
partprobe(loop_device)
|
||||
|
||||
boot_dev: str
|
||||
|
@ -159,7 +169,7 @@ def cmd_build(
|
|||
root_dev = loop_root
|
||||
else:
|
||||
logging.info('Creating per-partition image files')
|
||||
boot_dev = create_img_file(get_image_path(device, flavour, 'boot'), IMG_FILE_BOOT_DEFAULT_SIZE)
|
||||
boot_dev = create_img_file(get_image_path(device, flavour, 'boot'), f'{bootfs_size_mb}M')
|
||||
root_dev = create_img_file(get_image_path(device, flavour, 'root'), f'{rootfs_size_mb - 200}M')
|
||||
|
||||
root_dev_raw = root_dev
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue