a lot: profiles, some more help strings. partial: exceptions instead of exit()

Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
This commit is contained in:
InsanePrawn 2021-09-29 02:00:59 +02:00
parent e705af21f5
commit f09deaa9a5
9 changed files with 190 additions and 106 deletions

16
boot.py
View file

@ -2,13 +2,20 @@ import os
import urllib.request
from image import get_device_and_flavour, get_image_name, dump_bootimg, dump_lk2nd
from fastboot import fastboot_boot, fastboot_erase_dtbo
from constants import BOOT_STRATEGIES, FASTBOOT, JUMPDRIVE, LK2ND, JUMPDRIVE_VERSION
from constants import BOOT_STRATEGIES, FLASH_PARTS, FASTBOOT, JUMPDRIVE, JUMPDRIVE_VERSION
import click
import logging
LK2ND = FLASH_PARTS['LK2ND']
BOOTIMG = FLASH_PARTS['BOOTIMG']
TYPES = [LK2ND, JUMPDRIVE, BOOTIMG]
@click.command(name='boot')
@click.argument('type', required=False)
@click.argument('type', required=False, default=BOOTIMG)
def cmd_boot(type):
f"""Flash one of {', '.join(TYPES)}"""
device, flavour = get_device_and_flavour()
image_name = get_image_name(device, flavour)
strategy = BOOT_STRATEGIES[device]
@ -21,8 +28,9 @@ def cmd_boot(type):
urllib.request.urlretrieve(f'https://github.com/dreemurrs-embedded/Jumpdrive/releases/download/{JUMPDRIVE_VERSION}/{file}', path)
elif type == LK2ND:
path = dump_lk2nd(image_name)
else:
elif type == BOOTIMG:
path = dump_bootimg(image_name)
else:
raise Exception(f'Unknown boot image type {type}')
fastboot_erase_dtbo()
fastboot_boot(path)