Skip to content

refactor: self-contained install functions in first-boot.sh#50

Merged
Shmayro merged 1 commit into
mainfrom
refactor-installs-to-main
May 29, 2026
Merged

refactor: self-contained install functions in first-boot.sh#50
Shmayro merged 1 commit into
mainfrom
refactor-installs-to-main

Conversation

@Shmayro
Copy link
Copy Markdown
Owner

@Shmayro Shmayro commented May 29, 2026

Re-targets the refactor work from #48 onto main. #48 was originally opened against copilot/add-arm64-support as part of a stacked PR chain and got merged into that intermediate branch instead of main — so its content never landed.

Same commit as #48 (cherry-picked unchanged), now properly targeting main.

Why

In the previous first-boot.sh:

  • install_gapps didn't reboot itself — it relied on a sibling helper needs_reboot() to decide whether a subsequent install would reboot for it.
  • install_arm_translation called adb reboot and then immediately touch /data/.arm-translation-done. adb reboot returns the moment the command is accepted by adbd, not when reboot completes — so the marker was set while the system was still rebooting. A container killed in that window leaves a "marked done but not actually applied" state on next start.
  • The first-boot and post-first-boot paths duplicated the same install sequence in two near-identical blocks.

Changes

  • Each install function does reboot → adb wait-for-device → marker in that order, so the marker only lands once adbd has come back.
  • needs_reboot() removed — the reboot decision is now local to each install function rather than crossing function boundaries.
  • The duplicate first-boot / post-first-boot branches collapse into one — only avdmanager create avd is conditional on /data/.first-boot-done.
  • Safe to flip e.g. ARM_TRANSLATION=1 on a container that already booted: restart the container and the upper-branch install runs cleanly to completion.

Cost

One extra AVD reboot (~25s) in the rare case where both GAPPS and ARM_TRANSLATION are enabled in the same pass, traded for cleaner per-function encapsulation.

Supersedes

Each install (gapps, root, arm_translation) is now responsible for its
own reboot + wait + done-marker sequence, in that order. The marker is
only written once adbd has come back, so a container killed mid-reboot
won't leave a "marked done but not applied" state.

- Drop the needs_reboot() helper; the reboot decision is now local to
  each install function instead of crossing function boundaries.
- Collapse the duplicate first-boot / post-first-boot branches in main
  into one path — only AVD creation is conditional on /data/.first-boot-done.
- install_gapps and install_arm_translation now end with
  'adb reboot; adb wait-for-device; touch .<addon>-done', so they are
  safe to invoke standalone after the initial first boot when a flag is
  flipped on a previously initialized container.

One extra AVD reboot occurs in the rare case where both GAPPS and
ARM_TRANSLATION are enabled in the same pass (~25s), traded for the
cleaner per-function encapsulation.
@Shmayro Shmayro merged commit c0aa391 into main May 29, 2026
1 check passed
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.

1 participant