From 07d5f499633a95c5e810b726b1c08c7d1f6b070e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Tue, 6 Oct 2026 00:52:28 -0400 Subject: [PATCH] Rebuild .cn twins per server and leave database syncs to omarchy update --- bin/omarchy-region | 11 +++-------- test/shell.d/region-switch-test.sh | 14 +++++++++++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/bin/omarchy-region b/bin/omarchy-region index f3006f40..8fa696d2 100755 --- a/bin/omarchy-region +++ b/bin/omarchy-region @@ -27,23 +27,18 @@ if [[ $1 != "global" && $1 != "china" ]]; then fi pacman_files=(/etc/pacman.conf /etc/pacman.d/mirrorlist) +drop_cn_servers='/^Server = https:\/\/[a-z-]*\.omarchy\.cn\//d' if [[ $1 == "china" ]]; then - for file in "${pacman_files[@]}"; do - if ! grep -q '^Server = https://[a-z-]*\.omarchy\.cn/' "$file"; then - sudo sed -i -f "$OMARCHY_PATH/default/region/china/pacman.sed" "$file" - fi - done + sudo sed -i -e "$drop_cn_servers" -f "$OMARCHY_PATH/default/region/china/pacman.sed" "${pacman_files[@]}" echo "Package mirrors -> .cn first, .org after" - sudo pacman -Sy sudo env OMARCHY_REGION=china OMARCHY_PATH="$OMARCHY_PATH" bash -e "$OMARCHY_PATH/install/config/region.sh" if [[ ! -f $HOME/.local/share/fcitx5/rime/rime_ice.schema.yaml ]]; then rime-ice-installer --yes fi else - sudo sed -i '/^Server = https:\/\/[a-z-]*\.omarchy\.cn\//d' "${pacman_files[@]}" + sudo sed -i -e "$drop_cn_servers" "${pacman_files[@]}" echo "Package mirrors -> .org only" - sudo pacman -Sy sudo env OMARCHY_REGION=global OMARCHY_PATH="$OMARCHY_PATH" bash -e "$OMARCHY_PATH/install/config/region.sh" omarchy-setup-claude-api --remove fi diff --git a/test/shell.d/region-switch-test.sh b/test/shell.d/region-switch-test.sh index a58f4c38..ed056a01 100755 --- a/test/shell.d/region-switch-test.sh +++ b/test/shell.d/region-switch-test.sh @@ -33,8 +33,8 @@ omarchy-region china >/dev/null [[ $(<"$root/etc/pacman.conf") == "$china_conf" && $(<"$root/etc/pacman.d/mirrorlist") == "$china_mirrors" ]] || fail "switching to China lists the .cn mirrors first" [[ $(omarchy-region) == "China" && $(<"$root/etc/locale.conf") == "LANG=zh_CN.UTF-8" ]] || fail "switching to China records it and sets the language" -[[ $(<"$calls") == $'pacman -Sy\nomarchy-pkg-add fcitx5-configtool fcitx5-rime librime opencc rime-ice-installer\nlocale-gen \nrime-ice-installer --yes' ]] || - fail "China syncs the .cn databases before installing Rime, then sets Rime Ice up" "$(<"$calls")" +[[ $(<"$calls") == $'omarchy-pkg-add fcitx5-configtool fcitx5-rime librime opencc rime-ice-installer\nlocale-gen \nrime-ice-installer --yes' ]] || + fail "China installs Rime without a partial database sync, then sets Rime Ice up" "$(<"$calls")" pass "switching to China sets mirrors, language and Rime Ice" : >"$calls" @@ -45,12 +45,20 @@ omarchy-region china >/dev/null grep -q '^rime-ice-installer' "$calls" && fail "an existing Rime Ice setup is not redone" pass "switching to China again changes nothing it already did" +printf 'Server = https://stable-mirror.omarchy.cn/$repo/os/$arch\nServer = https://stable-mirror.omarchy.org/$repo/os/$arch\nServer = https://mirror.omarchy.org/$repo/os/$arch\n' >"$root/etc/pacman.d/mirrorlist" +omarchy-region china >/dev/null +[[ $(<"$root/etc/pacman.d/mirrorlist") == $'Server = https://stable-mirror.omarchy.cn/$repo/os/$arch\nServer = https://stable-mirror.omarchy.org/$repo/os/$arch\nServer = https://mirror.omarchy.cn/$repo/os/$arch\nServer = https://mirror.omarchy.org/$repo/os/$arch' ]] || + fail "a partly switched mirrorlist gets every missing .cn twin" "$(<"$root/etc/pacman.d/mirrorlist")" +cp "$ROOT/default/pacman/mirrorlist-stable" "$root/etc/pacman.d/mirrorlist" +sed -i -f "$ROOT/default/region/china/pacman.sed" "$root/etc/pacman.d/mirrorlist" +pass "every .org server ends up with exactly one .cn twin in front" + : >"$calls" omarchy-region global >/dev/null [[ $(<"$root/etc/pacman.conf") == "$(<"$ROOT/default/pacman/pacman-stable.conf")" && $(<"$root/etc/pacman.d/mirrorlist") == "$(<"$ROOT/default/pacman/mirrorlist-stable")" ]] || fail "switching to Global drops exactly the .cn mirrors" [[ $(omarchy-region) == "Global" && $(<"$root/etc/locale.conf") == "LANG=en_US.UTF-8" ]] || fail "switching to Global records it and restores English" -[[ $(<"$calls") == $'pacman -Sy\nomarchy-setup-claude-api --remove' ]] || fail "Global removes the Claude Code third-party API and keeps Rime" "$(<"$calls")" +[[ $(<"$calls") == "omarchy-setup-claude-api --remove" ]] || fail "Global removes the Claude Code third-party API and keeps Rime" "$(<"$calls")" [[ -f $HOME/.local/share/fcitx5/rime/rime_ice.schema.yaml ]] || fail "Global keeps the input method" pass "switching to Global restores mirrors and language, keeps Rime, removes the Claude API setup"