fix(installer): parse pkglist name field, skip unresolvable pkgs, keymap confirm

pacstrap failed at line 382 because pkglist lines from pacman -Q are
'name version' and were passed whole as pacman targets (~400 'target
not found'). Parse only the first field, pre-filter against pacman -Slq
so packages missing from the live repos (local-aur) are skipped with a
warning, and fall back to an unfiltered list if pacman -Syy fails.
Keymap screen now offers a US-layout confirm before the gum filter.
This commit is contained in:
alvinlollo
2026-09-23 22:32:01 +10:00
parent 0755091721
commit 8484bddcf2
+48 -6
View File
@@ -40,6 +40,7 @@ trap 'gum style --foreground 9 --bold "Failed at line $LINENO. See $LOG"' ERR
die() { gum style --foreground 9 --bold "ERROR: $*"; exit 1; }
info() { gum style --foreground 12 --bold "$*"; }
ok() { gum style --foreground 10 --bold "$*"; }
warn() { gum style --foreground 11 --bold "$*"; }
header() {
gum style \
@@ -85,10 +86,18 @@ screen_keymap() {
header "Keyboard Layout"
echo ""
gum style --foreground 15 \
"Select your console keymap." \
"This affects passwords and the LUKS passphrase at boot."
"Select the keyboard layout of your physical keyboard." \
"This affects passwords and the LUKS passphrase at boot." \
"" \
"The default is the US layout (us)."
echo ""
KEYMAP=$(localectl list-keymaps | gum filter --header "+ Keymap" --placeholder "Search keymaps...")
if gum confirm --affirmative "Use us (default)" --negative "Choose another layout" \
"Use US keyboard layout (us)?"; then
KEYMAP="us"
else
KEYMAP=$(localectl list-keymaps | gum filter --header "+ Keymap" --placeholder "Search keymaps...") \
|| die "No keymap selected."
fi
[[ -z "$KEYMAP" ]] && die "No keymap selected."
loadkeys "$KEYMAP" 2>/dev/null || true
log "Keymap: $KEYMAP"
@@ -357,15 +366,48 @@ install_pacstrap() {
local pkglist="/run/archiso/bootmnt/arch/pkglist.x86_64.txt"
local pkgs=()
local dropped=()
local filter_ok=false
if [[ -f "$pkglist" ]]; then
while IFS= read -r pkg; do
[[ -z "$pkg" ]] && continue
# The medium's pkglist comes from `pacman -Q`: lines are "name version".
# Parse only the first field, then drop names not resolvable in the live
# session's repos (e.g. local-aur packages are not configured there).
info "Syncing package databases for resolvability check..."
if pacman -Syy --noconfirm >>"$LOG" 2>&1; then
declare -A available=()
local db_line
while IFS= read -r db_line; do
[[ -n "$db_line" ]] && available["$db_line"]=1
done < <(pacman -Slq 2>>"$LOG" || true)
(( ${#available[@]} > 0 )) && filter_ok=true
else
warn "pacman -Syy failed (see $LOG) — installing without resolvability filter."
fi
local line pkg
while IFS= read -r line; do
[[ -z "$line" ]] && continue
pkg=${line%% *}
skip "$pkg" && continue
if $filter_ok && [[ -z "${available[$pkg]:-}" ]]; then
dropped+=("$pkg")
continue
fi
pkgs+=("$pkg")
done < "$pkglist"
fi
if (( ${#dropped[@]} > 0 )); then
warn "Skipped ${#dropped[@]} pkglist package(s) not found in configured repos:"
gum style --foreground 11 "${dropped[@]/#/ - }"
local d
for d in "${dropped[@]}"; do
log "Pacstrap: skipped unresolvable: $d"
done
fi
# Hardcoded essentials are never filtered — they must be in allowed repos.
for p in base linux linux-firmware linux-cachyos linux-cachyos-headers \
networkmanager grub efibootmgr sudo git intel-ucode amd-ucode \
mkinitcpio cryptsetup dosfstools e2fsprogs btrfs-progs \
@@ -378,7 +420,7 @@ install_pacstrap() {
done
info "Installing ${#pkgs[@]} packages (this may take a while)..."
log "Pacstrap: ${#pkgs[@]} packages"
log "Pacstrap: ${#pkgs[@]} packages, ${#dropped[@]} skipped"
pacstrap "$TARGET" "${pkgs[@]}" --noconfirm 2>>"$LOG"
ok "Packages installed."