boot.py: cleanups, don't create loopdev just for jumpdrive

This commit is contained in:
InsanePrawn 2022-02-13 20:00:59 +01:00
parent 3ed8d379dd
commit f1ce9865b6

17
boot.py
View file

@ -6,7 +6,6 @@ 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, losetup_rootfs_image, get_image_path, dump_aboot, dump_lk2nd
from chroot import get_device_chroot
from wrapper import enforce_wrap
LK2ND = FLASH_PARTS['LK2ND']
@ -22,10 +21,8 @@ def cmd_boot(type):
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)
image_path = get_image_path(device, flavour)
strategy = BOOT_STRATEGIES[device]
if strategy == FASTBOOT:
@ -35,11 +32,13 @@ def cmd_boot(type):
os.makedirs(os.path.dirname(path), exist_ok=True)
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(loop_device + 'p1')
elif type == ABOOT:
path = dump_aboot(loop_device + 'p1')
else:
raise Exception(f'Unknown boot image type {type}')
loop_device = losetup_rootfs_image(image_path, sector_size)
if type == LK2ND:
path = dump_lk2nd(loop_device + 'p1')
elif type == ABOOT:
path = dump_aboot(loop_device + 'p1')
else:
raise Exception(f'Unknown boot image type {type}')
fastboot_erase_dtbo()
fastboot_boot(path)