2022-01-02 21:38:21 +00:00
|
|
|
# Copyright 2022 Oliver Smith
|
2020-02-20 20:07:28 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2021-08-19 01:39:08 +00:00
|
|
|
import pmb.config.pmaports
|
2017-09-28 22:05:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
def variables(args, flavor, method):
|
2020-10-27 16:03:04 +00:00
|
|
|
_cmdline = args.deviceinfo["kernel_cmdline"] or ""
|
2017-09-28 22:05:00 +00:00
|
|
|
if "cmdline" in args and args.cmdline:
|
|
|
|
_cmdline = args.cmdline
|
|
|
|
|
2020-03-03 23:51:25 +00:00
|
|
|
flash_pagesize = args.deviceinfo['flash_pagesize']
|
|
|
|
|
2020-02-04 10:30:28 +00:00
|
|
|
if method.startswith("fastboot"):
|
2021-05-19 18:55:40 +00:00
|
|
|
_partition_kernel = args.deviceinfo["flash_fastboot_partition_kernel"]\
|
|
|
|
or "boot"
|
|
|
|
_partition_system = args.deviceinfo["flash_fastboot_partition_system"]\
|
|
|
|
or "system"
|
|
|
|
_partition_vbmeta = args.deviceinfo["flash_fastboot_partition_vbmeta"]\
|
|
|
|
or None
|
2021-08-27 16:35:46 +00:00
|
|
|
_partition_dtbo = args.deviceinfo["flash_fastboot_partition_dtbo"]\
|
|
|
|
or None
|
2017-09-28 22:05:00 +00:00
|
|
|
else:
|
2021-05-19 18:55:40 +00:00
|
|
|
_partition_kernel = args.deviceinfo["flash_heimdall_partition_kernel"]\
|
|
|
|
or "KERNEL"
|
|
|
|
_partition_system = args.deviceinfo["flash_heimdall_partition_system"]\
|
|
|
|
or "SYSTEM"
|
|
|
|
_partition_vbmeta = args.deviceinfo["flash_heimdall_partition_vbmeta"]\
|
|
|
|
or None
|
2021-08-27 16:35:46 +00:00
|
|
|
_partition_dtbo = args.deviceinfo["flash_heimdall_partition_dtbo"]\
|
|
|
|
or None
|
2019-01-18 19:01:03 +00:00
|
|
|
|
2017-09-28 22:05:00 +00:00
|
|
|
if "partition" in args and args.partition:
|
2021-08-27 16:35:46 +00:00
|
|
|
# Only one operation is done at same time so it doesn't matter
|
2021-05-19 18:55:40 +00:00
|
|
|
# sharing the arg
|
2019-01-18 19:01:03 +00:00
|
|
|
_partition_kernel = args.partition
|
2017-09-28 22:05:00 +00:00
|
|
|
_partition_system = args.partition
|
2020-03-03 23:51:25 +00:00
|
|
|
_partition_vbmeta = args.partition
|
2021-08-27 16:35:46 +00:00
|
|
|
_partition_dtbo = args.partition
|
2017-09-28 22:05:00 +00:00
|
|
|
|
2020-10-26 11:42:10 +00:00
|
|
|
_dtb = ""
|
|
|
|
if args.deviceinfo["append_dtb"] == "true":
|
|
|
|
_dtb = "-dtb"
|
|
|
|
|
2017-09-28 22:05:00 +00:00
|
|
|
vars = {
|
|
|
|
"$BOOT": "/mnt/rootfs_" + args.device + "/boot",
|
2020-10-26 11:42:10 +00:00
|
|
|
"$DTB": _dtb,
|
2020-02-04 10:30:28 +00:00
|
|
|
"$IMAGE_SPLIT_BOOT": "/home/pmos/rootfs/" + args.device + "-boot.img",
|
|
|
|
"$IMAGE_SPLIT_ROOT": "/home/pmos/rootfs/" + args.device + "-root.img",
|
2017-10-12 20:08:10 +00:00
|
|
|
"$IMAGE": "/home/pmos/rootfs/" + args.device + ".img",
|
2017-09-28 22:05:00 +00:00
|
|
|
"$KERNEL_CMDLINE": _cmdline,
|
2019-01-18 19:01:03 +00:00
|
|
|
"$PARTITION_KERNEL": _partition_kernel,
|
2021-05-19 18:55:40 +00:00
|
|
|
"$PARTITION_INITFS": args.deviceinfo[
|
|
|
|
"flash_heimdall_partition_initfs"] or "RECOVERY",
|
2017-09-28 22:05:00 +00:00
|
|
|
"$PARTITION_SYSTEM": _partition_system,
|
2020-03-03 23:51:25 +00:00
|
|
|
"$PARTITION_VBMETA": _partition_vbmeta,
|
2021-08-27 16:35:46 +00:00
|
|
|
"$PARTITION_DTBO": _partition_dtbo,
|
2020-03-03 23:51:25 +00:00
|
|
|
"$FLASH_PAGESIZE": flash_pagesize,
|
2017-09-28 22:05:00 +00:00
|
|
|
"$RECOVERY_ZIP": "/mnt/buildroot_" + args.deviceinfo["arch"] +
|
|
|
|
"/var/lib/postmarketos-android-recovery-installer"
|
|
|
|
"/pmos-" + args.device + ".zip",
|
2019-03-02 18:10:35 +00:00
|
|
|
"$UUU_SCRIPT": "/mnt/rootfs_" + args.deviceinfo["codename"] +
|
|
|
|
"/usr/share/uuu/flash_script.lst"
|
2017-09-28 22:05:00 +00:00
|
|
|
}
|
|
|
|
|
2021-08-19 01:39:08 +00:00
|
|
|
# Backwards compatibility with old mkinitfs (pma#660)
|
|
|
|
pmaports_cfg = pmb.config.pmaports.read_config(args)
|
|
|
|
if pmaports_cfg.get("supported_mkinitfs_without_flavors", False):
|
|
|
|
vars["$FLAVOR"] = ""
|
|
|
|
else:
|
|
|
|
vars["$FLAVOR"] = f"-{flavor}" if flavor is not None else "-"
|
|
|
|
|
2017-09-28 22:05:00 +00:00
|
|
|
return vars
|