Skip to content

Commit

Permalink
feat(provision): call dd with sudo to eliminate need for disk group m…
Browse files Browse the repository at this point in the history
…embership
  • Loading branch information
xen0n committed Jan 16, 2024
1 parent 9c8ed5c commit 9945a73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions ruyi/cli/prereqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def has_cmd_in_path(cmd: str) -> bool:
"zstd",
"unzip",
# commands used by the device provisioner
"sudo",
"dd",
"fastboot",
)
Expand Down
10 changes: 5 additions & 5 deletions ruyi/device/provision_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,9 @@ def do_provision_interactive() -> int:
system beforehand.
Note that, as Ruyi does not run as [yellow]root[/yellow], but raw disk access is most likely
required to flash images, you should arrange to allow your user account write
access to the block device files. This likely means you should ensure your
user is part of the [yellow]disk[/yellow] group; for example, you can
[yellow]sudo gpasswd -a <your user> disk[/yellow] then logout and re-login, to achieve this.
required to flash images, you should arrange to allow your user account [yellow]sudo[/yellow]
access to necessary commands such as [yellow]dd[/yellow]. Flashing will fail if the [yellow]sudo[/yellow]
configuration does not allow so.
"""
)

Expand Down Expand Up @@ -495,6 +494,7 @@ class PackageProvisionStrategy(TypedDict):

def _do_dd(infile: str, outfile: str, blocksize: int = 4096) -> int:
argv = [
"sudo",
"dd",
f"if={infile}",
f"of={outfile}",
Expand All @@ -504,7 +504,7 @@ def _do_dd(infile: str, outfile: str, blocksize: int = 4096) -> int:
log.I(
f"dd-ing [yellow]{infile}[/yellow] to [green]{outfile}[/green] with block size {blocksize}..."
)
log.D(f"about to call dd: argv={argv}")
log.D(f"about to call dd with sudo: argv={argv}")
retcode = subprocess.call(argv)
if retcode == 0:
log.I(f"successfully flashed [green]{outfile}[/green]")
Expand Down

0 comments on commit 9945a73

Please sign in to comment.