aboutsummaryrefslogtreecommitdiff
path: root/installer/lib/common.sh
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-09 23:45:00 -0500
committerCraig Jennings <c@cjennings.net>2026-06-09 23:45:00 -0500
commit4e6f4cc66206f02e92d4a2ca2f414fad5a3439a1 (patch)
tree27c48401b170856691023a50573a26e0032a89fc /installer/lib/common.sh
parent39b4a8bc5cac3a2092122f6c4fbede9bf0139286 (diff)
downloadarchangel-4e6f4cc66206f02e92d4a2ca2f414fad5a3439a1.tar.gz
archangel-4e6f4cc66206f02e92d4a2ca2f414fad5a3439a1.zip
feat(install): install baked AUR packages and clean the target config
Wire the baked AUR repo into the installer. Before pacstrap, install_base checks whether the ISO shipped the repo and, if so, exposes [aur] in the live /etc/pacman.conf and reads the package names from the manifest, adding them to the pacstrap set so they install into the target offline. This mirrors the existing [archzfs] handling. pacstrap resolves repos from the live system, not $MNTPOINT. The live config already carries [aur] from the shipped ISO config, so the append is idempotent by design. A --skip-aur ISO ships no repo, and aur_repo_available gates the whole path, so the installer still works there. configure_system strips any [aur] stanza from the target /etc/pacman.conf. pacstrap installs a stock target config with no [aur], so this is defensive, but it guarantees the installed system never references /usr/share/aur-packages, which exists only on the live ISO. Four new common.sh helpers carry the logic: aur_repo_available, append_aur_repo (idempotent), aur_manifest_names (the manifest is the source of what to install, so the list never drifts), and strip_repo_stanza. All four covered across Normal, Boundary, and Error.
Diffstat (limited to 'installer/lib/common.sh')
-rw-r--r--installer/lib/common.sh61
1 files changed, 61 insertions, 0 deletions
diff --git a/installer/lib/common.sh b/installer/lib/common.sh
index 8f44170..0317034 100644
--- a/installer/lib/common.sh
+++ b/installer/lib/common.sh
@@ -124,6 +124,67 @@ required_commands() {
}
#############################
+# AUR Local Repository
+#############################
+# The ISO can bake a local pacman repo of AUR packages at /usr/share/aur-packages
+# (built by build-aur.sh at ISO-build time). These helpers expose it to
+# pacstrap from the LIVE system, list what it holds, and keep the installed
+# target's pacman.conf from referencing a path the target won't have. See
+# docs/aur-local-repo-spec.org.
+
+# True when the baked AUR repo exists at $1 (default /usr/share/aur-packages).
+# repo-add ships aur.db (a symlink) alongside aur.db.tar.gz; the airootfs copy
+# may dereference the symlink to a plain file, so accept either name. A
+# --skip-aur ISO ships no repo, so this gates every AUR install-time step.
+aur_repo_available() {
+ local repo_dir="${1:-/usr/share/aur-packages}"
+ [[ -f "$repo_dir/aur.db" || -f "$repo_dir/aur.db.tar.gz" ]]
+}
+
+# Append an [aur] stanza pointing at $server to the pacman.conf at $1, unless
+# one is already present. Idempotent so a re-run of the installer doesn't stack
+# duplicates. SigLevel = Optional TrustAll mirrors the build-side stanza: the
+# repo is trusted by construction.
+append_aur_repo() {
+ local pacman_conf="$1" server="$2"
+ grep -q '^\[aur\]' "$pacman_conf" && return 0
+ cat >> "$pacman_conf" <<EOF
+
+[aur]
+SigLevel = Optional TrustAll
+Server = $server
+EOF
+}
+
+# Print the package names (first TSV column) from the AUR build manifest at
+# $1, skipping the header. Empty output when the file is absent — the
+# manifest is the single source for what to install, so the installer never
+# hard-codes the baked package list.
+aur_manifest_names() {
+ local manifest="$1"
+ [[ -f "$manifest" ]] || return 0
+ awk -F'\t' 'NR>1 {print $1}' "$manifest"
+}
+
+# Remove the named repo's stanza (its [name] header and the config lines up to
+# the next [section] or EOF) from the pacman.conf at $2. Used to ensure the
+# installed target never references the baked [aur] repo, whose
+# /usr/share/aur-packages path exists only on the live ISO. A no-op when the
+# stanza is absent.
+strip_repo_stanza() {
+ local repo="$1" pacman_conf="$2"
+ local tmp
+ tmp=$(mktemp)
+ awk -v header="[$repo]" '
+ $0 == header { skip = 1; next }
+ skip && /^\[/ { skip = 0 }
+ skip { next }
+ { print }
+ ' "$pacman_conf" > "$tmp"
+ mv "$tmp" "$pacman_conf"
+}
+
+#############################
# Password / Passphrase Input
#############################