forked from Mirror/pmbootstrap
pmb.flasher: Fix passing command line flags (MR 2543)
Commit 37ec73c
dropped the use of args to access command line arguments,
but did not add another way to pass command line arguments; thus,
optional flags to flash_kernel, flash_rootfs, flash_lk2nd, sideload and
list_devices were ignored.
Fix this by making sure the relevant arguments are passed for all
frontend methods.
Fixes #2522.
This commit is contained in:
parent
b5f14e2b94
commit
00c670ffda
2 changed files with 128 additions and 14 deletions
|
@ -40,9 +40,25 @@ class Flasher(commands.Command):
|
||||||
return
|
return
|
||||||
|
|
||||||
if action in ["boot", "flash_kernel"]:
|
if action in ["boot", "flash_kernel"]:
|
||||||
kernel(deviceinfo, method, action == "boot", self.autoinstall)
|
kernel(
|
||||||
|
deviceinfo,
|
||||||
|
method,
|
||||||
|
action == "boot",
|
||||||
|
self.autoinstall,
|
||||||
|
cmdline=self.cmdline,
|
||||||
|
no_reboot=self.no_reboot,
|
||||||
|
partition=self.partition,
|
||||||
|
resume=self.resume,
|
||||||
|
)
|
||||||
elif action == "flash_rootfs":
|
elif action == "flash_rootfs":
|
||||||
rootfs(deviceinfo, method)
|
rootfs(
|
||||||
|
deviceinfo,
|
||||||
|
method,
|
||||||
|
cmdline=self.cmdline,
|
||||||
|
no_reboot=self.no_reboot,
|
||||||
|
partition=self.partition,
|
||||||
|
resume=self.resume,
|
||||||
|
)
|
||||||
elif action == "flash_vbmeta":
|
elif action == "flash_vbmeta":
|
||||||
logging.info("(native) flash vbmeta.img with verity disabled flag")
|
logging.info("(native) flash vbmeta.img with verity disabled flag")
|
||||||
pmb.flasher.run(
|
pmb.flasher.run(
|
||||||
|
@ -66,7 +82,14 @@ class Flasher(commands.Command):
|
||||||
resume=self.resume,
|
resume=self.resume,
|
||||||
)
|
)
|
||||||
elif action == "flash_lk2nd":
|
elif action == "flash_lk2nd":
|
||||||
flash_lk2nd(deviceinfo, method)
|
flash_lk2nd(
|
||||||
|
deviceinfo,
|
||||||
|
method,
|
||||||
|
cmdline=self.cmdline,
|
||||||
|
no_reboot=self.no_reboot,
|
||||||
|
partition=self.partition,
|
||||||
|
resume=self.resume,
|
||||||
|
)
|
||||||
elif action == "list_flavors":
|
elif action == "list_flavors":
|
||||||
list_flavors(device)
|
list_flavors(device)
|
||||||
elif action == "list_devices":
|
elif action == "list_devices":
|
||||||
|
@ -80,4 +103,11 @@ class Flasher(commands.Command):
|
||||||
resume=self.resume,
|
resume=self.resume,
|
||||||
)
|
)
|
||||||
elif action == "sideload":
|
elif action == "sideload":
|
||||||
sideload(deviceinfo, method)
|
sideload(
|
||||||
|
deviceinfo,
|
||||||
|
method,
|
||||||
|
cmdline=self.cmdline,
|
||||||
|
no_reboot=self.no_reboot,
|
||||||
|
partition=self.partition,
|
||||||
|
resume=self.resume,
|
||||||
|
)
|
||||||
|
|
|
@ -23,6 +23,10 @@ def kernel(
|
||||||
method: str,
|
method: str,
|
||||||
boot: bool = False,
|
boot: bool = False,
|
||||||
autoinstall: bool = False,
|
autoinstall: bool = False,
|
||||||
|
cmdline: str | None = None,
|
||||||
|
no_reboot: bool | None = None,
|
||||||
|
partition: str | None = None,
|
||||||
|
resume: bool | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
# Rebuild the initramfs, just to make sure (see #69)
|
# Rebuild the initramfs, just to make sure (see #69)
|
||||||
flavor = pmb.helpers.frontend._parse_flavor(deviceinfo.codename, autoinstall)
|
flavor = pmb.helpers.frontend._parse_flavor(deviceinfo.codename, autoinstall)
|
||||||
|
@ -35,10 +39,28 @@ def kernel(
|
||||||
# Generate the paths and run the flasher
|
# Generate the paths and run the flasher
|
||||||
if boot:
|
if boot:
|
||||||
logging.info("(native) boot " + flavor + " kernel")
|
logging.info("(native) boot " + flavor + " kernel")
|
||||||
pmb.flasher.run(deviceinfo, method, "boot", flavor)
|
pmb.flasher.run(
|
||||||
|
deviceinfo,
|
||||||
|
method,
|
||||||
|
"boot",
|
||||||
|
flavor,
|
||||||
|
cmdline=cmdline,
|
||||||
|
no_reboot=no_reboot,
|
||||||
|
partition=partition,
|
||||||
|
resume=resume,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
logging.info("(native) flash kernel " + flavor)
|
logging.info("(native) flash kernel " + flavor)
|
||||||
pmb.flasher.run(deviceinfo, method, "flash_kernel", flavor)
|
pmb.flasher.run(
|
||||||
|
deviceinfo,
|
||||||
|
method,
|
||||||
|
"flash_kernel",
|
||||||
|
flavor,
|
||||||
|
cmdline=cmdline,
|
||||||
|
no_reboot=no_reboot,
|
||||||
|
partition=partition,
|
||||||
|
resume=resume,
|
||||||
|
)
|
||||||
logging.info("You will get an IP automatically assigned to your USB interface shortly.")
|
logging.info("You will get an IP automatically assigned to your 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(f"ssh {get_context().config.user}@{pmb.config.default_ip}")
|
logging.info(f"ssh {get_context().config.user}@{pmb.config.default_ip}")
|
||||||
|
@ -55,7 +77,14 @@ def list_flavors(device: str) -> None:
|
||||||
logging.info("* " + str(pmb.chroot.other.kernel_flavor_installed(chroot)))
|
logging.info("* " + str(pmb.chroot.other.kernel_flavor_installed(chroot)))
|
||||||
|
|
||||||
|
|
||||||
def rootfs(deviceinfo: Deviceinfo, method: str) -> None:
|
def rootfs(
|
||||||
|
deviceinfo: Deviceinfo,
|
||||||
|
method: str,
|
||||||
|
cmdline: str | None = None,
|
||||||
|
no_reboot: bool | None = None,
|
||||||
|
partition: str | None = None,
|
||||||
|
resume: bool | None = None,
|
||||||
|
) -> None:
|
||||||
# Generate rootfs, install flasher
|
# Generate rootfs, install flasher
|
||||||
suffix = ".img"
|
suffix = ".img"
|
||||||
if pmb.config.flashers.get(method, {}).get("split", False):
|
if pmb.config.flashers.get(method, {}).get("split", False):
|
||||||
|
@ -76,14 +105,46 @@ def rootfs(deviceinfo: Deviceinfo, method: str) -> None:
|
||||||
|
|
||||||
# Run the flasher
|
# Run the flasher
|
||||||
logging.info("(native) flash rootfs image")
|
logging.info("(native) flash rootfs image")
|
||||||
pmb.flasher.run(deviceinfo, method, "flash_rootfs")
|
pmb.flasher.run(
|
||||||
|
deviceinfo,
|
||||||
|
method,
|
||||||
|
"flash_rootfs",
|
||||||
|
cmdline=cmdline,
|
||||||
|
no_reboot=no_reboot,
|
||||||
|
partition=partition,
|
||||||
|
resume=resume,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def list_devices(deviceinfo: Deviceinfo, method: str) -> None:
|
def list_devices(
|
||||||
pmb.flasher.run(deviceinfo, method, "list_devices")
|
deviceinfo: Deviceinfo,
|
||||||
|
method: str,
|
||||||
|
cmdline: str | None = None,
|
||||||
|
no_reboot: bool | None = None,
|
||||||
|
partition: str | None = None,
|
||||||
|
resume: bool | None = None,
|
||||||
|
) -> None:
|
||||||
|
# pmb.flasher.run provides user-facing error messages for unsupported
|
||||||
|
# flags, hence why we pass them here despite them being unused
|
||||||
|
pmb.flasher.run(
|
||||||
|
deviceinfo,
|
||||||
|
method,
|
||||||
|
"list_devices",
|
||||||
|
cmdline=cmdline,
|
||||||
|
no_reboot=no_reboot,
|
||||||
|
partition=partition,
|
||||||
|
resume=resume,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def sideload(deviceinfo: Deviceinfo, method: str) -> None:
|
def sideload(
|
||||||
|
deviceinfo: Deviceinfo,
|
||||||
|
method: str,
|
||||||
|
cmdline: str | None = None,
|
||||||
|
no_reboot: bool | None = None,
|
||||||
|
partition: str | None = None,
|
||||||
|
resume: bool | None = None,
|
||||||
|
) -> None:
|
||||||
# Install depends
|
# Install depends
|
||||||
pmb.flasher.install_depends(method)
|
pmb.flasher.install_depends(method)
|
||||||
|
|
||||||
|
@ -104,10 +165,25 @@ def sideload(deviceinfo: Deviceinfo, method: str) -> None:
|
||||||
" '--android-recovery-zip' parameter first!"
|
" '--android-recovery-zip' parameter first!"
|
||||||
)
|
)
|
||||||
|
|
||||||
pmb.flasher.run(deviceinfo, method, "sideload")
|
pmb.flasher.run(
|
||||||
|
deviceinfo,
|
||||||
|
method,
|
||||||
|
"sideload",
|
||||||
|
cmdline=cmdline,
|
||||||
|
no_reboot=no_reboot,
|
||||||
|
partition=partition,
|
||||||
|
resume=resume,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def flash_lk2nd(deviceinfo: Deviceinfo, method: str) -> None:
|
def flash_lk2nd(
|
||||||
|
deviceinfo: Deviceinfo,
|
||||||
|
method: str,
|
||||||
|
cmdline: str | None = None,
|
||||||
|
no_reboot: bool | None = None,
|
||||||
|
partition: str | None = None,
|
||||||
|
resume: bool | None = None,
|
||||||
|
) -> None:
|
||||||
if method == "fastboot":
|
if method == "fastboot":
|
||||||
# In the future this could be expanded to use "fastboot flash lk2nd $img"
|
# In the future this could be expanded to use "fastboot flash lk2nd $img"
|
||||||
# which reflashes/updates lk2nd from itself. For now let the user handle this
|
# which reflashes/updates lk2nd from itself. For now let the user handle this
|
||||||
|
@ -151,4 +227,12 @@ def flash_lk2nd(deviceinfo: Deviceinfo, method: str) -> None:
|
||||||
pmb.chroot.apk.install([lk2nd_pkg], suffix)
|
pmb.chroot.apk.install([lk2nd_pkg], suffix)
|
||||||
|
|
||||||
logging.info("(native) flash lk2nd image")
|
logging.info("(native) flash lk2nd image")
|
||||||
pmb.flasher.run(deviceinfo, method, "flash_lk2nd")
|
pmb.flasher.run(
|
||||||
|
deviceinfo,
|
||||||
|
method,
|
||||||
|
"flash_lk2nd",
|
||||||
|
cmdline=cmdline,
|
||||||
|
no_reboot=no_reboot,
|
||||||
|
partition=partition,
|
||||||
|
resume=resume,
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue