~postmarketos/pmbootstrap-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2

[PATCH pmbootstrap v2] flasher: heimdall-bootimg: add support for '--no-reboot' and '--resume'

Details
Message ID
<170534361606.26168.17672643433174186875-0@git.sr.ht>
DKIM signature
missing
Download raw message
Patch: +41 -5
From: Andras Sebok <sebokandris2009@gmail.com>

---
 pmb/config/__init__.py   | 11 +++++++----
 pmb/flasher/run.py       | 10 ++++++++++
 pmb/flasher/variables.py | 12 +++++++++++-
 pmb/parse/arguments.py   | 13 +++++++++++++
 4 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py
index fd75a00f..29557c98 100644
--- a/pmb/config/__init__.py
+++ b/pmb/config/__init__.py
@@ -998,20 +998,23 @@ flashers = {
            "list_devices": [["heimdall", "detect"]],
            "flash_rootfs": [
                ["heimdall_wait_for_device.sh"],
                ["heimdall", "flash", "--$PARTITION_ROOTFS", "$IMAGE"]],
                ["heimdall", "flash", "--$PARTITION_ROOTFS", "$IMAGE",
                 "$NO_REBOOT", "$RESUME"]],
            "flash_kernel": [
                ["heimdall_wait_for_device.sh"],
                ["heimdall", "flash", "--$PARTITION_KERNEL",
                 "$BOOT/boot.img$FLAVOR"]],
                 "$BOOT/boot.img$FLAVOR", "$NO_REBOOT", "$RESUME"]],
            "flash_vbmeta": [
                ["avbtool", "make_vbmeta_image", "--flags", "2",
                    "--padding_size", "$FLASH_PAGESIZE",
                    "--output", "/vbmeta.img"],
                ["heimdall", "flash", "--$PARTITION_VBMETA", "/vbmeta.img"],
                ["heimdall", "flash", "--$PARTITION_VBMETA", "/vbmeta.img",
                 "$NO_REBOOT", "$RESUME"],
                ["rm", "-f", "/vbmeta.img"]],
            "flash_lk2nd": [
                ["heimdall_wait_for_device.sh"],
                ["heimdall", "flash", "--$PARTITION_KERNEL", "$BOOT/lk2nd.img"]]
                ["heimdall", "flash", "--$PARTITION_KERNEL", "$BOOT/lk2nd.img",
                 "$NO_REBOOT", "$RESUME"]]
        },
    },
    "adb": {
diff --git a/pmb/flasher/run.py b/pmb/flasher/run.py
index 7daa7376..ad106f8a 100644
--- a/pmb/flasher/run.py
+++ b/pmb/flasher/run.py
@@ -50,6 +50,14 @@ def run(args, action, flavor=None):
                           " in deviceinfo file. See also:"
                           " <https://wiki.postmarketos.org/wiki/"
                           "Deviceinfo_reference>")
    
    if args.no_reboot and ("flash" not in action or method != "heimdall-bootimg"):
        raise RuntimeError("The '--no-reboot' option is only"
                           " supported when flashing with heimall-bootimg.")
    
    if args.resume and ("flash" not in action or method != "heimdall-bootimg"):
        raise RuntimeError("The '--resume' option is only"
                           " supported when flashing with heimall-bootimg.")

    # Run the commands of each action
    for command in cfg["actions"][action]:
@@ -66,5 +74,7 @@ def run(args, action, flavor=None):
                    check_partition_blacklist(args, key, value)
                    command[i] = command[i].replace(key, value)

        # Remove empty strings
        command = [x for x in command if x != '']
        # Run the action
        pmb.chroot.root(args, command, output="interactive")
