forked from Mirror/pmbootstrap
add "flasher flash_vbmeta" command (!1885)
Flashes device vbmeta partition (can be overriden with "flash_fastboot_partition_vbmeta" setting in deviceinfo) with custom vbmeta.img which has verity flag disabled, so device can boot postmarketOS with no problems.
This commit is contained in:
parent
45f5ace1c2
commit
e6da56d9b0
5 changed files with 42 additions and 2 deletions
|
@ -273,6 +273,7 @@ deviceinfo_attributes = [
|
||||||
"flash_heimdall_partition_system",
|
"flash_heimdall_partition_system",
|
||||||
"flash_fastboot_partition_kernel",
|
"flash_fastboot_partition_kernel",
|
||||||
"flash_fastboot_partition_system",
|
"flash_fastboot_partition_system",
|
||||||
|
"flash_fastboot_partition_vbmeta",
|
||||||
"generate_legacy_uboot_initfs",
|
"generate_legacy_uboot_initfs",
|
||||||
"kernel_cmdline",
|
"kernel_cmdline",
|
||||||
"generate_bootimg",
|
"generate_bootimg",
|
||||||
|
@ -351,13 +352,21 @@ uuu specific: $UUU_SCRIPT
|
||||||
"""
|
"""
|
||||||
flashers = {
|
flashers = {
|
||||||
"fastboot": {
|
"fastboot": {
|
||||||
"depends": ["android-tools"],
|
"depends": ["android-tools", "avbtool"],
|
||||||
"actions": {
|
"actions": {
|
||||||
"list_devices": [["fastboot", "devices", "-l"]],
|
"list_devices": [["fastboot", "devices", "-l"]],
|
||||||
"flash_rootfs": [["fastboot", "flash", "$PARTITION_SYSTEM",
|
"flash_rootfs": [["fastboot", "flash", "$PARTITION_SYSTEM",
|
||||||
"$IMAGE"]],
|
"$IMAGE"]],
|
||||||
"flash_kernel": [["fastboot", "flash", "$PARTITION_KERNEL",
|
"flash_kernel": [["fastboot", "flash", "$PARTITION_KERNEL",
|
||||||
"$BOOT/boot.img-$FLAVOR"]],
|
"$BOOT/boot.img-$FLAVOR"]],
|
||||||
|
"flash_vbmeta": [
|
||||||
|
# Generate vbmeta image with "disable verification" flag
|
||||||
|
["avbtool", "make_vbmeta_image", "--flags", "2",
|
||||||
|
"--padding_size", "$FLASH_PAGESIZE",
|
||||||
|
"--output", "/vbmeta.img"],
|
||||||
|
["fastboot", "flash", "$PARTITION_VBMETA", "/vbmeta.img"],
|
||||||
|
["rm", "-f", "/vbmeta.img"]
|
||||||
|
],
|
||||||
"boot": [["fastboot", "--cmdline", "$KERNEL_CMDLINE",
|
"boot": [["fastboot", "--cmdline", "$KERNEL_CMDLINE",
|
||||||
"boot", "$BOOT/boot.img-$FLAVOR"]],
|
"boot", "$BOOT/boot.img-$FLAVOR"]],
|
||||||
},
|
},
|
||||||
|
|
|
@ -70,6 +70,11 @@ def rootfs(args):
|
||||||
pmb.flasher.run(args, "flash_rootfs")
|
pmb.flasher.run(args, "flash_rootfs")
|
||||||
|
|
||||||
|
|
||||||
|
def flash_vbmeta(args):
|
||||||
|
logging.info("(native) flash vbmeta.img with verity disabled flag")
|
||||||
|
pmb.flasher.run(args, "flash_vbmeta")
|
||||||
|
|
||||||
|
|
||||||
def list_devices(args):
|
def list_devices(args):
|
||||||
pmb.flasher.run(args, "list_devices")
|
pmb.flasher.run(args, "list_devices")
|
||||||
|
|
||||||
|
@ -115,6 +120,8 @@ def frontend(args):
|
||||||
kernel(args)
|
kernel(args)
|
||||||
if action == "flash_rootfs":
|
if action == "flash_rootfs":
|
||||||
rootfs(args)
|
rootfs(args)
|
||||||
|
if action == "flash_vbmeta":
|
||||||
|
flash_vbmeta(args)
|
||||||
if action == "list_flavors":
|
if action == "list_flavors":
|
||||||
list_flavors(args)
|
list_flavors(args)
|
||||||
if action == "list_devices":
|
if action == "list_devices":
|
||||||
|
|
|
@ -32,6 +32,15 @@ def run(args, action, flavor=None):
|
||||||
# Variable setup
|
# Variable setup
|
||||||
vars = pmb.flasher.variables(args, flavor, method)
|
vars = pmb.flasher.variables(args, flavor, method)
|
||||||
|
|
||||||
|
# vbmeta flasher requires vbmeta partition to be explicitly specified
|
||||||
|
if action == "flash_vbmeta" and not vars["$PARTITION_VBMETA"]:
|
||||||
|
raise RuntimeError("Your device does not have 'vbmeta' partition"
|
||||||
|
" specified; set"
|
||||||
|
" 'deviceinfo_flash_fastboot_partition_vbmeta'"
|
||||||
|
" in deviceinfo file. See also:"
|
||||||
|
" <https://wiki.postmarketos.org/wiki/"
|
||||||
|
"Deviceinfo_reference>")
|
||||||
|
|
||||||
# Run the commands of each action
|
# Run the commands of each action
|
||||||
for command in cfg["actions"][action]:
|
for command in cfg["actions"][action]:
|
||||||
# Variable replacement
|
# Variable replacement
|
||||||
|
|
|
@ -7,17 +7,21 @@ def variables(args, flavor, method):
|
||||||
if "cmdline" in args and args.cmdline:
|
if "cmdline" in args and args.cmdline:
|
||||||
_cmdline = args.cmdline
|
_cmdline = args.cmdline
|
||||||
|
|
||||||
|
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"] or "boot"
|
||||||
_partition_system = args.deviceinfo["flash_fastboot_partition_system"] or "system"
|
_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"] or "KERNEL"
|
||||||
_partition_system = args.deviceinfo["flash_heimdall_partition_system"] or "SYSTEM"
|
_partition_system = args.deviceinfo["flash_heimdall_partition_system"] or "SYSTEM"
|
||||||
|
|
||||||
if "partition" in args and args.partition:
|
if "partition" in args and args.partition:
|
||||||
# Only one of two 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
|
||||||
|
|
||||||
vars = {
|
vars = {
|
||||||
"$BOOT": "/mnt/rootfs_" + args.device + "/boot",
|
"$BOOT": "/mnt/rootfs_" + args.device + "/boot",
|
||||||
|
@ -29,6 +33,8 @@ def variables(args, flavor, method):
|
||||||
"$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,
|
||||||
|
"$FLASH_PAGESIZE": flash_pagesize,
|
||||||
"$RECOVERY_ZIP": "/mnt/buildroot_" + args.deviceinfo["arch"] +
|
"$RECOVERY_ZIP": "/mnt/buildroot_" + args.deviceinfo["arch"] +
|
||||||
"/var/lib/postmarketos-android-recovery-installer"
|
"/var/lib/postmarketos-android-recovery-installer"
|
||||||
"/pmos-" + args.device + ".zip",
|
"/pmos-" + args.device + ".zip",
|
||||||
|
|
|
@ -70,6 +70,15 @@ def arguments_flasher(subparser):
|
||||||
" 'userdata' on Android may have more"
|
" 'userdata' on Android may have more"
|
||||||
" space)")
|
" space)")
|
||||||
|
|
||||||
|
# Flash vbmeta
|
||||||
|
flash_vbmeta = sub.add_parser("flash_vbmeta",
|
||||||
|
help="generate and flash AVB 2.0 image with disable"
|
||||||
|
" verification flag set to a partition on the"
|
||||||
|
" device (typically called vbmeta)")
|
||||||
|
flash_vbmeta.add_argument("--partition", default=None,
|
||||||
|
help="partition to flash the vbmeta to (defaults"
|
||||||
|
" to deviceinfo_flash_*_partition_vbmeta")
|
||||||
|
|
||||||
# Actions without extra arguments
|
# Actions without extra arguments
|
||||||
sub.add_parser("sideload", help="sideload recovery zip")
|
sub.add_parser("sideload", help="sideload recovery zip")
|
||||||
sub.add_parser("list_flavors", help="list installed kernel flavors" +
|
sub.add_parser("list_flavors", help="list installed kernel flavors" +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue