partially add config.file['paths']['images'] (mostly taken from c5c8104a60)

Co-authored-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: InsanePrawn <insane.prawny@gmail.com>
This commit is contained in:
InsanePrawn 2021-10-25 17:42:31 +02:00
parent 9258cbf76d
commit ee4f899254
4 changed files with 13 additions and 7 deletions

16
boot.py
View file

@ -1,9 +1,11 @@
import os import os
import urllib.request 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, FLASH_PARTS, FASTBOOT, JUMPDRIVE, JUMPDRIVE_VERSION
import click 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_name, dump_bootimg, dump_lk2nd
from wrapper import enforce_wrap from wrapper import enforce_wrap
LK2ND = FLASH_PARTS['LK2ND'] LK2ND = FLASH_PARTS['LK2ND']
@ -19,18 +21,20 @@ def cmd_boot(type):
enforce_wrap() enforce_wrap()
device, flavour = get_device_and_flavour() device, flavour = get_device_and_flavour()
image_name = get_image_name(device, flavour) image_name = get_image_name(device, flavour)
image_path = os.path.join(config.get_path('images'), image_name)
strategy = BOOT_STRATEGIES[device] strategy = BOOT_STRATEGIES[device]
if strategy == FASTBOOT: if strategy == FASTBOOT:
if type == JUMPDRIVE: if type == JUMPDRIVE:
file = f'boot-{device}.img' file = f'boot-{device}.img'
path = os.path.join('/var/cache/jumpdrive', file) path = os.path.join(config.get_path('jumpdrive'), file)
os.makedirs(os.path.dirname(path), exist_ok=True)
if not os.path.exists(path): if not os.path.exists(path):
urllib.request.urlretrieve(f'https://github.com/dreemurrs-embedded/Jumpdrive/releases/download/{JUMPDRIVE_VERSION}/{file}', path) urllib.request.urlretrieve(f'https://github.com/dreemurrs-embedded/Jumpdrive/releases/download/{JUMPDRIVE_VERSION}/{file}', path)
elif type == LK2ND: elif type == LK2ND:
path = dump_lk2nd(image_name) path = dump_lk2nd(image_path)
elif type == BOOTIMG: elif type == BOOTIMG:
path = dump_bootimg(image_name) path = dump_bootimg(image_path)
else: else:
raise Exception(f'Unknown boot image type {type}') raise Exception(f'Unknown boot image type {type}')
fastboot_erase_dtbo() fastboot_erase_dtbo()

View file

@ -5,7 +5,7 @@ from config import config
from wrapper import enforce_wrap from wrapper import enforce_wrap
import logging import logging
PATHS = ['chroots', 'pacman', 'jumpdrive', 'packages'] PATHS = ['chroots', 'pacman', 'jumpdrive', 'packages', 'images']
@click.group(name='cache') @click.group(name='cache')

View file

@ -44,6 +44,7 @@ CONFIG_DEFAULTS = {
'packages': os.path.join('%cache_dir%', 'packages'), 'packages': os.path.join('%cache_dir%', 'packages'),
'pkgbuilds': os.path.join('%cache_dir%', 'pkgbuilds'), 'pkgbuilds': os.path.join('%cache_dir%', 'pkgbuilds'),
'jumpdrive': os.path.join('%cache_dir%', 'jumpdrive'), 'jumpdrive': os.path.join('%cache_dir%', 'jumpdrive'),
'images': os.path.join('%cache_dir%', 'images'),
}, },
'profiles': { 'profiles': {
'current': 'default', 'current': 'default',

View file

@ -15,6 +15,7 @@ DOCKER_PATHS = {
'pacman': '/var/cache/pacman', 'pacman': '/var/cache/pacman',
'packages': '/prebuilts', 'packages': '/prebuilts',
'pkgbuilds': '/pkgbuilds', 'pkgbuilds': '/pkgbuilds',
'images': '/images',
} }