diff --git a/pmb/flasher/variables.py b/pmb/flasher/variables.py
index 6fd5469a..393a1846 100644
--- a/pmb/flasher/variables.py
+++ b/pmb/flasher/variables.py
@@ -61,6 +61,14 @@ def variables(args, flavor, method):
    _dtb = ""
    if args.deviceinfo["append_dtb"] == "true":
        _dtb = "-dtb"
    
    _no_reboot = ""
    if args.no_reboot:
        _no_reboot = "--no-reboot"

    _resume = ""
    if args.resume:
        _resume = "--resume"

    vars = {
        "$BOOT": "/mnt/rootfs_" + args.device + "/boot",
@@ -80,7 +88,9 @@ def variables(args, flavor, method):
                         "/var/lib/postmarketos-android-recovery-installer"
                         "/pmos-" + args.device + ".zip",
        "$UUU_SCRIPT": "/mnt/rootfs_" + args.deviceinfo["codename"] +
                       "/usr/share/uuu/flash_script.lst"
                       "/usr/share/uuu/flash_script.lst",
        "$NO_REBOOT": _no_reboot,
        "$RESUME": _resume
    }

    # Backwards compatibility with old mkinitfs (pma#660)
diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py
index 47bd8c69..a8505258 100644
--- a/pmb/parse/arguments.py
+++ b/pmb/parse/arguments.py
@@ -289,6 +289,19 @@ def arguments_flasher(subparser):
                   " inside the device rootfs chroot on this computer")
    sub.add_parser("list_devices", help="show connected devices")

    group = ret.add_argument_group("heimdall options", \
                                   "With heimdall as"
                                   " flash method, the device automatically"
                                   " reboots after each flash command. Use"
                                   " --no-reboot and --resume for multiple"
                                   " flash actions without reboot.")
    group.add_argument("--no-reboot", dest="no_reboot",
                       help="don't automatically reboot after flashing",
                       action="store_true")
    group.add_argument("--resume", dest="resume",
                       help="resume flashing after using --no-reboot",
                       action="store_true")

    return ret


-- 
2.38.5
Details
Message ID
<CYGFUFG2K86U.2ZC1BCDW1EA7Y@postmarketos.org>
In-Reply-To
<170534361606.26168.17672643433174186875-0@git.sr.ht> (view parent)
DKIM signature
pass
Download raw message
On Mon Jan 15, 2024 at 6:27 PM UTC, ~andrisas wrote:
> From: Andras Sebok <sebokandris2009@gmail.com>

Thanks for the update, let's merge it!

Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>

