From f369b00ebd1da265e2f456d31e8b959eb4f3c893 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Tue, 26 Oct 2021 06:03:31 +0200 Subject: [PATCH] boot.py: use losetup --- boot.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/boot.py b/boot.py index a954651..1f28b62 100644 --- a/boot.py +++ b/boot.py @@ -5,7 +5,7 @@ import click from config import config from constants import BOOT_STRATEGIES, FLASH_PARTS, FASTBOOT, JUMPDRIVE, JUMPDRIVE_VERSION from fastboot import fastboot_boot, fastboot_erase_dtbo -from image import get_device_and_flavour, get_image_path, dump_bootimg, dump_lk2nd +from image import get_device_and_flavour, losetup_rootfs_image, get_image_path, dump_bootimg, dump_lk2nd from chroot import get_device_chroot from wrapper import enforce_wrap @@ -21,8 +21,11 @@ def cmd_boot(type): f"""Flash one of {', '.join(TYPES)}""" enforce_wrap() device, flavour = get_device_and_flavour() + # TODO: parse arch and sector size chroot = get_device_chroot(device, flavour, 'aarch64') + sector_size = 4096 image_path = get_image_path(chroot) + loop_device = losetup_rootfs_image(image_path, sector_size) strategy = BOOT_STRATEGIES[device] if strategy == FASTBOOT: @@ -33,9 +36,9 @@ def cmd_boot(type): if not os.path.exists(path): urllib.request.urlretrieve(f'https://github.com/dreemurrs-embedded/Jumpdrive/releases/download/{JUMPDRIVE_VERSION}/{file}', path) elif type == LK2ND: - path = dump_lk2nd(image_path) + path = dump_lk2nd(loop_device + 'p1') elif type == BOOTIMG: - path = dump_bootimg(image_path) + path = dump_bootimg(loop_device + 'p1') else: raise Exception(f'Unknown boot image type {type}') fastboot_erase_dtbo()