gentoo-overlays: guard with os_family so non-gentoo boxes skip it
The script's body was never wrapped in an os_family template conditional
despite the header claiming it was 'guarded by the chezmoi template
engine'. So topgrade/chezmoi apply would run it on every box and die
with '/var/db/repos/gentoo missing' on arch/debian.
Wrap the body in '{{ if eq .os_family "gentoo" }}' / '{{ else }}' (same
pattern the arch-only chaotic-aur script already uses). On non-gentoo
boxes the rendered script reduces to a single 'skipping' log line.
Also fix two stale comments in the header (filename was 05, not 10).
Verified by rendering with --config override: arch → no-op log line,
gentoo → full body intact, both pass bash -n.
This commit is contained in:
parent
d61ffacc22
commit
6b64fe0625
1 changed files with 16 additions and 13 deletions
29
run_once_10-add-gentoo-overlays.sh.tmpl
Normal file → Executable file
29
run_once_10-add-gentoo-overlays.sh.tmpl
Normal file → Executable file
|
|
@ -1,31 +1,30 @@
|
|||
#!/usr/bin/env bash
|
||||
# =============================================================================
|
||||
# run_once_05-add-gentoo-overlays.sh.tmpl (gentoo-only)
|
||||
# run_once_10-add-gentoo-overlays.sh.tmpl (gentoo-only)
|
||||
# Add the GURU overlay to the portage repository list. GURU is the
|
||||
# community overlay (like AUR for arch) where packages like bun, eza,
|
||||
# sway, etc. live when they're not in the main tree.
|
||||
#
|
||||
# Idempotent: skips if GURU is already enabled.
|
||||
# Run-order: 00 (bootstrap) → 05-overlays (here) → 10-add-{chaotic,debian}
|
||||
# → 20-install-packages → 40-install-sway
|
||||
# Guarded: this script is a no-op on non-gentoo boxes via the os_family
|
||||
# template conditional below — so topgrade/chezmoi apply never errors
|
||||
# on arch/debian where /var/db/repos/gentoo doesn't exist.
|
||||
#
|
||||
# Run-order: 00 (bootstrap) → 05 (hosts) → 10 (overlays, here)
|
||||
# → 20 (packages) → 40 (sway)
|
||||
# =============================================================================
|
||||
set -euo pipefail
|
||||
|
||||
log() { printf '\033[1;34m[overlays]\033[0m %s\n' "$*"; }
|
||||
die() { printf '\033[1;31m[overlays ERROR]\033[0m %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
# This script is gentoo-only. Guarded by the chezmoi template engine;
|
||||
# on arch/debian it never renders (only this single file path).
|
||||
|
||||
{{ if eq .os_family "gentoo" -}}
|
||||
# --- gentoo: ensure GURU overlay is enabled ---
|
||||
if [[ ! -d /var/db/repos/gentoo ]]; then
|
||||
die "/var/db/repos/gentoo missing — this doesn't look like a gentoo system"
|
||||
fi
|
||||
|
||||
# --- 1. GURU overlay ---
|
||||
# User explicitly requires GURU. Per the bootstrap-runbook skill: gentoo
|
||||
# boxes without GURU can't install most of the user packages (eza, fzf,
|
||||
# fd-find on stable, lazygit, topgrade, etc.) because they only ship in
|
||||
# the main tree as ~amd64 or only live in GURU.
|
||||
# GURU overlay — required for eza, lazygit, topgrade, etc.
|
||||
if [[ -d /var/db/repos/guru ]]; then
|
||||
log "GURU overlay already enabled at /var/db/repos/guru — skipping"
|
||||
else
|
||||
|
|
@ -51,7 +50,7 @@ else
|
|||
log "GURU overlay enabled and synced"
|
||||
fi
|
||||
|
||||
# --- 2. Verify ---
|
||||
# --- verify ---
|
||||
log "enabled overlays:"
|
||||
eselect repository list 2>&1 | sed 's/^/ /'
|
||||
|
||||
|
|
@ -62,4 +61,8 @@ fi
|
|||
GURU_NAME=$(cat /var/db/repos/guru/profiles/repo_name)
|
||||
log "GURU repo verified: $GURU_NAME"
|
||||
|
||||
log "overlays ready"
|
||||
log "overlays ready"
|
||||
{{ else -}}
|
||||
# Not a gentoo box — nothing to do (guarded by os_family above).
|
||||
log "skipping gentoo overlays (os_family={{ .os_family }}, not gentoo)"
|
||||
{{ end -}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue