Skip to content

install-phone: --work can be a path with a space - #646

Merged
derekross merged 1 commit into
derekross:mainfrom
only21mil:build/install-phone-work-path-quoting
Nov 11, 2026
Merged

derekross merged 1 commit into
derekross:mainfrom
only21mil:build/install-phone-work-path-quoting

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

What and why

With --work under a path with a space, tools/install-phone stops with "writing firstboot.conf into the image copy failed" before flashing anything: its debugfs command file names the three $work files bare, and debugfs splits commands at blanks. Following your note on #625, each host path now goes in debugfs's double quotes with any " doubled, the same inline dq() as the extractors. The host debugfs 1.47.2 reads that quoting in a -f file as in -R (space, ", backslash, apostrophe, tab).

A release bundle's ./install --unsigned --work '<dir>/my work', only fastboot faked, in a sandbox with the checkout at /mnt. The script trims the install's output with grep and strips colour codes. Before, on main:

$ bash install-with-work-dir origin/main 'my work'
$ git rev-parse --short origin/main   # the bundle's install is this revision's tools/install-phone
c065745d
(bundle install == origin/main:tools/install-phone)
$ ./install --unsigned --work '/mnt/logs/repro/run-origin-main-my_work/my work' | grep -E '==>|written|error|userdata'   # in the bundle, answers on stdin, fake fastboot
==> Checking the files (bundle mode)
==> Checking the phone
==> About the phone's owner
Host name [alice-phone]: Time zone [Etc/UTC]: Full name for git (optional): Email for git (optional): Wi-Fi network name (optional; Enter to skip): SSH public key for root and alice [/mnt/logs/repro/run-origin-main-my_work/home/.ssh/id_ed25519.pub]: ==> Preparing a local copy of the root image in /mnt/logs/repro/run-origin-main-my_work/my work
error: writing firstboot.conf into the image copy failed
install exit=1; partitions flashed to the fake fastboot: 

After, on this branch:

$ bash install-with-work-dir install-phone-work-path-quoting 'my work'
$ git rev-parse --short install-phone-work-path-quoting   # the bundle's install is this revision's tools/install-phone
ba3608ab
(bundle install == install-phone-work-path-quoting:tools/install-phone)
$ ./install --unsigned --work '/mnt/logs/repro/run-install-phone-work-path-quoting-my_work/my work' | grep -E '==>|written|error|userdata'   # in the bundle, answers on stdin, fake fastboot
==> Checking the files (bundle mode)
==> Checking the phone
==> About the phone's owner
Host name [alice-phone]: Time zone [Etc/UTC]: Full name for git (optional): Email for git (optional): Wi-Fi network name (optional; Enter to skip): SSH public key for root and alice [/mnt/logs/repro/run-install-phone-work-path-quoting-my_work/home/.ssh/id_ed25519.pub]: ==> Preparing a local copy of the root image in /mnt/logs/repro/run-install-phone-work-path-quoting-my_work/my work
    firstboot.conf, root's authorized_keys and boot-update.conf (AUTO_WRITE=yes) written, file system checks clean
==> The plan
    fastboot flash userdata /mnt/logs/repro/run-install-phone-work-path-quoting-my_work/my work/root.simg
userdata will be ERASED: stock Android's data is lost, and stock Android on
Type the phone's codename (twelve) to go ahead: ==> Flashing
    fastboot flash userdata /mnt/logs/repro/run-install-phone-work-path-quoting-my_work/my work/root.simg
==> Done. The phone boots slot B; the first boot sets up alice (a few minutes).
install exit=0; partitions flashed to the fake fastboot: boot_b dtbo_b init_boot_b userdata vendor_boot_b vendor_kernel_boot_b 
$ debugfs -R 'cat|stat <file>' <flashed userdata>   # the files the phone gets
35546664ad03963d mode 0600 uid 0 gid 0  /etc/omamobile/firstboot.conf
09922c50e87ac7a3 mode 0644 uid 0 gid 0  /etc/omamobile/boot-update.conf
98b9e61f341ad343 mode 0600 uid 0 gid 0  /root/.ssh/authorized_keys
e2fsck -fn on the flashed userdata: exit=0

