Skip to content
This repository was archived by the owner on May 6, 2026. It is now read-only.

Commit 5368db8

Browse files
yysjasmineclaude
andcommitted
installer(macos): port linux CN-region auto-detection into setup-interactive
macOS was the only platform without automatic China-mirror setup — Linux sources shared/cn-env.sh in install.sh, and Windows runs Test-IsChinaRegion per PS script. Port the same AGENTPACK_CN override + iping.cc probe block into setup-interactive.sh so CN users get npm/pip/uv mirrors without having to set AGENTPACK_CN=1 by hand. apply_tuna_apt_mirror no-ops on macOS (no /etc/os-release), so apply_cn_env is safe here as-is. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d0c69ff commit 5368db8

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

macos/scripts/postinstall.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,29 @@ if [ -f /opt/homebrew/bin/brew ]; then
3636
eval "$(/opt/homebrew/bin/brew shellenv)"
3737
fi
3838
39+
# CN-region environment setup: mirror env vars (uv/pip/npm) + pre-installed uv.
40+
# Driven by AGENTPACK_CN=1 or a CN network probe. apply_tuna_apt_mirror is a
41+
# silent no-op on macOS (no /etc/os-release), so apply_cn_env is safe here.
42+
if [ -f "$SHARED_DIR/cn-env.sh" ]; then
43+
# shellcheck disable=SC1091
44+
source "$SHARED_DIR/cn-env.sh"
45+
_ap_cn_detected=0
46+
case "${AGENTPACK_CN:-}" in
47+
1|true|TRUE|yes|YES) _ap_cn_detected=1 ;;
48+
0|false|FALSE|no|NO) _ap_cn_detected=0 ;;
49+
*)
50+
country="$(curl -fsSL --max-time 5 https://api.iping.cc/v1/query 2>/dev/null \
51+
| python3 -c "import json,sys; print(json.load(sys.stdin).get('country_code',''))" 2>/dev/null || true)"
52+
[ "$country" = "CN" ] && _ap_cn_detected=1
53+
;;
54+
esac
55+
if [ "$_ap_cn_detected" -eq 1 ]; then
56+
export AGENTPACK_CN=1
57+
echo "[OK] Detected China network — using domestic mirrors (npm / pip / uv)"
58+
apply_cn_env
59+
fi
60+
fi
61+
3962
echo ""
4063
echo "========================================"
4164
echo " Agent Pack Setup"

0 commit comments

Comments
 (0)