Files
lnxgit/scripts/wsl_move_workdir.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

40 lines
1.2 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
# 把构建环境从 /root 移到 /opt(普通用户可访问),并修正所有权。
set -euo pipefail
OLD="/root/lnxgit-android"
NEW="/opt/lnxgit-android"
USER_NAME="${USER_NAME:-builder}"
if [ -d "$NEW" ]; then
echo "==> $NEW 已存在,跳过搬迁"
else
echo "==> 移动 $OLD -> $NEW"
mv "$OLD" "$NEW"
fi
# 保留一份软链接,方便 root 调试
[ -e "$OLD" ] || ln -s "$NEW" "$OLD"
echo "==> 修正虚拟环境中的路径引用"
if [ -f "$NEW/venv/bin/activate" ]; then
sed -i "s#$OLD#$NEW#g" "$NEW/venv/bin/activate" || true
fi
for f in "$NEW"/venv/bin/*; do
if [ -f "$f" ] && head -c 2 "$f" 2>/dev/null | grep -q '#!'; then
sed -i "s#$OLD#$NEW#g" "$f" 2>/dev/null || true
fi
done
if [ -f "$NEW/venv/pyvenv.cfg" ]; then
sed -i "s#$OLD#$NEW#g" "$NEW/venv/pyvenv.cfg" || true
fi
# 脚本目录中的硬编码路径
sed -i "s#/root/lnxgit-android#/opt/lnxgit-android#g" "$NEW/venv/bin/"* 2>/dev/null || true
echo "==> 交给 $USER_NAME"
chown -R "$USER_NAME:$USER_NAME" "$NEW"
chmod -R a+rX /opt
echo "==> 验证"
su - "$USER_NAME" -c "cd /opt/lnxgit-android && ./venv/bin/python --version && ./venv/bin/python -m buildozer version 2>&1 | tail -2"