Align the China region to the official cn profile

The region value is cn, the China files live under default/regions/cn/, and
omarchy-apply-pacman renders pacman for every caller: the .cn twins of the
channel servers first, then .org, USTC and ArchLinuxCN. Switching to China
installs and trusts the ArchLinuxCN keyring. A migration renames china to cn
and repoints the drop-in links.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-07 11:33:01 -04:00
1 parent d2e4a95aed
commit 9a57690e7d
20 files changed
+119 -99

No files matched your search

+4
View File
@@ -56,6 +56,10 @@ cp "$OMARCHY_PATH/default/pacman/pacman-$channel.conf" "$staging/pacman.conf"
cp "$OMARCHY_PATH/default/pacman/mirrorlist-$channel" "$staging/mirrorlist"
if [[ $region != "global" ]]; then
profile="$OMARCHY_PATH/default/regions/$region/pacman"
# A region's own copies of the channel servers go ahead of them.
if [[ -r $profile/servers.sed ]]; then
sed -i -f "$profile/servers.sed" "$staging/pacman.conf" "$staging/mirrorlist"
fi
printf '\n' >> "$staging/pacman.conf"
cat "$profile/pacman.conf.append" >> "$staging/pacman.conf"
cat "$profile/mirrorlist.append" >> "$staging/mirrorlist"
+20 -15
View File
@@ -1,8 +1,8 @@
#!/bin/bash
# omarchy:summary=Show or switch the region this machine is set up for
# omarchy:args=[global|china]
# omarchy:examples=omarchy region | omarchy region china
# omarchy:args=[global|cn]
# omarchy:examples=omarchy region | omarchy region cn
# omarchy:requires-sudo=true
set -euo pipefail
@@ -12,7 +12,7 @@ region_file=/etc/omarchy/region
if (($# == 0)); then
if [[ ! -e $region_file ]]; then
echo "Global"
elif [[ $(<"$region_file") == "china" ]]; then
elif [[ $(<"$region_file") == "cn" ]]; then
echo "China"
else
echo "Unknown region in $region_file: $(<"$region_file")" >&2
@@ -21,34 +21,39 @@ if (($# == 0)); then
exit 0
fi
if [[ $1 != "global" && $1 != "china" ]]; then
echo "Usage: omarchy-region [global|china]" >&2
if [[ $1 != "global" && $1 != "cn" ]]; then
echo "Usage: omarchy-region [global|cn]" >&2
exit 1
fi
pacman_files=(/etc/pacman.conf /etc/pacman.d/mirrorlist)
drop_cn_servers='/^Server = https:\/\/[a-z-]*\.omarchy\.cn\//d'
channel=$(omarchy-version-channel)
if [[ $channel != "stable" && $channel != "rc" && $channel != "edge" ]]; then
echo "Cannot tell this machine's package channel ($channel); run omarchy channel set first" >&2
exit 1
fi
if [[ $1 == "china" ]]; then
# Mirrors move last, so a failed setup leaves the machine wholly Global.
if [[ $1 == "cn" ]]; then
# Packages first against current mirrors, so a failed install leaves the machine Global.
omarchy-update-pacman -Syu --noconfirm
sudo env OMARCHY_REGION=china OMARCHY_PATH="$OMARCHY_PATH" bash -e "$OMARCHY_PATH/install/config/region.sh"
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 env OMARCHY_REGION=cn OMARCHY_PATH="$OMARCHY_PATH" bash -e "$OMARCHY_PATH/install/config/region.sh"
# The refresh renders the cn profile: .cn mirrors first, USTC after, and ArchLinuxCN, whose keyring comes from it.
omarchy-refresh-pacman "$channel"
mapfile -t profile_packages < <(grep -Ev '^[[:space:]]*(#|$)' "$OMARCHY_PATH/default/regions/cn/packages")
omarchy-pkg-add "${profile_packages[@]}"
sudo pacman-key --populate archlinuxcn
if [[ ! -f $HOME/.local/share/fcitx5/rime/rime_ice.schema.yaml ]]; then
# A running fcitx5 only sees the new Rime addon after a restart.
systemctl --user try-restart omarchy-fcitx5.service
rime-ice-installer --yes
fi
else
sudo sed -i -e "$drop_cn_servers" "${pacman_files[@]}"
echo "Package mirrors -> .org only"
sudo env OMARCHY_REGION=global OMARCHY_PATH="$OMARCHY_PATH" bash -e "$OMARCHY_PATH/install/config/region.sh"
omarchy-refresh-pacman "$channel"
omarchy-setup-claude-api --remove
fi
# The language and the developer mirrors reach only a new session, so offer one in the new language.
if [[ $1 == "china" ]]; then
if [[ $1 == "cn" ]]; then
prompt="立即注销,切换到中文界面和国内镜像?" log_out="立即注销" later="稍后"
reminder="区域已设为中国。重新登录后切换到中文界面和国内镜像。"
else