>
> ---
>  pmb/config/__init__.py   | 11 +++++++----
>  pmb/flasher/run.py       | 10 ++++++++++
>  pmb/flasher/variables.py | 12 +++++++++++-
>  pmb/parse/arguments.py   | 13 +++++++++++++
>  4 files changed, 41 insertions(+), 5 deletions(-)
>
> diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py
> index fd75a00f..29557c98 100644
> --- a/pmb/config/__init__.py
> +++ b/pmb/config/__init__.py
> @@ -998,20 +998,23 @@ flashers = {
>              "list_devices": [["heimdall", "detect"]],
>              "flash_rootfs": [
>                  ["heimdall_wait_for_device.sh"],
> -                ["heimdall", "flash", "--$PARTITION_ROOTFS", "$IMAGE"]],
> +                ["heimdall", "flash", "--$PARTITION_ROOTFS", "$IMAGE",
> +                 "$NO_REBOOT", "$RESUME"]],
>              "flash_kernel": [
>                  ["heimdall_wait_for_device.sh"],
>                  ["heimdall", "flash", "--$PARTITION_KERNEL",
> -                 "$BOOT/boot.img$FLAVOR"]],
> +                 "$BOOT/boot.img$FLAVOR", "$NO_REBOOT", "$RESUME"]],
>              "flash_vbmeta": [
>                  ["avbtool", "make_vbmeta_image", "--flags", "2",
>                      "--padding_size", "$FLASH_PAGESIZE",
>                      "--output", "/vbmeta.img"],
> -                ["heimdall", "flash", "--$PARTITION_VBMETA", "/vbmeta.img"],
> +                ["heimdall", "flash", "--$PARTITION_VBMETA", "/vbmeta.img",
> +                 "$NO_REBOOT", "$RESUME"],
>                  ["rm", "-f", "/vbmeta.img"]],
>              "flash_lk2nd": [
>                  ["heimdall_wait_for_device.sh"],
> -                ["heimdall", "flash", "--$PARTITION_KERNEL", "$BOOT/lk2nd.img"]]
> +                ["heimdall", "flash", "--$PARTITION_KERNEL", "$BOOT/lk2nd.img",
> +                 "$NO_REBOOT", "$RESUME"]]
>          },
>      },
>      "adb": {
> diff --git a/pmb/flasher/run.py b/pmb/flasher/run.py
> index 7daa7376..ad106f8a 100644
> --- a/pmb/flasher/run.py
> +++ b/pmb/flasher/run.py
> @@ -50,6 +50,14 @@ def run(args, action, flavor=None):
>                             " in deviceinfo file. See also:"
>                             " <https://wiki.postmarketos.org/wiki/"
>                             "Deviceinfo_reference>")
> +    
> +    if args.no_reboot and ("flash" not in action or method != "heimdall-bootimg"):
> +        raise RuntimeError("The '--no-reboot' option is only"
> +                           " supported when flashing with heimall-bootimg.")
> +    
> +    if args.resume and ("flash" not in action or method != "heimdall-bootimg"):
> +        raise RuntimeError("The '--resume' option is only"
> +                           " supported when flashing with heimall-bootimg.")
>  
>      # Run the commands of each action
>      for command in cfg["actions"][action]:
> @@ -66,5 +74,7 @@ def run(args, action, flavor=None):
>                      check_partition_blacklist(args, key, value)
>                      command[i] = command[i].replace(key, value)
>  
> +        # Remove empty strings
> +        command = [x for x in command if x != '']
>          # Run the action
>          pmb.chroot.root(args, command, output="interactive")
> diff --git a/pmb/flasher/variables.py b/pmb/flasher/variables.py
> index 6fd5469a..393a1846 100644
> --- a/pmb/flasher/variables.py
> +++ b/pmb/flasher/variables.py
> @@ -61,6 +61,14 @@ def variables(args, flavor, method):
>      _dtb = ""
>      if args.deviceinfo["append_dtb"] == "true":
>          _dtb = "-dtb"
> +    
> +    _no_reboot = ""
> +    if args.no_reboot:
> +        _no_reboot = "--no-reboot"
> +
> +    _resume = ""
> +    if args.resume:
> +        _resume = "--resume"
>  
>      vars = {
>          "$BOOT": "/mnt/rootfs_" + args.device + "/boot",
> @@ -80,7 +88,9 @@ def variables(args, flavor, method):
>                           "/var/lib/postmarketos-android-recovery-installer"
>                           "/pmos-" + args.device + ".zip",
>          "$UUU_SCRIPT": "/mnt/rootfs_" + args.deviceinfo["codename"] +
> -                       "/usr/share/uuu/flash_script.lst"
> +                       "/usr/share/uuu/flash_script.lst",
> +        "$NO_REBOOT": _no_reboot,
> +        "$RESUME": _resume
>      }
>  
>      # Backwards compatibility with old mkinitfs (pma#660)
> diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py
> index 47bd8c69..a8505258 100644
> --- a/pmb/parse/arguments.py
> +++ b/pmb/parse/arguments.py
> @@ -289,6 +289,19 @@ def arguments_flasher(subparser):
>                     " inside the device rootfs chroot on this computer")
>      sub.add_parser("list_devices", help="show connected devices")
>  
> +    group = ret.add_argument_group("heimdall options", \
> +                                   "With heimdall as"
> +                                   " flash method, the device automatically"
> +                                   " reboots after each flash command. Use"
> +                                   " --no-reboot and --resume for multiple"
> +                                   " flash actions without reboot.")
> +    group.add_argument("--no-reboot", dest="no_reboot",
> +                       help="don't automatically reboot after flashing",
> +                       action="store_true")
> +    group.add_argument("--resume", dest="resume",
> +                       help="resume flashing after using --no-reboot",
> +                       action="store_true")
> +
>      return ret
>  
>  
Details
Message ID
<170543980683.2391.7704691801895035241.b4-ty@postmarketos.org>
In-Reply-To
<170534361606.26168.17672643433174186875-0@git.sr.ht> (view parent)
DKIM signature
pass
Download raw message
On Mon, 15 Jan 2024 19:27:57 +0100, ~andrisas wrote:
> 


Applied, thanks!

[1/1] flasher: heimdall-bootimg: add support for '--no-reboot' and '--resume'
      commit: e0e3e213ba24720afa431b13f0f878c6fd9dd108

Best regards,
-- 
Oliver Smith <ollieparanoid@postmarketos.org>
Reply to thread Export thread (mbox)