installer: always clean up finalizer log bind
This commit is contained in:
1 file changed
+51
-51
@@ -850,59 +850,59 @@ def run_chroot_finalizer(ctx: InstallContext) -> None:
|
|||||||
with ctx.log_path.open("a", encoding="utf-8") as log:
|
with ctx.log_path.open("a", encoding="utf-8") as log:
|
||||||
log.write(f"[orchestrator] WARNING: failed to bind unified finalizer log: {exc}\n")
|
log.write(f"[orchestrator] WARNING: failed to bind unified finalizer log: {exc}\n")
|
||||||
|
|
||||||
# 4: copy install tooling somewhere arch-chroot will not mask. /tmp is not
|
try:
|
||||||
# safe here: arch-chroot mounts a fresh tmpfs over the target's /tmp before
|
# 4: copy install tooling somewhere arch-chroot will not mask. /tmp is not
|
||||||
# running commands, so files copied to /mnt/tmp are invisible in the chroot.
|
# safe here: arch-chroot mounts a fresh tmpfs over the target's /tmp before
|
||||||
tooling_path = Path("/opt/omarchy-install")
|
# running commands, so files copied to /mnt/tmp are invisible in the chroot.
|
||||||
target_tooling = ctx.target / tooling_path.relative_to("/")
|
tooling_path = Path("/opt/omarchy-install")
|
||||||
target_tooling.parent.mkdir(parents=True, exist_ok=True)
|
target_tooling = ctx.target / tooling_path.relative_to("/")
|
||||||
if target_tooling.exists():
|
target_tooling.parent.mkdir(parents=True, exist_ok=True)
|
||||||
shutil.rmtree(target_tooling)
|
if target_tooling.exists():
|
||||||
subprocess.run(
|
shutil.rmtree(target_tooling)
|
||||||
["cp", "-a", f"{ctx.omarchy_path}/.", str(target_tooling)],
|
subprocess.run(
|
||||||
check=True,
|
["cp", "-a", f"{ctx.omarchy_path}/.", str(target_tooling)],
|
||||||
)
|
check=True,
|
||||||
if not (target_tooling / "finalize.sh").exists():
|
)
|
||||||
raise RuntimeError(
|
if not (target_tooling / "finalize.sh").exists():
|
||||||
f"Copied installer tooling but {target_tooling / 'finalize.sh'} is missing"
|
raise RuntimeError(
|
||||||
|
f"Copied installer tooling but {target_tooling / 'finalize.sh'} is missing"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Keep the payload root-owned. It only needs to be traversable/readable by
|
||||||
|
# the install user; sudoers below handles privileged work inside scripts.
|
||||||
|
subprocess.run(["chmod", "-R", "a+rX", str(target_tooling)], check=True)
|
||||||
|
subprocess.run(
|
||||||
|
[
|
||||||
|
"arch-chroot", "-u", ctx.username, str(ctx.target),
|
||||||
|
"test", "-r", str(tooling_path / "finalize.sh"),
|
||||||
|
],
|
||||||
|
check=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Keep the payload root-owned. It only needs to be traversable/readable by
|
# 5: arch-chroot -u $user → finalize.sh
|
||||||
# the install user; sudoers below handles privileged work inside scripts.
|
mirror_channel = _read_omarchy_mirror()
|
||||||
subprocess.run(["chmod", "-R", "a+rX", str(target_tooling)], check=True)
|
env_extras = [
|
||||||
subprocess.run(
|
"OMARCHY_INSTALL_MODE=offline",
|
||||||
[
|
"OMARCHY_CHROOT_FINALIZER=1",
|
||||||
"arch-chroot", "-u", ctx.username, str(ctx.target),
|
"OMARCHY_PATH=/usr/share/omarchy",
|
||||||
"test", "-r", str(tooling_path / "finalize.sh"),
|
f"OMARCHY_INSTALL={tooling_path / 'install'}",
|
||||||
],
|
f"OMARCHY_START_TIME={omarchy_start_time}",
|
||||||
check=True,
|
f"OMARCHY_START_EPOCH={omarchy_start_epoch}",
|
||||||
)
|
f"OMARCHY_USER_NAME={ctx.full_name}",
|
||||||
|
f"OMARCHY_USER_EMAIL={ctx.email}",
|
||||||
# 5: arch-chroot -u $user → finalize.sh
|
f"OMARCHY_MIRROR={mirror_channel}",
|
||||||
mirror_channel = _read_omarchy_mirror()
|
"OMARCHY_INSTALL_LOG_FILE=/var/log/omarchy-install.log",
|
||||||
env_extras = [
|
f"USER={ctx.username}",
|
||||||
"OMARCHY_INSTALL_MODE=offline",
|
f"HOME=/home/{ctx.username}",
|
||||||
"OMARCHY_CHROOT_FINALIZER=1",
|
]
|
||||||
"OMARCHY_PATH=/usr/share/omarchy",
|
cmd = [
|
||||||
f"OMARCHY_INSTALL={tooling_path / 'install'}",
|
"arch-chroot",
|
||||||
f"OMARCHY_START_TIME={omarchy_start_time}",
|
"-u", ctx.username,
|
||||||
f"OMARCHY_START_EPOCH={omarchy_start_epoch}",
|
str(ctx.target),
|
||||||
f"OMARCHY_USER_NAME={ctx.full_name}",
|
"env", "--unset=XDG_RUNTIME_DIR",
|
||||||
f"OMARCHY_USER_EMAIL={ctx.email}",
|
*env_extras,
|
||||||
f"OMARCHY_MIRROR={mirror_channel}",
|
"/bin/bash", str(tooling_path / "finalize.sh"),
|
||||||
"OMARCHY_INSTALL_LOG_FILE=/var/log/omarchy-install.log",
|
]
|
||||||
f"USER={ctx.username}",
|
|
||||||
f"HOME=/home/{ctx.username}",
|
|
||||||
]
|
|
||||||
cmd = [
|
|
||||||
"arch-chroot",
|
|
||||||
"-u", ctx.username,
|
|
||||||
str(ctx.target),
|
|
||||||
"env", "--unset=XDG_RUNTIME_DIR",
|
|
||||||
*env_extras,
|
|
||||||
"/bin/bash", str(tooling_path / "finalize.sh"),
|
|
||||||
]
|
|
||||||
try:
|
|
||||||
subprocess.run(cmd, check=True)
|
subprocess.run(cmd, check=True)
|
||||||
finally:
|
finally:
|
||||||
sudoers.unlink(missing_ok=True)
|
sudoers.unlink(missing_ok=True)
|
||||||
|
|||||||
Reference in new issue
Block a user