orchestrator: keep finalizer payload out of tmp

This commit is contained in:
Ryan Hughes committed 2026-05-22 01:39:49 -04:00
1 parent ec218bade6
commit c5baf2c791
1 file changed
+16 -21
@@ -794,9 +794,10 @@ def _register_efibootmgr_entry(
# the same paths # the same paths
# 3. write a passwordless-sudo shim for the install user (finalize.sh's # 3. write a passwordless-sudo shim for the install user (finalize.sh's
# scripts run as the user and shell out to sudo repeatedly) # scripts run as the user and shell out to sudo repeatedly)
# 4. copy the omarchy install tooling into /mnt/tmp/omarchy-install (the # 4. copy the omarchy install tooling into /mnt/opt/omarchy-install (the
# target never gets the omarchy-installer package installed) # target never gets the omarchy-installer package installed). Do NOT use
# 5. arch-chroot -u $user → /tmp/omarchy-install/finalize.sh # /tmp: arch-chroot mounts a fresh tmpfs over the target's /tmp.
# 5. arch-chroot -u $user → /opt/omarchy-install/finalize.sh
# ───────────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────────
def run_chroot_finalizer(ctx: InstallContext) -> None: def run_chroot_finalizer(ctx: InstallContext) -> None:
@@ -825,10 +826,12 @@ def run_chroot_finalizer(ctx: InstallContext) -> None:
) )
sudoers.chmod(0o440) sudoers.chmod(0o440)
# 4: copy install tooling to /mnt/tmp (ephemeral on first reboot, leaves # 4: copy install tooling somewhere arch-chroot will not mask. /tmp is not
# zero install detritus on the target). # safe here: arch-chroot mounts a fresh tmpfs over the target's /tmp before
target_tooling = ctx.target / "tmp" / "omarchy-install" # running commands, so files copied to /mnt/tmp are invisible in the chroot.
target_tooling.parent.mkdir(exist_ok=True) tooling_path = Path("/opt/omarchy-install")
target_tooling = ctx.target / tooling_path.relative_to("/")
target_tooling.parent.mkdir(parents=True, exist_ok=True)
if target_tooling.exists(): if target_tooling.exists():
shutil.rmtree(target_tooling) shutil.rmtree(target_tooling)
subprocess.run( subprocess.run(
@@ -840,21 +843,13 @@ def run_chroot_finalizer(ctx: InstallContext) -> None:
f"Copied installer tooling but {target_tooling / 'finalize.sh'} is missing" f"Copied installer tooling but {target_tooling / 'finalize.sh'} is missing"
) )
# Resolve ownership inside the target. The install user exists in # Keep the payload root-owned. It only needs to be traversable/readable by
# /mnt/etc/passwd, not in the live ISO, and the user's primary group is not # the install user; sudoers below handles privileged work inside scripts.
# guaranteed to have the same name as the user. The trailing ':' asks chown subprocess.run(["chmod", "-R", "a+rX", str(target_tooling)], check=True)
# to use the user's login group.
subprocess.run(
[
"arch-chroot", str(ctx.target),
"chown", "-R", f"{ctx.username}:", "/tmp/omarchy-install",
],
check=True,
)
subprocess.run( subprocess.run(
[ [
"arch-chroot", "-u", ctx.username, str(ctx.target), "arch-chroot", "-u", ctx.username, str(ctx.target),
"test", "-r", "/tmp/omarchy-install/finalize.sh", "test", "-r", str(tooling_path / "finalize.sh"),
], ],
check=True, check=True,
) )
@@ -863,7 +858,7 @@ def run_chroot_finalizer(ctx: InstallContext) -> None:
mirror_channel = _read_omarchy_mirror() mirror_channel = _read_omarchy_mirror()
env_extras = [ env_extras = [
"OMARCHY_INSTALL_MODE=offline", "OMARCHY_INSTALL_MODE=offline",
"OMARCHY_PATH=/tmp/omarchy-install", f"OMARCHY_PATH={tooling_path}",
f"OMARCHY_USER_NAME={ctx.full_name}", f"OMARCHY_USER_NAME={ctx.full_name}",
f"OMARCHY_USER_EMAIL={ctx.email}", f"OMARCHY_USER_EMAIL={ctx.email}",
f"OMARCHY_MIRROR={mirror_channel}", f"OMARCHY_MIRROR={mirror_channel}",
@@ -877,7 +872,7 @@ def run_chroot_finalizer(ctx: InstallContext) -> None:
"env", "--unset=XDG_RUNTIME_DIR", "env", "--unset=XDG_RUNTIME_DIR",
*env_extras, *env_extras,
"/bin/bash", "-lc", "/bin/bash", "-lc",
"bash /tmp/omarchy-install/finalize.sh", f"bash {tooling_path / 'finalize.sh'}",
] ]
subprocess.run(cmd, check=True) subprocess.run(cmd, check=True)