1
0
Fork 0
gnu-plus-dotfiles/run_once_10-add-gentoo-overlays.sh.tmpl
rain 4556813e78 Gentoo bootstrap: fix ambiguous package names + early-return on os_family mismatch
Three issues caught during tadbit onboarding:

1. run_once_00-install-bootstrap-tools.sh.tmpl (gentoo branch):
   'gnupg' is ambiguous (app-crypt/gnupg vs app-vim/gnupg). Use full
   category/package names: app-crypt/gnupg, app-crypt/age, etc.
   The previous 'for p in age curl ...' loop fed short names to
   emerge which printed '!!! The short ebuild name gnupg is
   ambiguous' and exited 1.

2. run_once_20-install-user-packages-gentoo.sh.tmpl:
   sys-devel/base-devel doesn't exist on Gentoo (it's an Arch/Fedora
   concept; Gentoo's toolchain is the @system set which is always
   installed). Removed base-devel from the package list.

3. Universal scripts (run_once_20 + run_once_40) were running on
   gentoo and hitting either 'die unsupported os_family' (universal
   20) or 'WARNING sway packages not configured for gentoo' (universal
   40). Added early-return: 'if os_family == gentoo, exit 0' at the
   top of each universal script so the gentoo-specific scripts
   handle the box. (Same pattern the chaotic-aur script already had.)

4. run_once_10-add-gentoo-overlays.sh.tmpl:
   The cached ~/.cache/eselect-repo/repositories.xml was corrupt on
   tadbit (lxml.etree.XMLSyntaxError on every 'eselect repository
   list' call). Added a sanity check: parse the XML with
   xml.etree.ElementTree, delete if invalid, re-fetch.

After these fixes, the bootstrap on tadbit is expected to run cleanly
with --keep-going (the four failures above all become no-ops).
2026-06-23 16:18:54 -04:00

65 lines
No EOL
2.7 KiB
Bash

#!/usr/bin/env bash
# =============================================================================
# run_once_05-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
# =============================================================================
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 [[ ! -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.
if [[ -d /var/db/repos/guru ]]; then
log "GURU overlay already enabled at /var/db/repos/guru — skipping"
else
log "enabling GURU overlay via eselect repository"
# `eselect repository` needs the overlays.xml index. If the cached
# one is corrupt (lxml.etree.XMLSyntaxError), delete it and re-fetch.
ESEL_REPO_CACHE="${HOME}/.cache/eselect-repo/repositories.xml"
if [[ -f "$ESEL_REPO_CACHE" ]]; then
# Quick sanity check: try to parse the XML. If invalid, delete.
if ! python3 -c "import xml.etree.ElementTree as ET; ET.parse('$ESEL_REPO_CACHE')" 2>/dev/null; then
log "WARN: $ESEL_REPO_CACHE is corrupt; removing and re-fetching"
rm -f "$ESEL_REPO_CACHE"
fi
fi
if ! sudo eselect repository list 2>&1 | grep -qi guru; then
log "fetching overlays.xml index"
sudo emaint sync --auto
fi
sudo eselect repository enable guru
# Sync just the new repo so we don't re-pull the entire gentoo tree
log "syncing GURU overlay"
sudo emaint sync -r guru
log "GURU overlay enabled and synced"
fi
# --- 2. Verify ---
log "enabled overlays:"
eselect repository list 2>&1 | sed 's/^/ /'
# Verify the GURU repo is readable
if [[ ! -f /var/db/repos/guru/profiles/repo_name ]]; then
die "/var/db/repos/guru/profiles/repo_name missing — overlay didn't sync cleanly"
fi
GURU_NAME=$(cat /var/db/repos/guru/profiles/repo_name)
log "GURU repo verified: $GURU_NAME"
log "overlays ready"