✨ feat(region): put the china channel mirrors first
- ✨ omarchy now runs per-channel china replicas, so they should lead instead of trailing as a fallback - ♻️ prepend per-channel fragments so each channel's own mirror stays the fallback - 🔥 drop the ustc arch mirror, which was never a stable or rc snapshot replica Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QuATgjU4mnqpqSLAKMQ14g
This commit is contained in:
1 parent
b89def6c7f
commit
3c68a1bb04
9 files changed
+22
-17
No files matched your search
@@ -53,12 +53,15 @@ else
|
|||||||
trap 'rm -rf "$staging"' EXIT
|
trap 'rm -rf "$staging"' EXIT
|
||||||
fi
|
fi
|
||||||
cp "$OMARCHY_PATH/default/pacman/pacman-$channel.conf" "$staging/pacman.conf"
|
cp "$OMARCHY_PATH/default/pacman/pacman-$channel.conf" "$staging/pacman.conf"
|
||||||
cp "$OMARCHY_PATH/default/pacman/mirrorlist-$channel" "$staging/mirrorlist"
|
if [[ $region == "global" ]]; then
|
||||||
if [[ $region != "global" ]]; then
|
cp "$OMARCHY_PATH/default/pacman/mirrorlist-$channel" "$staging/mirrorlist"
|
||||||
|
else
|
||||||
profile="$OMARCHY_PATH/default/regions/$region/pacman"
|
profile="$OMARCHY_PATH/default/regions/$region/pacman"
|
||||||
printf '\n' >> "$staging/pacman.conf"
|
printf '\n' >> "$staging/pacman.conf"
|
||||||
cat "$profile/pacman.conf.append" >> "$staging/pacman.conf"
|
cat "$profile/pacman.conf.append" >> "$staging/pacman.conf"
|
||||||
cat "$profile/mirrorlist.append" >> "$staging/mirrorlist"
|
# pacman tries servers in order, so the regional mirror leads and the
|
||||||
|
# channel's own mirror stays as the fallback.
|
||||||
|
cat "$profile/mirrorlist-$channel.prepend" "$OMARCHY_PATH/default/pacman/mirrorlist-$channel" > "$staging/mirrorlist"
|
||||||
fi
|
fi
|
||||||
[[ -z $render_dir ]] || exit 0
|
[[ -z $render_dir ]] || exit 0
|
||||||
|
|
||||||
|
|||||||
@@ -55,10 +55,10 @@ validate_dev_region() {
|
|||||||
[[ -f $region_file ]] && region=$(<"$region_file")
|
[[ -f $region_file ]] && region=$(<"$region_file")
|
||||||
[[ $region == "global" ]] && return 0
|
[[ $region == "global" ]] && return 0
|
||||||
|
|
||||||
# The refresh after linking needs a runnable helper and both fragments, not
|
# The refresh after linking needs a runnable helper and the edge fragments
|
||||||
# just a directory with the region's name.
|
# dev uses, not just a directory with the region's name.
|
||||||
local profile="$checkout/default/regions/$region/pacman"
|
local profile="$checkout/default/regions/$region/pacman"
|
||||||
if [[ ! -x $checkout/bin/omarchy-apply-pacman || ! -r $profile/pacman.conf.append || ! -r $profile/mirrorlist.append ]]; then
|
if [[ ! -x $checkout/bin/omarchy-apply-pacman || ! -r $profile/pacman.conf.append || ! -r $profile/mirrorlist-edge.prepend ]]; 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."
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Server = https://mirror.omarchy.cn/$repo/os/$arch
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Server = https://rc-mirror.omarchy.cn/$repo/os/$arch
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Server = https://stable-mirror.omarchy.cn/$repo/os/$arch
|
||||||
@@ -1 +0,0 @@
|
|||||||
Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
|
|
||||||
@@ -213,7 +213,7 @@ if grep -Eq $'^(link|refresh)\t' "$log_file"; then
|
|||||||
fail "dev refuses an empty region profile before linking or refreshing pacman" "$(cat "$log_file")"
|
fail "dev refuses an empty region profile before linking or refreshing pacman" "$(cat "$log_file")"
|
||||||
fi
|
fi
|
||||||
mkdir -p "$checkout/default/regions/cn/pacman"
|
mkdir -p "$checkout/default/regions/cn/pacman"
|
||||||
touch "$checkout/default/regions/cn/pacman/pacman.conf.append" "$checkout/default/regions/cn/pacman/mirrorlist.append"
|
touch "$checkout/default/regions/cn/pacman/pacman.conf.append" "$checkout/default/regions/cn/pacman/mirrorlist-edge.prepend"
|
||||||
chmod -x "$checkout/bin/omarchy-apply-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
|
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"
|
fail "dev refuses a checkout whose pacman helper cannot run"
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ pass "refresh keeps existing config file modes"
|
|||||||
printf 'cn\n' > "$TARGET_ROOT/etc/omarchy/region"
|
printf 'cn\n' > "$TARGET_ROOT/etc/omarchy/region"
|
||||||
for channel in stable rc edge; do
|
for channel in stable rc edge; do
|
||||||
case "$channel" in
|
case "$channel" in
|
||||||
stable) host=stable-mirror.omarchy.org ;;
|
stable) host=stable-mirror.omarchy ;;
|
||||||
rc) host=rc-mirror.omarchy.org ;;
|
rc) host=rc-mirror.omarchy ;;
|
||||||
edge) host=mirror.omarchy.org ;;
|
edge) host=mirror.omarchy ;;
|
||||||
esac
|
esac
|
||||||
apply "$channel"
|
apply "$channel"
|
||||||
expected=$(printf 'Server = https://%s/$repo/os/$arch\nServer = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch' "$host")
|
expected=$(printf 'Server = https://%s.cn/$repo/os/$arch\nServer = https://%s.org/$repo/os/$arch' "$host" "$host")
|
||||||
[[ $(<"$TARGET_ROOT/etc/pacman.d/mirrorlist") == "$expected" ]] || fail "$channel mirror order and variables"
|
[[ $(<"$TARGET_ROOT/etc/pacman.d/mirrorlist") == "$expected" ]] || fail "$channel mirror order and variables"
|
||||||
{
|
{
|
||||||
cat "$ROOT/default/pacman/pacman-$channel.conf"
|
cat "$ROOT/default/pacman/pacman-$channel.conf"
|
||||||
@@ -43,7 +43,7 @@ for channel in stable rc edge; do
|
|||||||
cmp "$TARGET_ROOT/etc/pacman.conf.bak" "$TARGET_ROOT/etc/pacman.conf"
|
cmp "$TARGET_ROOT/etc/pacman.conf.bak" "$TARGET_ROOT/etc/pacman.conf"
|
||||||
cmp "$TARGET_ROOT/etc/pacman.d/mirrorlist.bak" "$TARGET_ROOT/etc/pacman.d/mirrorlist"
|
cmp "$TARGET_ROOT/etc/pacman.d/mirrorlist.bak" "$TARGET_ROOT/etc/pacman.d/mirrorlist"
|
||||||
done
|
done
|
||||||
pass "China keeps each channel first, appends only CN defaults, and is idempotent"
|
pass "China puts its channel mirror first, keeps the global one as fallback, and is idempotent"
|
||||||
|
|
||||||
cp "$TARGET_ROOT/etc/pacman.conf" "$scratch/before.conf"
|
cp "$TARGET_ROOT/etc/pacman.conf" "$scratch/before.conf"
|
||||||
cp "$TARGET_ROOT/etc/pacman.d/mirrorlist" "$scratch/before.mirrors"
|
cp "$TARGET_ROOT/etc/pacman.d/mirrorlist" "$scratch/before.mirrors"
|
||||||
@@ -75,8 +75,8 @@ mkdir -p "$scratch/rendered"
|
|||||||
"$ROOT/bin/omarchy-apply-pacman" --render rc "$scratch/rendered" "$TARGET_ROOT"
|
"$ROOT/bin/omarchy-apply-pacman" --render rc "$scratch/rendered" "$TARGET_ROOT"
|
||||||
rg -qxF 'Server = https://pkgs.omarchy.org/rc/$arch' "$scratch/rendered/pacman.conf"
|
rg -qxF 'Server = https://pkgs.omarchy.org/rc/$arch' "$scratch/rendered/pacman.conf"
|
||||||
rg -qxF '[archlinuxcn]' "$scratch/rendered/pacman.conf"
|
rg -qxF '[archlinuxcn]' "$scratch/rendered/pacman.conf"
|
||||||
[[ $(<"$scratch/rendered/mirrorlist") == $'Server = https://rc-mirror.omarchy.org/$repo/os/$arch\nServer = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch' ]] ||
|
[[ $(<"$scratch/rendered/mirrorlist") == $'Server = https://rc-mirror.omarchy.cn/$repo/os/$arch\nServer = https://rc-mirror.omarchy.org/$repo/os/$arch' ]] ||
|
||||||
fail "render keeps the channel mirror first"
|
fail "render puts the regional channel mirror first"
|
||||||
cmp "$scratch/before.conf" "$TARGET_ROOT/etc/pacman.conf"
|
cmp "$scratch/before.conf" "$TARGET_ROOT/etc/pacman.conf"
|
||||||
pass "render builds the regional channel files without touching the target"
|
pass "render builds the regional channel files without touching the target"
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ source "$SHELL_TEST_DIR/fixtures/sudo-boundary-test.sh"
|
|||||||
copy_boundary_file bin/omarchy-refresh-pacman
|
copy_boundary_file bin/omarchy-refresh-pacman
|
||||||
copy_boundary_file bin/omarchy-apply-pacman
|
copy_boundary_file bin/omarchy-apply-pacman
|
||||||
for file in default/pacman/pacman-rc.conf default/pacman/mirrorlist-rc \
|
for file in default/pacman/pacman-rc.conf default/pacman/mirrorlist-rc \
|
||||||
default/regions/cn/pacman/pacman.conf.append default/regions/cn/pacman/mirrorlist.append; do
|
default/regions/cn/pacman/pacman.conf.append default/regions/cn/pacman/mirrorlist-rc.prepend; do
|
||||||
copy_boundary_file "$file"
|
copy_boundary_file "$file"
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ PY
|
|||||||
printf '\n'
|
printf '\n'
|
||||||
cat "$ROOT/default/regions/cn/pacman/pacman.conf.append"
|
cat "$ROOT/default/regions/cn/pacman/pacman.conf.append"
|
||||||
} >"$boundary_tmp/expected-pacman.conf"
|
} >"$boundary_tmp/expected-pacman.conf"
|
||||||
cat "$ROOT/default/pacman/mirrorlist-rc" "$ROOT/default/regions/cn/pacman/mirrorlist.append" >"$boundary_tmp/expected-mirrorlist"
|
cat "$ROOT/default/regions/cn/pacman/mirrorlist-rc.prepend" "$ROOT/default/pacman/mirrorlist-rc" >"$boundary_tmp/expected-mirrorlist"
|
||||||
cmp -s "$boundary_tmp/expected-pacman.conf" "$SUDO_TEST_CAPTURE/etc/pacman.conf" ||
|
cmp -s "$boundary_tmp/expected-pacman.conf" "$SUDO_TEST_CAPTURE/etc/pacman.conf" ||
|
||||||
fail "root installs the rendered China pacman.conf" "$(diff "$boundary_tmp/expected-pacman.conf" "$SUDO_TEST_CAPTURE/etc/pacman.conf" 2>&1)"
|
fail "root installs the rendered China pacman.conf" "$(diff "$boundary_tmp/expected-pacman.conf" "$SUDO_TEST_CAPTURE/etc/pacman.conf" 2>&1)"
|
||||||
cmp -s "$boundary_tmp/expected-mirrorlist" "$SUDO_TEST_CAPTURE/etc/pacman.d/mirrorlist" ||
|
cmp -s "$boundary_tmp/expected-mirrorlist" "$SUDO_TEST_CAPTURE/etc/pacman.d/mirrorlist" ||
|
||||||
|
|||||||
Reference in new issue
Block a user