forked from Mirror/pmbootstrap
enforce E501 in pmb/flasher (MR 2058)
This commit is contained in:
parent
aaece05bb7
commit
cfa5bc2cf7
4 changed files with 37 additions and 22 deletions
|
@ -31,10 +31,12 @@ def kernel(args):
|
||||||
pmb.flasher.run(args, "flash_kernel", flavor)
|
pmb.flasher.run(args, "flash_kernel", flavor)
|
||||||
logging.info("You will get an IP automatically assigned to your "
|
logging.info("You will get an IP automatically assigned to your "
|
||||||
"USB interface shortly.")
|
"USB interface shortly.")
|
||||||
logging.info("Then you can connect to your device using ssh after pmOS has booted:")
|
logging.info("Then you can connect to your device using ssh after pmOS has"
|
||||||
|
" booted:")
|
||||||
logging.info("ssh {}@{}".format(args.user, pmb.config.default_ip))
|
logging.info("ssh {}@{}".format(args.user, pmb.config.default_ip))
|
||||||
logging.info("NOTE: If you enabled full disk encryption, you should make sure that"
|
logging.info("NOTE: If you enabled full disk encryption, you should make"
|
||||||
" osk-sdl has been properly configured for your device")
|
" sure that osk-sdl has been properly configured for your"
|
||||||
|
" device")
|
||||||
|
|
||||||
|
|
||||||
def list_flavors(args):
|
def list_flavors(args):
|
||||||
|
@ -52,13 +54,15 @@ def rootfs(args):
|
||||||
if pmb.config.flashers.get(method, {}).get("split", False):
|
if pmb.config.flashers.get(method, {}).get("split", False):
|
||||||
suffix = "-root.img"
|
suffix = "-root.img"
|
||||||
|
|
||||||
img_path = args.work + "/chroot_native/home/pmos/rootfs/" + args.device + suffix
|
img_path = f"{args.work}/chroot_native/home/pmos/rootfs/{args.device}"\
|
||||||
|
f"{suffix}"
|
||||||
if not os.path.exists(img_path):
|
if not os.path.exists(img_path):
|
||||||
raise RuntimeError("The rootfs has not been generated yet, please run"
|
raise RuntimeError("The rootfs has not been generated yet, please run"
|
||||||
" 'pmbootstrap install' first.")
|
" 'pmbootstrap install' first.")
|
||||||
|
|
||||||
# Do not flash if using fastboot & image is too large
|
# Do not flash if using fastboot & image is too large
|
||||||
if method.startswith("fastboot") and args.deviceinfo["flash_fastboot_max_size"]:
|
if method.startswith("fastboot") \
|
||||||
|
and args.deviceinfo["flash_fastboot_max_size"]:
|
||||||
img_size = os.path.getsize(img_path) / 1024**2
|
img_size = os.path.getsize(img_path) / 1024**2
|
||||||
max_size = int(args.deviceinfo["flash_fastboot_max_size"])
|
max_size = int(args.deviceinfo["flash_fastboot_max_size"])
|
||||||
if img_size > max_size:
|
if img_size > max_size:
|
||||||
|
|
|
@ -13,11 +13,13 @@ def init(args):
|
||||||
method = args.deviceinfo["flash_method"]
|
method = args.deviceinfo["flash_method"]
|
||||||
|
|
||||||
if method not in pmb.config.flashers:
|
if method not in pmb.config.flashers:
|
||||||
raise RuntimeError("Flash method " + method + " is not supported by the"
|
raise RuntimeError(f"Flash method {method} is not supported by the"
|
||||||
" current configuration. However, adding a new flash method is "
|
" current configuration. However, adding a new"
|
||||||
" not that hard, when the flashing application already exists.\n"
|
" flash method is not that hard, when the flashing"
|
||||||
"Make sure, it is packaged for Alpine Linux, or package it "
|
" application already exists.\n"
|
||||||
" yourself, and then add it to pmb/config/__init__.py.")
|
"Make sure, it is packaged for Alpine Linux, or"
|
||||||
|
" package it yourself, and then add it to"
|
||||||
|
" pmb/config/__init__.py.")
|
||||||
cfg = pmb.config.flashers[method]
|
cfg = pmb.config.flashers[method]
|
||||||
|
|
||||||
# Install depends
|
# Install depends
|
||||||
|
|
|
@ -49,10 +49,11 @@ def run(args, action, flavor=None):
|
||||||
for i in range(len(command)):
|
for i in range(len(command)):
|
||||||
if key in command[i]:
|
if key in command[i]:
|
||||||
if value is None:
|
if value is None:
|
||||||
raise RuntimeError("Variable " + key + " found in"
|
raise RuntimeError(f"Variable {key} found in action"
|
||||||
" action " + action + " for method " + method + ","
|
f" {action} for method {method},"
|
||||||
" but the value for this variable is None! Is that"
|
" but the value for this variable"
|
||||||
" missing in your deviceinfo?")
|
" is None! Is that missing in your"
|
||||||
|
" deviceinfo?")
|
||||||
check_partition_blacklist(args, key, value)
|
check_partition_blacklist(args, key, value)
|
||||||
command[i] = command[i].replace(key, value)
|
command[i] = command[i].replace(key, value)
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,23 @@ def variables(args, flavor, method):
|
||||||
flash_pagesize = args.deviceinfo['flash_pagesize']
|
flash_pagesize = args.deviceinfo['flash_pagesize']
|
||||||
|
|
||||||
if method.startswith("fastboot"):
|
if method.startswith("fastboot"):
|
||||||
_partition_kernel = args.deviceinfo["flash_fastboot_partition_kernel"] or "boot"
|
_partition_kernel = args.deviceinfo["flash_fastboot_partition_kernel"]\
|
||||||
_partition_system = args.deviceinfo["flash_fastboot_partition_system"] or "system"
|
or "boot"
|
||||||
_partition_vbmeta = args.deviceinfo["flash_fastboot_partition_vbmeta"] or None
|
_partition_system = args.deviceinfo["flash_fastboot_partition_system"]\
|
||||||
|
or "system"
|
||||||
|
_partition_vbmeta = args.deviceinfo["flash_fastboot_partition_vbmeta"]\
|
||||||
|
or None
|
||||||
else:
|
else:
|
||||||
_partition_kernel = args.deviceinfo["flash_heimdall_partition_kernel"] or "KERNEL"
|
_partition_kernel = args.deviceinfo["flash_heimdall_partition_kernel"]\
|
||||||
_partition_system = args.deviceinfo["flash_heimdall_partition_system"] or "SYSTEM"
|
or "KERNEL"
|
||||||
_partition_vbmeta = args.deviceinfo["flash_heimdall_partition_vbmeta"] or None
|
_partition_system = args.deviceinfo["flash_heimdall_partition_system"]\
|
||||||
|
or "SYSTEM"
|
||||||
|
_partition_vbmeta = args.deviceinfo["flash_heimdall_partition_vbmeta"]\
|
||||||
|
or None
|
||||||
|
|
||||||
if "partition" in args and args.partition:
|
if "partition" in args and args.partition:
|
||||||
# Only one of operations is done at same time so it doesn't matter sharing the arg
|
# Only one of operations is done at same time so it doesn't matter
|
||||||
|
# sharing the arg
|
||||||
_partition_kernel = args.partition
|
_partition_kernel = args.partition
|
||||||
_partition_system = args.partition
|
_partition_system = args.partition
|
||||||
_partition_vbmeta = args.partition
|
_partition_vbmeta = args.partition
|
||||||
|
@ -37,7 +44,8 @@ def variables(args, flavor, method):
|
||||||
"$IMAGE": "/home/pmos/rootfs/" + args.device + ".img",
|
"$IMAGE": "/home/pmos/rootfs/" + args.device + ".img",
|
||||||
"$KERNEL_CMDLINE": _cmdline,
|
"$KERNEL_CMDLINE": _cmdline,
|
||||||
"$PARTITION_KERNEL": _partition_kernel,
|
"$PARTITION_KERNEL": _partition_kernel,
|
||||||
"$PARTITION_INITFS": args.deviceinfo["flash_heimdall_partition_initfs"] or "RECOVERY",
|
"$PARTITION_INITFS": args.deviceinfo[
|
||||||
|
"flash_heimdall_partition_initfs"] or "RECOVERY",
|
||||||
"$PARTITION_SYSTEM": _partition_system,
|
"$PARTITION_SYSTEM": _partition_system,
|
||||||
"$PARTITION_VBMETA": _partition_vbmeta,
|
"$PARTITION_VBMETA": _partition_vbmeta,
|
||||||
"$FLASH_PAGESIZE": flash_pagesize,
|
"$FLASH_PAGESIZE": flash_pagesize,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue