aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinstaller/archangel84
-rw-r--r--installer/lib/common.sh28
-rw-r--r--tests/unit/test_common.bats63
3 files changed, 106 insertions, 69 deletions
diff --git a/installer/archangel b/installer/archangel
index 4dc6689..5719d4f 100755
--- a/installer/archangel
+++ b/installer/archangel
@@ -878,84 +878,30 @@ install_base() {
pacman-key --init
pacman-key --populate archlinux
- # Add archzfs repo to pacman.conf for pacstrap
- # SigLevel=Never: pacstrap -K creates empty keyring where key import fails;
- # repo is explicitly added and served over HTTPS, GPG adds no real value here
- if ! grep -q "\[archzfs\]" /etc/pacman.conf; then
- cat >> /etc/pacman.conf << 'EOF'
+ # ZFS needs the archzfs repo added to pacman.conf for pacstrap.
+ # SigLevel=Never: pacstrap -K creates empty keyring where key import
+ # fails; repo is explicitly added and served over HTTPS, GPG adds no
+ # real value here.
+ if [[ "$FILESYSTEM" == "zfs" ]]; then
+ if ! grep -q "\[archzfs\]" /etc/pacman.conf; then
+ cat >> /etc/pacman.conf << 'EOF'
[archzfs]
Server = https://github.com/archzfs/archzfs/releases/download/experimental
SigLevel = Never
EOF
+ fi
+ info "ZFS will be built from source via DKMS - this ensures kernel compatibility."
fi
info "Installing base packages (this takes a while)..."
- info "ZFS will be built from source via DKMS - this ensures kernel compatibility."
- # Use yes to auto-select defaults for provider prompts
- yes "" | pacstrap -K /mnt \
- base \
- base-devel \
- linux-lts \
- linux-lts-headers \
- linux-firmware \
- zfs-dkms \
- zfs-utils \
- efibootmgr \
- networkmanager \
- avahi \
- nss-mdns \
- openssh \
- git \
- vim \
- sudo \
- zsh \
- nodejs \
- npm \
- ttf-dejavu \
- fzf \
- wget \
- inetutils \
- wireless-regdb
- info "Base system installed."
-}
-
-install_base_btrfs() {
- step "Installing Base System (Btrfs)"
+ local packages
+ mapfile -t packages < <(pacstrap_packages "$FILESYSTEM") \
+ || error "Unknown filesystem: $FILESYSTEM"
- info "Updating pacman keys..."
- pacman-key --init
- pacman-key --populate archlinux
-
- info "Installing base packages (this takes a while)..."
- yes "" | pacstrap -K /mnt \
- base \
- base-devel \
- linux-lts \
- linux-lts-headers \
- linux-firmware \
- btrfs-progs \
- grub \
- grub-btrfs \
- efibootmgr \
- snapper \
- snap-pac \
- networkmanager \
- avahi \
- nss-mdns \
- openssh \
- git \
- vim \
- sudo \
- zsh \
- nodejs \
- npm \
- ttf-dejavu \
- fzf \
- wget \
- inetutils \
- wireless-regdb
+ # Use yes to auto-select defaults for provider prompts
+ yes "" | pacstrap -K /mnt "${packages[@]}"
info "Base system installed."
}
@@ -1614,7 +1560,7 @@ install_btrfs() {
mount "${efi_parts[0]}" /mnt/efi
# Install base system
- install_base_btrfs
+ install_base
# Configure system
configure_system
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
@@ -57,6 +57,34 @@ require_command() {
}
#############################
+# 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
#############################
diff --git a/tests/unit/test_common.bats b/tests/unit/test_common.bats
index f0e3e21..04f4e09 100644
--- a/tests/unit/test_common.bats
+++ b/tests/unit/test_common.bats
@@ -88,6 +88,69 @@ setup() {
}
#############################
+# pacstrap_packages
+#############################
+
+@test "pacstrap_packages zfs includes zfs-dkms and zfs-utils" {
+ run pacstrap_packages zfs
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"zfs-dkms"* ]]
+ [[ "$output" == *"zfs-utils"* ]]
+}
+
+@test "pacstrap_packages btrfs includes btrfs-progs, grub, grub-btrfs, snapper, snap-pac" {
+ run pacstrap_packages btrfs
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"btrfs-progs"* ]]
+ [[ "$output" == *"grub"* ]]
+ [[ "$output" == *"grub-btrfs"* ]]
+ [[ "$output" == *"snapper"* ]]
+ [[ "$output" == *"snap-pac"* ]]
+}
+
+@test "pacstrap_packages zfs excludes Btrfs-specific packages" {
+ run pacstrap_packages zfs
+ [ "$status" -eq 0 ]
+ [[ "$output" != *"btrfs-progs"* ]]
+ [[ "$output" != *"grub-btrfs"* ]]
+ [[ "$output" != *"snapper"* ]]
+}
+
+@test "pacstrap_packages btrfs excludes ZFS-specific packages" {
+ run pacstrap_packages btrfs
+ [ "$status" -eq 0 ]
+ [[ "$output" != *"zfs-dkms"* ]]
+ [[ "$output" != *"zfs-utils"* ]]
+}
+
+@test "pacstrap_packages includes common packages for both filesystems" {
+ for fs in zfs btrfs; do
+ run pacstrap_packages "$fs"
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"base"* ]]
+ [[ "$output" == *"linux-lts"* ]]
+ [[ "$output" == *"efibootmgr"* ]]
+ [[ "$output" == *"networkmanager"* ]]
+ [[ "$output" == *"openssh"* ]]
+ [[ "$output" == *"inetutils"* ]]
+ done
+}
+
+@test "pacstrap_packages unknown filesystem returns status 1" {
+ run pacstrap_packages reiserfs
+ [ "$status" -eq 1 ]
+ [ -z "$output" ]
+}
+
+@test "pacstrap_packages emits one package per line" {
+ run pacstrap_packages zfs
+ [ "$status" -eq 0 ]
+ local expected_lines
+ expected_lines=$(echo "$output" | wc -l)
+ [ "$expected_lines" -ge 20 ]
+}
+
+#############################
# prompt_password
#############################