image,flash: get sector size from deviceinfo

This commit is contained in:
InsanePrawn 2022-09-04 02:55:39 +02:00
parent 4f7cb8f516
commit 927fa352c5
2 changed files with 15 additions and 6 deletions

View file

@ -27,8 +27,10 @@ def cmd_flash(what: str, location: str):
device_image_name = get_image_name(device, flavour)
device_image_path = get_image_path(device, flavour)
# TODO: PARSE DEVICE SECTOR SIZE
sector_size = 4096
deviceinfo = device.parse_deviceinfo()
sector_size = deviceinfo.flash_pagesize
if not sector_size:
raise Exception(f"Device {device.name} has no flash_pagesize specified")
if what not in FLASH_PARTS.values():
raise Exception(f'Unknown what "{what}", must be one of {", ".join(FLASH_PARTS.values())}')

View file

@ -397,7 +397,11 @@ def cmd_build(profile_name: str = None,
flavour = get_flavour(profile_name)
size_extra_mb: int = int(profile["size_extra_mb"])
sector_size = 4096
deviceinfo = device.parse_deviceinfo()
sector_size = deviceinfo.flash_pagesize
if not sector_size:
raise Exception(f"Device {device.name} has no flash_pagesize specified")
rootfs_size_mb = FLAVOURS[flavour].get('size', 2) * 1000
packages = BASE_PACKAGES + [device.package.name] + FLAVOURS[flavour]['packages'] + profile['pkgs_include']
@ -466,9 +470,12 @@ def cmd_inspect(profile: str = None, shell: bool = False):
arch = device.arch
wrap_if_foreign_arch(arch)
flavour = get_flavour(profile)
# TODO: PARSE DEVICE SECTOR SIZE
sector_size = 4096
chroot = get_device_chroot(device, flavour, arch)
deviceinfo = device.parse_deviceinfo()
sector_size = deviceinfo.flash_pagesize
if not sector_size:
raise Exception(f"Device {device.name} has no flash_pagesize specified")
chroot = get_device_chroot(device.name, flavour, arch)
image_path = get_image_path(device, flavour)
loop_device = losetup_rootfs_image(image_path, sector_size)
partprobe(loop_device)