Merge reworked #13690: timezone-derived region and channel mirror prepends

Drop the .cn servers.sed twins, the USTC Arch fallback and the closed
#14399 timezone preselection. region.sh follows the installer's marker.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-08 22:43:55 -04:00
commit 4521dac023
25 files changed
+150 -206

No files matched your search

+10 -33
View File
@@ -7,35 +7,6 @@ source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
test_tmp=$(mktemp -d)
trap 'rm -rf "$test_tmp"' EXIT
china_sed="$ROOT/default/regions/cn/pacman/servers.sed"
expected_stable_omarchy='Server = https://pkgs.omarchy.cn/stable/$arch
Server = https://pkgs.omarchy.org/stable/$arch'
actual=$(sed -f "$china_sed" "$ROOT/default/pacman/pacman-stable.conf" | sed -n '/^\[omarchy\]/,/^$/p' | grep '^Server')
[[ $actual == "$expected_stable_omarchy" ]] || fail "stable [omarchy] lists pkgs.omarchy.cn before pkgs.omarchy.org" "$actual"
pass "stable [omarchy] lists pkgs.omarchy.cn before pkgs.omarchy.org"
declare -A mirrors=([stable]=stable-mirror [rc]=rc-mirror [edge]=mirror)
for channel in stable rc edge; do
host=${mirrors[$channel]}
expected="Server = https://$host.omarchy.cn/\$repo/os/\$arch
Server = https://$host.omarchy.org/\$repo/os/\$arch"
actual=$(sed -f "$china_sed" "$ROOT/default/pacman/mirrorlist-$channel")
[[ $actual == "$expected" ]] || fail "$channel mirrorlist lists $host.omarchy.cn first" "$actual"
pass "$channel mirrorlist lists $host.omarchy.cn first"
for file in "pacman-$channel.conf" "mirrorlist-$channel"; do
original=$(<"$ROOT/default/pacman/$file")
stripped=$(sed -f "$china_sed" "$ROOT/default/pacman/$file" | grep -v '^Server = https://[a-z-]*\.omarchy\.cn/')
[[ $stripped == "$original" ]] || fail "$file only gains .cn servers" "$(diff <(echo "$original") <(echo "$stripped"))"
org_count=$(grep -c '^Server = https://[a-z-]*\.omarchy\.org/' "$ROOT/default/pacman/$file")
cn_count=$(sed -f "$china_sed" "$ROOT/default/pacman/$file" | grep -c '^Server = https://[a-z-]*\.omarchy\.cn/')
((org_count > 0 && org_count == cn_count)) || fail "$file gets one .cn twin per .org server" "org=$org_count cn=$cn_count"
done
pass "$channel templates only gain one .cn twin per .org server"
done
region_bin="$test_tmp/omarchy-region"
region_file="$test_tmp/region"
sed "s|/etc/omarchy/region|$region_file|" "$ROOT/bin/omarchy-region" >"$region_bin"
@@ -126,15 +97,21 @@ fi
[[ ! -e $root/etc/omarchy/region && ! -e $root/etc/gemrc && $(<"$root/etc/locale.conf") == "LANG=en_US.UTF-8" ]] ||
fail "a failed package install leaves the machine Global"
pass "China installs its packages before it writes any region state"
OMARCHY_REGION=cn bash -e "$region_setup"
echo cn >"$root/etc/omarchy/region"
: >"$calls"
env -u OMARCHY_REGION bash -e "$region_setup"
[[ ! -e $root/etc/omarchy/region ]] || fail "an installer that passes no region installs Global"
pass "Global and an unset region leave no region file"
[[ $(<"$root/etc/omarchy/region") == "cn" && $(readlink "$root/etc/gemrc") == "$ROOT/default/regions/cn/gemrc" ]] ||
fail "install keeps the cn marker the installer wrote and links its drop-ins"
pass "install follows the region marker the installer wrote"
OMARCHY_REGION=global bash -e "$region_setup"
env -u OMARCHY_REGION bash -e "$region_setup"
[[ ! -e $root/etc/omarchy/region && ! -e $root/etc/gemrc ]] || fail "no marker installs Global"
pass "no marker installs Global"
if output=$(OMARCHY_REGION=mars bash -e "$region_setup" 2>&1); then
fail "install rejects an unknown region" "$output"
fi
[[ $output == "Unknown OMARCHY_REGION: mars" ]] || fail "install names the unknown region" "$output"
[[ $output == "Unknown region: mars" ]] || fail "install names the unknown region" "$output"
pass "install rejects an unknown region"
user_region="$ROOT/install/user/region.sh"