mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-23 13:45:45 -05:00
Bonus: Generalize and reuse cmd_ssh() Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
28 lines
1 KiB
Python
28 lines
1 KiB
Python
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
|
|
import click
|
|
|
|
|
|
@click.command(name='boot')
|
|
@click.argument('type', required=False)
|
|
def cmd_boot(type):
|
|
device, flavour = get_device_and_flavour()
|
|
image_name = get_image_name(device, flavour)
|
|
strategy = BOOT_STRATEGIES[device]
|
|
|
|
if strategy == FASTBOOT:
|
|
if type == JUMPDRIVE:
|
|
file = f'boot-{device}.img'
|
|
path = os.path.join('/var/cache/jumpdrive', file)
|
|
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_name)
|
|
else:
|
|
path = dump_bootimg(image_name)
|
|
|
|
fastboot_erase_dtbo()
|
|
fastboot_boot(path)
|