Skip to content

Commit

Permalink
refactor: rpi_boot: use chroot to run flash-kernel, ditch double rebo…
Browse files Browse the repository at this point in the history
…ot strategy (#318)

This PR introduces one-step firmware install strategy to rpi_boot to deprecate the previously used double steps firmware update strategy. It also includes some internal refinements in rpi_boot.

* New features
1. support flash-kernel directly in post-update phase with chroot to standby slot.
2. now if system-boot partition is not mounted, rpi_boot will try to mount it.
3. rpi_boot now allows extra partitions after partition ID 3.

* Other changes
1. otaclient_common.linux: implement new subprocess_run_wrapper, which supports chroot.
2. otaclient.boot_control.common: implement a plain version of mount.
  • Loading branch information
Bodong-Yang committed Jun 19, 2024
1 parent ed458fd commit 09533e4
Show file tree
Hide file tree
Showing 6 changed files with 542 additions and 506 deletions.
31 changes: 31 additions & 0 deletions src/otaclient/app/boot_control/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
subprocess_check_output,
write_str_to_file_sync,
)
from otaclient_common.typing import StrOrPath

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -234,6 +235,36 @@ def set_ext4_fslabel(cls, dev: str, fslabel: str, *, raise_exception: bool = Tru
cmd = ["e2label", dev, fslabel]
subprocess_call(cmd, raise_exception=raise_exception)

@classmethod
def mount(
cls,
target: StrOrPath,
mount_point: StrOrPath,
*,
options: list[str] | None = None,
params: list[str] | None = None,
raise_exception: bool = True,
) -> None:
"""Thin wrapper to call mount using subprocess.
This will call the following:
mount [-o <option1>,[<option2>[,...]] [<param1> [<param2>[...]]] <target> <mount_point>
Args:
target (StrOrPath): The target device to mount.
mount_point (StrOrPath): The mount point to mount to.
options (list[str] | None, optional): A list of options, append after -o. Defaults to None.
params (list[str] | None, optional): A list of params. Defaults to None.
raise_exception (bool, optional): Whether to raise exception on failed call. Defaults to True.
"""
cmd = ["mount"]
if options:
cmd.extend(["-o", ",".join(options)])
if params:
cmd.extend(params)
cmd = [*cmd, str(target), str(mount_point)]
subprocess_call(cmd, raise_exception=raise_exception)

@classmethod
def mount_rw(
cls, target: str, mount_point: Path | str, *, raise_exception: bool = True
Expand Down
Loading

0 comments on commit 09533e4

Please sign in to comment.