工程(ci远端化·修复): mac_setup gdstyle支持本地预置包复用+tar结构校验; 自举前置件全部由SSH预置(用户sudo运行零下载等待——Godot 170MB+gdstyle已落Mac共享位)
This commit is contained in:
1 parent
fb5f2d42e5
commit
17352f85b0
2 files changed
+22
-9
No files matched your search
+11
-3
@@ -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
|
||||
|
||||
|
||||
|
||||
+11
-6
@@ -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)"
|
||||
|
||||
Reference in new issue
Block a user