Pin a local-source install's locally built packages so updates keep them
This commit is contained in:
1 parent
8d069b0c03
commit
947a69ba91
5 files changed
+121
No files matched your search
@@ -37,6 +37,7 @@ def build_phases(ctx: InstallContext):
|
||||
stage_provisioning_state,
|
||||
finalize_limine_boot,
|
||||
run_chroot_finalizer,
|
||||
pin_local_packages,
|
||||
configure_dns_resolver,
|
||||
configure_login,
|
||||
configure_ssh_access,
|
||||
@@ -56,6 +57,7 @@ def build_phases(ctx: InstallContext):
|
||||
("Staging provisioning", stage_provisioning_state),
|
||||
("Finalizing Limine boot", finalize_limine_boot),
|
||||
("Finalizing user", run_chroot_finalizer),
|
||||
("Pinning local builds", pin_local_packages),
|
||||
("Configuring login", configure_login),
|
||||
("Configuring SSH access", configure_ssh_access),
|
||||
("Configuring Tailscale", configure_tailscale),
|
||||
|
||||
@@ -1375,6 +1375,42 @@ def run_chroot_finalizer(ctx: InstallContext) -> None:
|
||||
)
|
||||
|
||||
|
||||
|
||||
PINNED_PACKAGES = Path("/usr/share/omarchy-iso/pinned-packages")
|
||||
PIN_HOOK_SCRIPT = """#!/bin/bash
|
||||
|
||||
# omarchy refresh pacman rewrites pacman.conf; keep this ISO's local builds pinned.
|
||||
line="{line}"
|
||||
grep -qxF "$line" /etc/pacman.conf || sudo sed -i "/^\\[options\\]/a $line" /etc/pacman.conf
|
||||
"""
|
||||
|
||||
|
||||
def pin_local_packages(ctx: InstallContext) -> None:
|
||||
if not PINNED_PACKAGES.exists():
|
||||
return
|
||||
|
||||
line = "IgnorePkg = " + " ".join(PINNED_PACKAGES.read_text().split())
|
||||
info(f"› {line}")
|
||||
pacman_conf = ctx.target / "etc" / "pacman.conf"
|
||||
conf = pacman_conf.read_text()
|
||||
if line not in conf.splitlines():
|
||||
if "[options]\n" not in conf:
|
||||
raise RuntimeError(f"{pacman_conf} has no [options] section to pin local builds in")
|
||||
pacman_conf.write_text(conf.replace("[options]\n", f"[options]\n{line}\n", 1))
|
||||
|
||||
if ctx.defer_provisioning:
|
||||
return
|
||||
|
||||
hooks = f"/home/{ctx.username}/.config/omarchy/hooks"
|
||||
hook = ctx.target / hooks.lstrip("/") / "pre-refresh-pacman.d" / "pin-local-packages"
|
||||
hook.parent.mkdir(parents=True, exist_ok=True)
|
||||
hook.write_text(PIN_HOOK_SCRIPT.format(line=line))
|
||||
hook.chmod(0o755)
|
||||
subprocess.run(
|
||||
["arch-chroot", str(ctx.target), "chown", "-R", f"{ctx.username}:{ctx.username}", hooks],
|
||||
check=True,
|
||||
)
|
||||
|
||||
def configure_dns_resolver(ctx: InstallContext) -> None:
|
||||
"""Put the installed system in systemd-resolved stub mode.
|
||||
|
||||
|
||||
Reference in new issue
Block a user