From 94e8746091a776ca0770f67de47c57c03487f287 Mon Sep 17 00:00:00 2001 From: WHC Date: Wed, 7 Oct 2026 11:43:12 +0800 Subject: [PATCH] ci: multi-mirror GitHub clone for mingw third_party windows-cross died cloning busybox-w32 through a global gitclone.com insteadOf (HTTP 502). Try ghfast/ghproxy/gitclone/github per repo instead of forcing one proxy for every fetch. --- scripts/build_third_party_mingw.sh | 30 +++++++++++++++++++++++++++--- scripts/ci_windows_cross.sh | 5 +++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/scripts/build_third_party_mingw.sh b/scripts/build_third_party_mingw.sh index 5874d3b..66a2142 100755 --- a/scripts/build_third_party_mingw.sh +++ b/scripts/build_third_party_mingw.sh @@ -22,11 +22,35 @@ need_cmd git need_cmd make need_cmd "${T}gcc" +# Clone a GitHub repo with CN-friendly mirrors; fall back if one proxy 502s. +github_mirrors() { # https://github.com/org/repo[.git] -> print candidate clone URLs + local url="$1" path + path="${url#https://github.com/}" + path="${path%.git}" + printf '%s\n' \ + "https://ghfast.top/https://github.com/${path}.git" \ + "https://ghproxy.net/https://github.com/${path}.git" \ + "https://gitclone.com/github.com/${path}.git" \ + "https://github.com/${path}.git" +} + checkout() { # url dir rev - local url="$1" dir="$2" rev="$3" - [[ -d "$dir/.git" ]] || git clone -q --filter=blob:none "$url" "$dir" + local url="$1" dir="$2" rev="$3" m + if [[ ! -d "$dir/.git" ]]; then + local ok=0 + while IFS= read -r m; do + echo " clone $m" + rm -rf "$dir" + if git clone -q --filter=blob:none "$m" "$dir"; then + ok=1 + break + fi + done < <(github_mirrors "$url") + [[ $ok -eq 1 ]] || { echo "clone failed: $url" >&2; exit 1; } + fi if ! git -C "$dir" rev-parse -q --verify "$rev^{commit}" >/dev/null; then - git -C "$dir" fetch -q --tags origin + git -C "$dir" fetch -q --tags origin || true + git -C "$dir" fetch -q origin "$rev" || true fi git -C "$dir" checkout -q --detach "$rev" } diff --git a/scripts/ci_windows_cross.sh b/scripts/ci_windows_cross.sh index 1f1cecf..2c120ab 100755 --- a/scripts/ci_windows_cross.sh +++ b/scripts/ci_windows_cross.sh @@ -60,8 +60,9 @@ if ! printf '#include \n' | x86_64-w64-mingw32-gcc -dM -E - | grep -qw exit 1 fi -# Third-party sources live on GitHub; prefer a CN-friendly rewrite. -git config --global url."https://gitclone.com/github.com/".insteadOf "https://github.com/" || true +# Do not set a global insteadOf: a single broken proxy (e.g. gitclone 502) +# would take down every third_party clone. build_third_party_mingw.sh tries +# several mirrors per repo instead. echo "==> bootstrap_windows.sh" exec bash scripts/bootstrap_windows.sh "$ROOT"