From 652d03367a12331fb4da5d2b1e1f0ae0012c0b10 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 5 Nov 2026 14:44:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(fetch):=20=E6=97=A0=E5=87=AD=E6=8D=AE?= =?UTF-8?q?=E6=97=B6=E5=8C=BF=E5=90=8D=E6=8B=89=E5=8C=85=EF=BC=88=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E4=BB=93=E5=B7=B2=E5=85=AC=E5=BC=80=EF=BC=89+=20?= =?UTF-8?q?=E4=BF=AE=20heredoc=20=E5=8F=8D=E5=BC=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 平台仓 private=false 后,下载 release asset 可匿名;脚本改为「有凭据带凭据、 没凭据走匿名」,不再因无凭据直接放弃 - 修 heredoc 里未转义的反引号(config 注释中的 `use sspf::` 被当命令执行, 报 'use: command not found' 且注释缺字) --- scripts/fetch-platform.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/fetch-platform.sh b/scripts/fetch-platform.sh index 7797747..7b2bdd2 100755 --- a/scripts/fetch-platform.sh +++ b/scripts/fetch-platform.sh @@ -25,7 +25,8 @@ # 1. 环境变量 SSPF_TAR 直指某个 .tar.gz # 2. 本地 dist:$SSPF_DIST_DIR(默认 ~/Desktop/workspace/ssw-platform/dist) # 3. Gitea Release:tag = vX.Y.Z,asset = sspf-vX.Y.Z-.tar.gz -# (默认 http://127.0.0.1:13300/ssw/ssw-platform;凭据取 GITEA_USER/GITEA_PASS 或本机 git credential) +# (默认 http://127.0.0.1:13300/ssw/ssw-platform;**仓库已公开,可匿名下载**; +# 需要时用 GITEA_USER/GITEA_PASS 或本机 git credential 带凭据) # 是编译器 host(如 x86_64-apple-darwin),可用 SSPF_TARGET 覆盖。 # set -euo pipefail @@ -70,12 +71,19 @@ download_from_gitea() { user="$(printf '%s\n' "${cred}" | sed -n 's/^username=//p')" pass="$(printf '%s\n' "${cred}" | sed -n 's/^password=//p')" fi - [[ -z "${user}" || -z "${pass}" ]] && { echo " (无 Gitea 凭据,跳过远端下载)" >&2; return 1; } + # 公开仓可匿名;有凭据则带上(兼容私有仓 / 需要审计的环境) local url="${base}/${repo}/releases/download/${tag}/${name}" echo "==> 从 Gitea 下载 ${tag} / ${name}" >&2 mkdir -p "$(dirname "${out}")" rm -f "${out}" - if ! curl -sfL --noproxy '*' -m 900 -u "${user}:${pass}" -o "${out}" "${url}"; then + local ok=1 + if [[ -n "${user}" && -n "${pass}" ]]; then + curl -sfL --noproxy '*' -m 900 -u "${user}:${pass}" -o "${out}" "${url}" || ok=0 + else + echo " (匿名模式:仓库已公开,无需凭据)" >&2 + curl -sfL --noproxy '*' -m 900 -o "${out}" "${url}" || ok=0 + fi + if [[ "${ok}" != "1" ]]; then echo " (下载失败或不存在:${url})" >&2 rm -f "${out}" return 1 @@ -184,7 +192,7 @@ rustflags = [ ${EXTERN_LINES} "-L", "dependency=${SKILL_ROOT}/vendor/${PKG}/lib", ] # 🔴 cargo test 的 doctest 走 rustdoc,**不吃 build.rustflags**;必须同样喂一遍, -# 否则测试阶段 doctest 里的 `use sspf::` 会 E0432(unresolved import)。 +# 否则测试阶段 doctest 里的 \`use sspf::\` 会 E0432(unresolved import)。 rustdocflags = [ ${EXTERN_LINES} "-L", "dependency=${SKILL_ROOT}/vendor/${PKG}/lib", ]