diff --git a/bin/omarchy-channel-set b/bin/omarchy-channel-set index 60200f97..93f05bc9 100755 --- a/bin/omarchy-channel-set +++ b/bin/omarchy-channel-set @@ -55,10 +55,15 @@ validate_dev_region() { [[ -f $region_file ]] && region=$(<"$region_file") [[ $region == "global" ]] && return 0 - # The refresh after linking needs a runnable helper and the edge fragments - # dev uses, not just a directory with the region's name. - local profile="$checkout/default/regions/$region/pacman" - if [[ ! -x $checkout/bin/omarchy-apply-pacman || ! -r $profile/pacman.conf.append || ! -r $profile/mirrorlist-edge.prepend ]]; then + # The refresh after linking needs a runnable helper and every fragment, not + # just a directory with the region's name: dev refreshes edge, and leaving + # dev later refreshes stable or rc with this checkout's tools. + local profile="$checkout/default/regions/$region/pacman" fragment supported=true + [[ -x $checkout/bin/omarchy-apply-pacman ]] || supported=false + for fragment in pacman.conf.append mirrorlist-stable.prepend mirrorlist-rc.prepend mirrorlist-edge.prepend; do + [[ -r $profile/$fragment ]] || supported=false + done + if ! $supported; then fail "$checkout does not support the '$region' region, so switching would drop its package repositories. Check out a branch with default/regions/$region, or remove $region_file to use global defaults." fi } diff --git a/test/shell.d/channel-test.sh b/test/shell.d/channel-test.sh index fb670e3e..791ff2e9 100644 --- a/test/shell.d/channel-test.sh +++ b/test/shell.d/channel-test.sh @@ -213,7 +213,23 @@ if grep -Eq $'^(link|refresh)\t' "$log_file"; then fail "dev refuses an empty region profile before linking or refreshing pacman" "$(cat "$log_file")" fi mkdir -p "$checkout/default/regions/cn/pacman" -touch "$checkout/default/regions/cn/pacman/pacman.conf.append" "$checkout/default/regions/cn/pacman/mirrorlist-edge.prepend" +cn_fragments=(pacman.conf.append mirrorlist-stable.prepend mirrorlist-rc.prepend mirrorlist-edge.prepend) +for missing in "${cn_fragments[@]}"; do + for fragment in "${cn_fragments[@]}"; do + if [[ $fragment == "$missing" ]]; then + rm -f "$checkout/default/regions/cn/pacman/$fragment" + else + touch "$checkout/default/regions/cn/pacman/$fragment" + fi + done + if OMARCHY_TEST_REGION_FILE="$test_tmp/region" run_channel dev >"$test_tmp/region.out" 2>"$test_tmp/region.err"; then + fail "dev refuses a region profile without $missing" + fi + if grep -Eq $'^(link|refresh)\t' "$log_file"; then + fail "dev refuses a profile without $missing before linking or refreshing pacman" "$(cat "$log_file")" + fi +done +touch "${cn_fragments[@]/#/$checkout/default/regions/cn/pacman/}" chmod -x "$checkout/bin/omarchy-apply-pacman" if OMARCHY_TEST_REGION_FILE="$test_tmp/region" run_channel dev >"$test_tmp/region.out" 2>"$test_tmp/region.err"; then fail "dev refuses a checkout whose pacman helper cannot run" @@ -221,7 +237,7 @@ fi if grep -Eq $'^(link|refresh)\t' "$log_file"; then fail "dev refuses incomplete region support before linking or refreshing pacman" "$(cat "$log_file")" fi -pass "dev refuses an empty region profile or a helper that cannot run" +pass "dev refuses a region profile missing any fragment or a helper that cannot run" chmod +x "$checkout/bin/omarchy-apply-pacman" OMARCHY_TEST_REGION_FILE="$test_tmp/region" run_channel dev