mirror of
https://github.com/hotwa/luci-app-openclaw.git
synced 2026-03-30 20:25:44 +00:00
Fix ARM64 musl node download discovery
This commit is contained in:
@@ -53,13 +53,14 @@ NODE_BIN="${NODE_BASE}/bin/node"
|
||||
NPM_BIN="${NODE_BASE}/bin/npm"
|
||||
PNPM_BIN="${OC_GLOBAL}/bin/pnpm"
|
||||
|
||||
# Node.js 官方镜像 + musl 非官方构建
|
||||
# Node.js 官方镜像 + musl 非官方构建
|
||||
# Node.js 下载源
|
||||
OPENCLAW_GITHUB_REPO="${OPENCLAW_GITHUB_REPO:-hotwa/luci-app-openclaw}"
|
||||
NODE_MIRROR="${NODE_MIRROR:-https://nodejs.org/dist}"
|
||||
NODE_MIRROR_CN="https://npmmirror.com/mirrors/node"
|
||||
NODE_MUSL_MIRROR="https://unofficial-builds.nodejs.org/download/release"
|
||||
# 项目自托管 ARM64 musl Node.js (unofficial-builds 仅提供 x64 musl)
|
||||
NODE_SELF_HOST="https://github.com/10000ge10000/luci-app-openclaw/releases/download/node-bins"
|
||||
NODE_SELF_HOST="${NODE_SELF_HOST:-https://github.com/${OPENCLAW_GITHUB_REPO}/releases/download/node-bins}"
|
||||
NODE_RELEASE_API="${NODE_RELEASE_API:-https://api.github.com/repos/${OPENCLAW_GITHUB_REPO}/releases/tags/node-bins}"
|
||||
NODE_RELEASE_PAGE="${NODE_RELEASE_PAGE:-https://github.com/${OPENCLAW_GITHUB_REPO}/releases/tag/node-bins}"
|
||||
|
||||
export PATH="${NODE_BASE}/bin:${OC_GLOBAL}/bin:$PATH"
|
||||
export NODE_ICU_DATA="${NODE_BASE}/share/icu"
|
||||
@@ -68,6 +69,48 @@ log_info() { echo " [✓] $1"; }
|
||||
log_warn() { echo " [!] $1"; }
|
||||
log_error() { echo " [✗] $1"; }
|
||||
|
||||
download_url_to_file() {
|
||||
local url="$1"
|
||||
local output="$2"
|
||||
|
||||
curl -fSL --connect-timeout 15 --max-time 300 -o "$output" "$url" 2>/dev/null || \
|
||||
wget -q --timeout=15 -O "$output" "$url" 2>/dev/null
|
||||
}
|
||||
|
||||
resolve_arm64_musl_node_url() {
|
||||
local node_ver="$1"
|
||||
local release_json="/tmp/openclaw-node-bins-release.json"
|
||||
local asset_url=""
|
||||
|
||||
echo " 正在从 ${NODE_RELEASE_API} 获取 ARM64 musl 版本列表..." >&2
|
||||
if ! download_url_to_file "$NODE_RELEASE_API" "$release_json"; then
|
||||
rm -f "$release_json"
|
||||
log_error "无法获取 ARM64 musl Node.js 发布元数据" >&2
|
||||
echo " 仓库: ${OPENCLAW_GITHUB_REPO}" >&2
|
||||
echo " 最低要求: v${node_ver}" >&2
|
||||
echo " Release API: ${NODE_RELEASE_API}" >&2
|
||||
echo " Release 页面: ${NODE_RELEASE_PAGE}" >&2
|
||||
echo " 请先发布 node-bins 中满足要求的 ARM64 musl 资产,或通过环境变量覆盖下载源" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
asset_url=$(oc_select_node_release_asset_url "$release_json" "linux-arm64" "$node_ver" || true)
|
||||
rm -f "$release_json"
|
||||
|
||||
if [ -n "$asset_url" ]; then
|
||||
printf '%s\n' "$asset_url"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log_error "未找到兼容的 ARM64 musl Node.js 资产" >&2
|
||||
echo " 仓库: ${OPENCLAW_GITHUB_REPO}" >&2
|
||||
echo " 最低要求: v${node_ver}" >&2
|
||||
echo " Release API: ${NODE_RELEASE_API}" >&2
|
||||
echo " Release 页面: ${NODE_RELEASE_PAGE}" >&2
|
||||
echo " 请先发布 node-bins 中满足要求的 ARM64 musl 资产,或通过环境变量覆盖下载源" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
# 安全创建目录 (会在 _oc_fix_opt 修复 /opt 后使用标准路径)
|
||||
ensure_mkdir() {
|
||||
local target="$1"
|
||||
@@ -169,17 +212,16 @@ download_node() {
|
||||
local mirror_list=""
|
||||
local musl_tarball="node-v${node_ver}-${node_arch}-musl.tar.xz"
|
||||
local glibc_tarball="node-v${node_ver}-${node_arch}.tar.xz"
|
||||
local arm64_musl_url=""
|
||||
|
||||
if [ "$libc_type" = "musl" ]; then
|
||||
echo ""
|
||||
echo "=== 下载 Node.js v${node_ver} (${node_arch}, musl libc) ==="
|
||||
|
||||
if [ "$node_arch" = "linux-arm64" ]; then
|
||||
# ARM64 musl: unofficial-builds 不提供,从项目自托管下载
|
||||
# 1) 项目自托管 ARM64 musl 构建 (当前版本)
|
||||
mirror_list="${NODE_SELF_HOST}/${musl_tarball}"
|
||||
# 2) unofficial-builds (留作将来可能支持)
|
||||
mirror_list="$mirror_list ${NODE_MUSL_MIRROR}/v${node_ver}/${musl_tarball}"
|
||||
# ARM64 musl: 从当前维护仓库的 node-bins release 动态选择兼容资产
|
||||
arm64_musl_url=$(resolve_arm64_musl_node_url "$node_ver") || exit 1
|
||||
mirror_list="${arm64_musl_url}"
|
||||
else
|
||||
# x64 musl: unofficial-builds 提供
|
||||
# 1) unofficial-builds
|
||||
|
||||
Reference in New Issue
Block a user