boot-update.conf and authorized_keys match byte for byte across the plain --work runs on main and this branch and the spaced run on this branch. firstboot.conf matches after normalizing PASSWORD_HASH, with each hash verified against the same PIN.

Regression test (stand-in fastboot, not the reproduction): tests/install-phone installs with --work under a "spaced" dir and reads the three files back. It fails with main's tool, and if any one line loses its quotes.

Device and build

  • Phone: none: a laptop tool only
  • Kernel release (uname -r): not applicable
  • Packages changed, with versions: none

Checks (no phone needed)

  • tools/pr-check origin/main passes
  • tests/all passes
  • tests/packages passes (or the packages I touched: ...): no package touched
  • Each changed package has its version bumped, and the new version is in the commit subject: no package changed
  • Commits have area prefixes and bodies that say why; any AI help is a Co-Authored-By: or Assisted-by: trailer, never a Signed-off-by:

On the phone

  • I ran this on my own phone, booted into this build: no phone; this runs on the laptop before flashing
  • Runbook steps passed (plan, step, result): not applicable
  • What I did not test: a phone or a real flash, a real release root image, a --work path with a newline.
  • Nothing in this change writes outside slot B and userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1)
tools/phone-smoke report

Not applicable: a laptop tool that never runs on a phone (CONTRIBUTING.md §6.5).

Generated with Claude Opus 5.5 in T3 Code Nightly

install-phone writes firstboot.conf, boot-update.conf and root's
authorized_keys into the image copy through a debugfs command file,
and named their host paths there bare. debugfs splits each command at
blanks, so a --work directory with a space in its path made the writes
miss, and the install stopped with "writing firstboot.conf into the
image copy failed" before anything was flashed. Each of the three host
paths now goes in debugfs's own double quotes, with any double quote
doubled, the encoding derekross#625 gave the image extractors; the helper stays
inline because the bundle ships install alone.

Tested: tests/install-phone runs a full install with --work under a
directory named 'a "spaced" dir' and reads the three files back from
the flashed image (fails with main's tool, passes with this one); the
host's debugfs 1.47.2 reads the quoting the same in a -f command file
as in -R for a space, a double quote, a backslash, an apostrophe and a
tab; a release bundle's ./install with only fastboot faked completes
from a spaced --work, and the three files it writes are byte-identical
to a plain --work run's (the password hash line checked against the
PIN). Not tested: a phone; a path with a newline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derekross

Copy link
Copy Markdown
Owner

Thanks, @only21mil. This is the last bare host path from the #625 note, and the fix is the same dq() the extractors got, kept inline because the bundle ships install alone.

I checked it on today's main. tools/pr-check and tests/install-phone pass on the head, and with main's tools/install-phone under your test the new case stops at "writing firstboot.conf into the image copy failed", so the test really covers it. It also merges cleanly together with #648, and both install-phone suites pass on the two combined. After this change no debugfs command in the installer names a host path bare; the read-backs after the write still decide whether the install continues, and flash() is untouched.

A path with a newline still can't work, as you say; the read-backs stop it before anything is flashed, so that is fine as it is.

Merging.

@derekross
derekross merged commit b820b2a into derekross:main Nov 11, 2026
2 checks passed
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
install-phone named the three host files of its debugfs command file bare, and debugfs splits commands at blanks, so a `--work` directory with a space stopped the install with "writing firstboot.conf into the image copy failed" before anything was flashed. Each host path now goes in debugfs's double quotes with any double quote doubled, as derekross#625 did for the image extractors. `tests/install-phone` installs from a `--work` path with a space and a quote and reads the three files back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants