Files
lnxgit/scripts/wsl_fix_gradle_cache.sh
LnxGit b0bf9653d7 补充 Android 构建脚本与踩坑记录;新增分片上传与源码清理工具
- scripts/: 一键式 WSL 构建流程(bootstrap / setup / host pyside / 用户 / 预热 / 构建 / 裁剪)
- android/BUILD.md: 完整构建说明与已知问题对照表
- buildozer.spec: p4a.source_dir 固定目录,避免每次直连 GitHub
- tools/upload_chunked.py: 大文件分片并发上传(绕过单请求超时)
- tools/clean_sources.py: 清理 BOM/CRLF(BOM 会导致打包工具 ast 解析失败)
2026-09-22 14:15:45 +08:00

52 lines
1.4 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# 计算 Gradle wrapper 的缓存目录名(MD5 的 base36 编码),并把已下载的分发包放到正确位置。
set -uo pipefail
BUILD_USER="${BUILD_USER:-builder}"
HOME_DIR="/home/$BUILD_USER"
VER="${GRADLE_VER:-8.14.3}"
DIST_NAME="gradle-${VER}-all.zip"
DIST_URL="https://services.gradle.org/distributions/${DIST_NAME}"
echo "=== wrapper 期望的哈希(MD5 base36) ==="
HASH="$(printf '%s' "$DIST_URL" | python3 -c '
import sys, hashlib
data = sys.stdin.buffer.read()
digest = hashlib.md5(data).hexdigest()
num = int(digest, 16)
alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"
out = ""
while num:
num, rem = divmod(num, 36)
out = alphabet[rem] + out
print(out)
')"
echo "distributionUrl = $DIST_URL"
echo "hash = $HASH"
DEST="$HOME_DIR/.gradle/wrapper/dists/gradle-${VER}-all/$HASH"
echo "=== 目标目录: $DEST ==="
mkdir -p "$DEST"
SRC="$HOME_DIR/.gradle/wrapper/dists/gradle-${VER}-all/114afcd2bdf37d5f8724308b16549bdf/$DIST_NAME"
if [ ! -f "$DEST/$DIST_NAME" ]; then
if [ -f "$SRC" ]; then
echo "==> 复制已下载的分发包"
cp "$SRC" "$DEST/$DIST_NAME"
else
echo "找不到已下载的 $DIST_NAME,请先运行 wsl_prefetch_gradle.sh" >&2
exit 1
fi
fi
cd "$DEST"
if [ ! -d "gradle-${VER}" ]; then
echo "==> 解压"
unzip -q -o "$DIST_NAME"
fi
touch "$DIST_NAME.ok"
chown -R "$BUILD_USER:$BUILD_USER" "$HOME_DIR/.gradle"
echo "=== 结果 ==="
ls -la "$DEST"