Set up China before moving the mirrors so a failed switch leaves the machine Global

This commit is contained in:
ZacharyZhang-NY committed 2026-10-06 21:13:37 -04:00
1 parent 09da70c303
commit a3e40cb8b0
4 files changed
+28 -6

No files matched your search

+8
View File
@@ -17,6 +17,7 @@ rewrite "$ROOT/bin/omarchy-region" "$sandbox/bin/omarchy-region"
for command in omarchy-update-pacman omarchy-pkg-add locale-gen rime-ice-installer omarchy-setup-claude-api systemctl; do
printf '#!/bin/bash\necho "%s $*" >>"%s"\n' "$command" "$calls" >"$test_tmp/bin/$command"
done
printf '#!/bin/bash\necho "omarchy-pkg-add $*" >>"%s"\n[[ -z ${STUB_PKG_FAIL:-} ]]\n' "$calls" >"$test_tmp/bin/omarchy-pkg-add"
printf '#!/bin/bash\n[[ $1 == env ]] && shift\nexec env "$@"\n' >"$test_tmp/bin/sudo"
chmod +x "$test_tmp/bin"/*
export PATH="$test_tmp/bin:$sandbox/bin:$PATH" OMARCHY_PATH="$sandbox" HOME="$test_tmp/home"
@@ -67,6 +68,13 @@ if output=$(omarchy-region mars 2>&1); then
fi
pass "an unknown region is refused"
if output=$(STUB_PKG_FAIL=1 omarchy-region china 2>&1); then
fail "switching to China fails when its packages do not install" "$output"
fi
[[ $(omarchy-region) == "Global" && $(<"$root/etc/pacman.conf") == "$(<"$ROOT/default/pacman/pacman-stable.conf")" && $(<"$root/etc/pacman.d/mirrorlist") == "$(<"$ROOT/default/pacman/mirrorlist-stable")" ]] ||
fail "a failed switch to China leaves the region and the mirrors Global"
pass "a failed switch to China leaves the machine Global"
rc_migration="$test_tmp/1788112314.sh"
rewrite "$ROOT/migrations/1788112314.sh" "$rc_migration"
cp "$ROOT/default/pacman/mirrorlist-rc" "$root/etc/pacman.d/mirrorlist"
+9
View File
@@ -61,6 +61,7 @@ mkdir -p "$stub_bin"
for command in omarchy-pkg-add rime-ice-installer locale-gen; do
printf '#!/bin/bash\necho "%s $*" >>"%s"\n' "$command" "$calls" >"$stub_bin/$command"
done
printf '#!/bin/bash\necho "omarchy-pkg-add $*" >>"%s"\n[[ -z ${STUB_PKG_FAIL:-} ]]\n' "$calls" >"$stub_bin/omarchy-pkg-add"
printf '#!/bin/bash\necho "$STUB_REGION"\n' >"$stub_bin/omarchy-region"
chmod +x "$stub_bin"/*
PATH="$stub_bin:$PATH"
@@ -115,8 +116,16 @@ if output=$(OMARCHY_REGION=china bash -e "$region_setup" 2>&1); then
fi
[[ $output == "Refusing to replace $root/etc/gemrc, which Omarchy did not create" && $(<"$root/etc/gemrc") == ":sources: []" ]] ||
fail "China names the file it refuses to replace and leaves it" "$output"
[[ ! -e $root/etc/omarchy/region ]] || fail "a refused China switch records no region"
rm "$root/etc/gemrc"
pass "region setup never touches mirror config Omarchy did not create"
if output=$(STUB_PKG_FAIL=1 OMARCHY_REGION=china bash -e "$region_setup" 2>&1); then
fail "China fails when its packages do not install" "$output"
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=china bash -e "$region_setup"
env -u OMARCHY_REGION bash -e "$region_setup"
[[ ! -e $root/etc/omarchy/region ]] || fail "an installer that passes no region installs Global"