M pmb/flasher/frontend.py => pmb/flasher/frontend.py +7 -0
@@ 151,3 151,10 @@ def frontend(args):
sideload(args)
if action in ["flash_lk2nd"]:
flash_lk2nd(args)
+
+ extra = args.action_extra
+ if extra and "fastboot" in method and action != "boot":
+ logging.info(extra)
+ cmd = ["fastboot"]
+ cmd += extra
+ pmb.chroot.root(args, ["fastboot"] + extra, output="interactive")
M pmb/flasher/run.py => pmb/flasher/run.py +28 -20
@@ 15,41 15,41 @@ def check_partition_blacklist(args, key, value):
"wiki page for more information.")
-def run(args, action, flavor=None):
+def _run(args, action, flavor=None):
pmb.flasher.init(args)
# Verify action
method = args.flash_method or args.deviceinfo["flash_method"]
cfg = pmb.config.flashers[method]
if action not in cfg["actions"]:
- raise RuntimeError("action " + action + " is not"
- " configured for method " + method + "!"
- " You can use the '--method' option to specify a"
- " different flash method. See also:"
- " <https://wiki.postmarketos.org/wiki/"
- "Deviceinfo_flash_methods>")
+ raise ValueError("action " + action + " is not"
+ " configured for method " + method + "!"
+ " You can use the '--method' option to specify a"
+ " different flash method. See also:"
+ " <https://wiki.postmarketos.org/wiki/"
+ "Deviceinfo_flash_methods>")
# Variable setup
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'"
- " or 'deviceinfo_flash_heimdall_partition_vbmeta'"
- " in deviceinfo file. See also:"
- " <https://wiki.postmarketos.org/wiki/"
- "Deviceinfo_reference>")
+ raise ValueError("Your device does not have 'vbmeta' partition"
+ " specified; set"
+ " 'deviceinfo_flash_fastboot_partition_vbmeta'"
+ " or 'deviceinfo_flash_heimdall_partition_vbmeta'"
+ " in deviceinfo file. See also:"
+ " <https://wiki.postmarketos.org/wiki/"
+ "Deviceinfo_reference>")
# dtbo flasher requires dtbo partition to be explicitly specified
if action == "flash_dtbo" and not vars["$PARTITION_DTBO"]:
- raise RuntimeError("Your device does not have 'dtbo' partition"
- " specified; set"
- " 'deviceinfo_flash_fastboot_partition_dtbo'"
- " in deviceinfo file. See also:"
- " <https://wiki.postmarketos.org/wiki/"
- "Deviceinfo_reference>")
+ raise ValueError("Your device does not have 'dtbo' partition"
+ " specified; set"
+ " 'deviceinfo_flash_fastboot_partition_dtbo'"
+ " in deviceinfo file. See also:"
+ " <https://wiki.postmarketos.org/wiki/"
+ "Deviceinfo_reference>")
# Run the commands of each action
for command in cfg["actions"][action]:
@@ 68,3 68,11 @@ def run(args, action, flavor=None):
# Run the action
pmb.chroot.root(args, command, output="interactive")
+
+
+def run(args, action, flavor=None, ignore_errors=False):
+ try:
+ _run(args, action, flavor)
+ except ValueError as e:
+ if not ignore_errors:
+ raise ValueError(e)
M pmb/parse/arguments.py => pmb/parse/arguments.py +9 -0
@@ 277,6 277,15 @@ def arguments_flasher(subparser):
help="partition to flash the dtbo to (defaults"
" to deviceinfo_flash_*_partition_dtbo)")
+ for action in [flash_kernel, flash_lk2nd, flash_rootfs,
+ flash_vbmeta, flash_dtbo]:
+ extra = action.add_argument(dest="action_extra",
+ metavar="EXTRA",
+ help="Additional commands to flasher"
+ " (only fastboot supported)",
+ nargs="*")
+ extra.required = False
+
# Actions without extra arguments
sub.add_parser("sideload", help="sideload recovery zip")
sub.add_parser("list_flavors", help="list installed kernel flavors" +