From a15a92cf36d2460784587b3fa6f586e94e9ff6ab Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 13 Apr 2026 00:16:04 -0400 Subject: refactor: decompose install_btrfs into named orchestration stages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pull the single-vs-multi-disk and LUKS-vs-no-encryption branching out of install_btrfs() into five helpers in lib/btrfs.sh: - btrfs_open_encryption — LUKS open + fill devices array - btrfs_make_filesystem — create_btrfs_volume dispatch - btrfs_configure_luks_target — in-chroot LUKS config - btrfs_install_grub — GRUB primary + multi-disk mirror - btrfs_close_encryption — LUKS close (cleanup) Helpers use namerefs (local -n) to take the caller's arrays as locals instead of promoting them to globals. install_btrfs() drops from ~99 lines of nested if-then-else to a ~45-line flat sequence of named stages — matching the style of install_zfs(). Behavior preserved — this is pure code movement, no new disk/LUKS operations. No unit tests added for the new helpers: they all wrap real LUKS/mkfs.btrfs calls that need block devices and root; VM integration tests in scripts/test-install.sh remain the source of truth. .shellcheckrc: disable SC2178 (nameref array heuristic) and SC2153 (globals from sourced files) — both recurring false positives. make test: 65/65. shellcheck clean. --- .shellcheckrc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to '.shellcheckrc') diff --git a/.shellcheckrc b/.shellcheckrc index c2d8dfd..7f7a9b1 100644 --- a/.shellcheckrc +++ b/.shellcheckrc @@ -17,5 +17,7 @@ # SC2143 - Use grep -q (stylistic) # SC2207 - Prefer mapfile (arrays from command output) # SC1003 - False positive on escaped single quotes in case patterns +# SC2178 - Nameref (local -n) tripping array-vs-string heuristic +# SC2153 - Global vars set in other sourced files look unset to shellcheck -disable=SC2034,SC2086,SC2162,SC2016,SC2317,SC2012,SC1091,SC2329,SC2011,SC2010,SC2129,SC2001,SC2059,SC2143,SC2207,SC1003 +disable=SC2034,SC2086,SC2162,SC2016,SC2317,SC2012,SC1091,SC2329,SC2011,SC2010,SC2129,SC2001,SC2059,SC2143,SC2207,SC1003,SC2178,SC2153 -- cgit v1.2.3