Fix/ci fork build failures (#4832)

解决两个问题:
1. fork的每次ci不通过很烦人
2. debian 11已经过了维护期了, 所以构建不成功. 当前是使用归档仓库, 但是更好的方式其实是切换到12
This commit is contained in:
YuLi
2026-09-19 19:19:53 -07:00
committed by GitHub
parent 4b07053aa5
commit b7947723b9
9 changed files with 76 additions and 10 deletions

View File

@@ -40,7 +40,7 @@ jobs:
retention-days: 90
- name: issue评论
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test'
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test' && vars.VERSION_ISSUE_NO != ''
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -115,7 +115,7 @@ jobs:
retention-days: 90
- name: issue评论
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test'
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test' && vars.VERSION_ISSUE_NO != ''
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -67,7 +67,7 @@ jobs:
retention-days: 90
- name: issue评论
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test'
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test' && vars.VERSION_ISSUE_NO != ''
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -152,7 +152,7 @@ jobs:
retention-days: 90
- name: issue评论
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test'
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test' && vars.VERSION_ISSUE_NO != ''
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -51,7 +51,7 @@ jobs:
retention-days: 90
- name: issue评论
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test'
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test' && vars.VERSION_ISSUE_NO != ''
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -60,7 +60,7 @@ jobs:
retention-days: 90
- name: issue评论
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test'
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test' && vars.VERSION_ISSUE_NO != ''
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -48,7 +48,7 @@ jobs:
retention-days: 90
- name: issue评论
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test'
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test' && vars.VERSION_ISSUE_NO != ''
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -66,7 +66,7 @@ jobs:
retention-days: 90
- name: issue评论
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test'
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/feature/test' && vars.VERSION_ISSUE_NO != ''
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -5,8 +5,74 @@ set -euxo pipefail
export DEBIAN_FRONTEND=noninteractive
if command -v apt-get >/dev/null 2>&1; then
apt-get update
apt-get install -y --no-install-recommends \
# Debian 11(bullseye)已结束支持,deb.debian.org 不再保留其软件包,apt-get 会因 404 整体失败。
# 归档站仅保留主仓库:bullseye-updates 为空、bullseye-security 尚未归档,故只配置 main 一条。
# 仅在 debian:11 容器内改写,避免影响其它发行版或原生 arm64 主机。
# Debian 11 (bullseye) is end-of-life and deb.debian.org no longer serves its packages, so
# apt-get fails outright with 404. The archive keeps the main suite only: bullseye-updates is
# empty and bullseye-security is not archived, hence the single entry below.
# Rewrite it only inside a debian:11 container, never on other releases or a native arm64 host.
OS_TAG=""
if [ -r /etc/os-release ]; then
OS_TAG="$(. /etc/os-release && echo "${ID:-}-${VERSION_ID:-}")"
fi
if [ "${OS_TAG}" = "debian-11" ]; then
echo "deb http://archive.debian.org/debian bullseye main" > /etc/apt/sources.list
rm -f /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources 2>/dev/null || true
# 归档快照的 Release 早已超出有效期,需要放行该校验,否则 apt-get update 仍会拒绝
# The archived Release is long past its Valid-Until, so that check must be relaxed
# or apt-get update still refuses the repository
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99archive-no-check-valid-until
apt-get update
# 镜像内预装的包来自 bullseye-security,版本高于归档主仓库(如 libc6 u14 对 u11)。
# 该仓库的索引虽在、软件包却已下线(其 pool 下的 deb 均返回 404),这些版本已无处可取;
# 而 libc6-dev、perl 都要求与 libc6、perl-base 精确同版本,故须先把已装包对齐到归档主仓库。
# dist-upgrade 只做升级、不会主动降级(--allow-downgrades 仅是放行降级动作),
# 因此逐个比对已装版本与候选版本,显式降级存在差异者。
# The image ships packages from bullseye-security whose versions outrank the archived main
# suite (e.g. libc6 u14 vs u11). That suite still serves indexes but no longer serves the
# packages themselves (its pool returns 404), so those versions are unobtainable; since
# libc6-dev and perl demand an exact version match against libc6 and perl-base, the installed
# set must first be aligned onto the archive. dist-upgrade only upgrades and never downgrades
# on its own (--allow-downgrades merely permits the action), so compare the installed version
# against the candidate for each package and downgrade the ones that differ.
set +x
# 包名取 ${binary:Package} 以带上架构后缀,并与版本一次查出:
# 若按包名二次查询,multi-arch 包会返回多条记录且无分隔,版本串会被拼接成非法值
# Take ${binary:Package} so the architecture suffix is kept, and read the version in the
# same query: looking the version up by bare name afterwards returns one record per
# architecture with no separator, concatenating them into an invalid version string
installed_list="$(dpkg-query -W -f='${db:Status-Abbrev}|${binary:Package}|${Version}\n' \
| awk -F'|' '$1 ~ /^ii/ {print $2"|"$3}')"
realign=""
while IFS='|' read -r pkg installed; do
[ -n "${pkg}" ] || continue
# 不能用 apt-cache policy 的 Candidate:它表示"apt 会选用的版本",而 apt 默认不降级,
# 对已装版本高于源的包它恒等于已装版本,比对将永远相等。
# madison 只列出源中实际提供的版本(按版本降序),取其首行才是源里的可用版本。
# apt-cache 的输出随 locale 变化,固定为 C 以稳定解析。
# The Candidate from apt-cache policy cannot be used: it denotes the version apt would
# select, and since apt never downgrades on its own it equals the installed version
# whenever that outranks the archive, making every comparison match.
# madison lists only what the configured sources actually offer (newest first), so its
# first row is the version available from the archive.
# apt-cache output is localized, so pin the locale to C for stable parsing.
available="$(LC_ALL=C apt-cache madison "${pkg}" 2>/dev/null \
| awk -F'|' 'NR==1{gsub(/ /,"",$2); print $2}' || true)"
if [ -n "${available}" ] && [ "${available}" != "${installed}" ]; then
realign="${realign} ${pkg}=${available}"
fi
done <<INSTALLED_LIST
${installed_list}
INSTALLED_LIST
set -x
if [ -n "${realign}" ]; then
apt-get install -y --allow-downgrades ${realign}
fi
else
apt-get update
fi
apt-get install -y --no-install-recommends --allow-downgrades \
git wget ca-certificates gcc g++ make perl python3 \
tar gzip xz-utils pkg-config zlib1g-dev
elif command -v yum >/dev/null 2>&1; then