Add Termux bootstrapper

This commit is contained in:
Aoran Zeng
2025-07-12 11:03:08 +08:00
parent a70ae801b9
commit 7e3a3f5260
3 changed files with 70 additions and 13 deletions

View File

@@ -30,7 +30,7 @@ end
## `chsrc-bootstrap` to the Rescue
`chsrc-bootstrap` 是一组使用原生脚本语言的脚本,用来完成两件事情:
`chsrc-bootstrap` 是一组使用原生脚本语言的脚本,每个脚本称为 `bootstrapper`用来完成两件事情:
1. 帮助用户进行最基本的换源,让用户能够立即开始使用该系统安装其他软件

55
bootstrap/Termux.bash Normal file
View File

@@ -0,0 +1,55 @@
#!/usr/bin/env bash
# ---------------------------------------------------------------
# File Name : Termux.bash
# File Authors : Aoran Zeng <ccmywish@qq.com>
# Contributors : Nul None <nul@none.org>
# Created On : <2025-07-12>
# Last Modified : <2025-07-12>
#
# Termux:
#
# Bootstrap Termux: https://github.com/RubyMetric/chsrc/issues/173
#
# @consult https://help.mirrors.cernet.edu.cn/termux/
#
# 我们默认采用校园网联合镜像站提供的源
# ---------------------------------------------------------------
bs_echo() {
echo "[chsrc-bootstrap] $*"
}
if command -v termux-change-repo &>/dev/null; then
termux-change-repo
else
# HELP: $PREFIX 有值吗? 是 "/data/data/com.termux/files/usr" 吗?
# 必要的
sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.cernet.edu.cn/termux/apt/termux-main stable main@' $PREFIX/etc/apt/sources.list
apt update
# x11-repo
sed -i 's@^\(deb.*x11 main\)$@#\1\ndeb https://mirrors.cernet.edu.cn/termux/apt/termux-x11 x11 main @' $PREFIX/etc/apt/sources.list.d/x11.list
# root-repo
sed -i 's@^\(deb.*root main\)$@#\1\ndeb https://mirrors.cernet.edu.cn/termux/apt/termux-root root main @' $PREFIX/etc/apt/sources.list.d/root.list
fi
# 立即更新测试换源状态
apt update && apt upgrade
bs_echo "基础换源已完成"
read -p "是否需要安装 chsrc ? (y/n): " need_install_chsrc
if [[ $need_install_chsrc == "y" || $need_install_chsrc == "Y" ]]; then
bs_echo "正在安装依赖项..."
apt-get install -y gcc make git
git clone https://gitee.com/RubyMetric/chsrc.git --depth 1
bs_echo "依赖安装完成!"
bs_echo "正在开始编译和安装"
cd chsrc
make build-in-release-mode
make install
bs_echo "chsrc 安装完成!"
fi