feat(fetch): 无凭据时匿名拉包(平台仓已公开)+ 修 heredoc 反引号
- 平台仓 private=false 后,下载 release asset 可匿名;脚本改为「有凭据带凭据、 没凭据走匿名」,不再因无凭据直接放弃 - 修 heredoc 里未转义的反引号(config 注释中的 `use sspf::` 被当命令执行, 报 'use: command not found' 且注释缺字)
This commit is contained in:
1 parent
d8a8165dd7
commit
652d03367a
1 file changed
+12
-4
@@ -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-<target>.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 带凭据)
|
||||
# <target> 是编译器 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",
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user