From bc613e72238f864a597777826d1f9cc533c4cffa Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 13 Apr 2026 00:10:17 -0400 Subject: refactor: merge install_base and install_base_btrfs Extract the pacstrap package list into pacstrap_packages(filesystem) in lib/common.sh (common + filesystem-specific). install_base() now dispatches on FILESYSTEM for both the archzfs-repo-append and the package list. install_base_btrfs() deleted; install_btrfs() call site updated to invoke install_base. Old: 49 + 38 lines of ~95% copy-paste. New: 32 lines + a 20-line pure helper. 7 bats tests cover: zfs has zfs-dkms/zfs-utils, btrfs has btrfs-progs + grub + grub-btrfs + snapper + snap-pac, each flavor excludes the other's specifics, common packages are in both, unknown filesystem returns status 1, output is one-per-line. make test: 65/65. --- installer/lib/common.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'installer/lib') diff --git a/installer/lib/common.sh b/installer/lib/common.sh index dcaf071..d181e0b 100644 --- a/installer/lib/common.sh +++ b/installer/lib/common.sh @@ -56,6 +56,34 @@ require_command() { command_exists "$1" || error "Required command not found: $1" } +############################# +# Package Selection +############################# + +# Print the pacstrap package list for the given filesystem, one per line. +# Common packages first, then filesystem-specific ones. +# Returns 1 for unknown filesystem. +# +# Usage: mapfile -t pkgs < <(pacstrap_packages zfs) +pacstrap_packages() { + local fs="$1" + local common=( + base base-devel + linux-lts linux-lts-headers linux-firmware + efibootmgr + networkmanager avahi nss-mdns openssh + git vim sudo zsh nodejs npm + ttf-dejavu fzf wget inetutils wireless-regdb + ) + local fs_specific + case "$fs" in + zfs) fs_specific=(zfs-dkms zfs-utils) ;; + btrfs) fs_specific=(btrfs-progs grub grub-btrfs snapper snap-pac) ;; + *) return 1 ;; + esac + printf '%s\n' "${common[@]}" "${fs_specific[@]}" +} + ############################# # Password / Passphrase Input ############################# -- cgit v1.2.3