aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test_common.bats
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-27 22:08:28 -0400
committerCraig Jennings <c@cjennings.net>2026-06-27 22:08:28 -0400
commit2ead67458add6accda226cca3e21592162d05bfd (patch)
tree0f180ac7f1132d1e8dc6b1845e4d48e622f4eee4 /tests/unit/test_common.bats
parent89691a0dc9eb7dcbf8583797d7cdc34aecec0d56 (diff)
downloadarchangel-2ead67458add6accda226cca3e21592162d05bfd.tar.gz
archangel-2ead67458add6accda226cca3e21592162d05bfd.zip
fix(installer): scope AUR list to filesystem, keep pacman.conf 0644HEADmain
The baked AUR set installed unconditionally, so zfs-auto-snapshot reached every target. On a btrfs install there's no zfs to satisfy its dependency, and pacstrap aborted the whole transaction. The ISO still bakes the full set. install_base now filters the manifest names through filter_aur_for_fs, dropping zfs-only tooling (zfs-auto-snapshot, zrepl) on a non-zfs target. strip_repo_stanza mv'd a 0600 mktemp file onto the target, so a clean install shipped /etc/pacman.conf root-only and every user-level makepkg/yay failed to read it. It now truncate-writes through the existing file, preserving the pristine 0644. Tested in test_common.bats.
Diffstat (limited to 'tests/unit/test_common.bats')
-rw-r--r--tests/unit/test_common.bats70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/unit/test_common.bats b/tests/unit/test_common.bats
index 6f9d1b1..c76b6a4 100644
--- a/tests/unit/test_common.bats
+++ b/tests/unit/test_common.bats
@@ -666,6 +666,26 @@ Boot0001* ZFSBootMenu"
rm -f "$f"
}
+@test "strip_repo_stanza preserves the target file mode (no 0600 clobber)" {
+ local f
+ f=$(mktemp)
+ printf '%s\n' '[core]' '[aur]' 'Server = file:///usr/share/aur-packages' '[extra]' > "$f"
+ chmod 644 "$f"
+ strip_repo_stanza aur "$f"
+ [ "$(stat -c %a "$f")" = "644" ]
+ rm -f "$f"
+}
+
+@test "strip_repo_stanza preserves a non-default file mode" {
+ local f
+ f=$(mktemp)
+ printf '%s\n' '[core]' '[aur]' 'Server = x' '[extra]' > "$f"
+ chmod 640 "$f"
+ strip_repo_stanza aur "$f"
+ [ "$(stat -c %a "$f")" = "640" ]
+ rm -f "$f"
+}
+
#############################
# aur_repo_available
#############################
@@ -720,3 +740,53 @@ Boot0001* ZFSBootMenu"
[ "$status" -eq 0 ]
[ -z "$output" ]
}
+
+#############################
+# aur_zfs_only_packages / filter_aur_for_fs
+#############################
+
+@test "aur_zfs_only_packages lists zfs-auto-snapshot and zrepl" {
+ run aur_zfs_only_packages
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"zfs-auto-snapshot"* ]]
+ [[ "$output" == *"zrepl"* ]]
+}
+
+@test "filter_aur_for_fs zfs keeps every package including zfs-only tooling" {
+ run filter_aur_for_fs zfs downgrade yay zrepl zfs-auto-snapshot topgrade
+ [ "$status" -eq 0 ]
+ [ "${#lines[@]}" -eq 5 ]
+ [[ "$output" == *"zfs-auto-snapshot"* ]]
+ [[ "$output" == *"zrepl"* ]]
+ [[ "$output" == *"yay"* ]]
+}
+
+@test "filter_aur_for_fs btrfs drops zfs-only tooling, keeps the rest" {
+ run filter_aur_for_fs btrfs downgrade yay zrepl zfs-auto-snapshot topgrade
+ [ "$status" -eq 0 ]
+ [ "${#lines[@]}" -eq 3 ]
+ [[ "$output" != *"zfs-auto-snapshot"* ]]
+ [[ "$output" != *"zrepl"* ]]
+ [[ "$output" == *"downgrade"* ]]
+ [[ "$output" == *"yay"* ]]
+ [[ "$output" == *"topgrade"* ]]
+}
+
+@test "filter_aur_for_fs btrfs with only zfs-only tooling prints nothing" {
+ run filter_aur_for_fs btrfs zfs-auto-snapshot zrepl
+ [ "$status" -eq 0 ]
+ [ -z "$output" ]
+}
+
+@test "filter_aur_for_fs with no package arguments prints nothing" {
+ run filter_aur_for_fs btrfs
+ [ "$status" -eq 0 ]
+ [ -z "$output" ]
+}
+
+@test "filter_aur_for_fs preserves input order" {
+ run filter_aur_for_fs zfs yay downgrade topgrade
+ [ "$status" -eq 0 ]
+ [ "${lines[0]}" = "yay" ]
+ [ "${lines[2]}" = "topgrade" ]
+}