From 17352f85b05f493f5bda89341492daba233913df Mon Sep 17 00:00:00 2001 From: DKChan <524912269@qq.com> Date: Tue, 3 Nov 2026 04:22:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E7=A8=8B(ci=E8=BF=9C=E7=AB=AF?= =?UTF-8?q?=E5=8C=96=C2=B7=E4=BF=AE=E5=A4=8D):=20mac=5Fsetup=20gdstyle?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9C=AC=E5=9C=B0=E9=A2=84=E7=BD=AE=E5=8C=85?= =?UTF-8?q?=E5=A4=8D=E7=94=A8+tar=E7=BB=93=E6=9E=84=E6=A0=A1=E9=AA=8C;=20?= =?UTF-8?q?=E8=87=AA=E4=B8=BE=E5=89=8D=E7=BD=AE=E4=BB=B6=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E7=94=B1SSH=E9=A2=84=E7=BD=AE(=E7=94=A8=E6=88=B7sudo=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E9=9B=B6=E4=B8=8B=E8=BD=BD=E7=AD=89=E5=BE=85=E2=80=94?= =?UTF-8?q?=E2=80=94Godot=20170MB+gdstyle=E5=B7=B2=E8=90=BDMac=E5=85=B1?= =?UTF-8?q?=E4=BA=AB=E4=BD=8D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/ci/chunk_dl.py | 14 +++++++++++--- tools/ci/mac_setup.sh | 17 +++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/tools/ci/chunk_dl.py b/tools/ci/chunk_dl.py index 9b83c54c..79d6e11d 100644 --- a/tools/ci/chunk_dl.py +++ b/tools/ci/chunk_dl.py @@ -19,7 +19,9 @@ MIRRORS = ["", "https://gh-proxy.net/", "https://gh-proxy.com/"] def pick_mirror(url: str): - """HEAD 探测取 Content-Length;返回(实际可用 URL, 字节数)或 (None, 0)。""" + """HEAD 探测取 Content-Length + 前 4 字节 zip 魔数校验(镜像站会回 200 错误页体, + 只看 Content-Length 会把 195 字节的假体当真——2026-11-03 gh-proxy.net 实证)。 + 返回(实际可用 URL, 字节数)或 (None, 0)。非 zip 目标禁用本件。""" for m in MIRRORS: u = m + url r = subprocess.run(["curl", "-sIL", "-m", "30", u], capture_output=True, text=True) @@ -30,8 +32,14 @@ def pick_mirror(url: str): size = int(line.split(":", 1)[1].strip()) except ValueError: size = 0 - if size > 0: - return u, size + if size <= 65536: + continue + head = subprocess.run( + ["curl", "-sL", "-m", "20", "-r", "0-3", "-o", "-", u], + capture_output=True) + if head.stdout[:2] != b"PK": + continue + return u, size return None, 0 diff --git a/tools/ci/mac_setup.sh b/tools/ci/mac_setup.sh index d479eaf2..802361bf 100644 --- a/tools/ci/mac_setup.sh +++ b/tools/ci/mac_setup.sh @@ -116,12 +116,17 @@ if /usr/local/bin/gdstyle --version >/dev/null 2>&1; then log "gdstyle 已在位,跳过" else TGZ="$(mktemp "${TMPDIR:-/tmp}/gdstyle_XXXXXX.tar.gz")" - _ok=0 - for m in "${MIRRORS[@]}"; do - log "下载 gdstyle v${GDSTYLE_VER} darwin(${m:+经 $m})" - if curl -fL --retry 2 -m 600 -o "$TGZ" "${m}${GDSTYLE_URL}"; then _ok=1; break; fi - done - [ "$_ok" = 1 ] || die "gdstyle 下载失败——手动下载 ${GDSTYLE_URL} 解压放 /usr/local/bin/gdstyle 后重跑" + SRC_TGZ="/Users/${INVOKER}/godot-linux/gdstyle-x86_64-apple-darwin.tar.gz" + if [ -s "$SRC_TGZ" ] && tar -tzf "$SRC_TGZ" >/dev/null 2>&1; then + TGZ="$SRC_TGZ"; log "复用已下载 gdstyle 包: $TGZ" + else + _ok=0 + for m in "${MIRRORS[@]}"; do + log "下载 gdstyle v${GDSTYLE_VER} darwin(${m:+经 $m})" + if curl -fL --retry 2 -m 600 -o "$TGZ" "${m}${GDSTYLE_URL}" && tar -tzf "$TGZ" >/dev/null 2>&1; then _ok=1; break; fi + done + [ "$_ok" = 1 ] || die "gdstyle 下载失败——手动下载 ${GDSTYLE_URL} 解压放 /usr/local/bin/gdstyle 后重跑" + fi TMPD="$(mktemp -d)" tar -xzf "$TGZ" -C "$TMPD" BIN="$(find "$TMPD" -type f -name 'gdstyle*' | head -1)"