Skip to content

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

Merged
Shmayro merged 1 commit into
copilot/add-arm64-supportfrom
refactor/self-contained-installs
May 29, 2026
Merged

refactor: self-contained install functions in first-boot.sh#48
Shmayro merged 1 commit into
copilot/add-arm64-supportfrom
refactor/self-contained-installs

Conversation

@Shmayro

@Shmayro Shmayro commented May 29, 2026

Copy link
Copy Markdown
Owner

Follow-up to #41. Cleans up the addon orchestration in first-boot.sh so each install function is fully self-contained and the post-first-boot flow is correct by construction.

Why

In the current code:

  • install_gapps doesn't reboot itself — it relies on a sibling helper needs_reboot() that checks "is anything else about to reboot for me?".
  • install_arm_translation calls 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 is set while the system is 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 duplicate 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.
  • This makes it 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.

Stacked on

This branch is based on copilot/add-arm64-support (#41). PR base is set to that branch so the diff shows only the refactor; once #41 merges, the base will switch to main automatically.

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.
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