Add Termux bootstrapper

This commit is contained in:
Aoran Zeng 2025-07-12 11:03:08 +08:00
parent a70ae801b9
commit 7e3a3f5260
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
3 changed files with 70 additions and 13 deletions

View File

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

View File

@ -5,6 +5,8 @@
* Contributors : Nul None <nul@none.org> * Contributors : Nul None <nul@none.org>
* Created On : <2025-03-04> * Created On : <2025-03-04>
* Last Modified : <2025-03-04> * Last Modified : <2025-03-04>
*
* recipe bootstrapper
* ------------------------------------------------------------*/ * ------------------------------------------------------------*/
/** /**
@ -13,18 +15,18 @@
static Source_t static Source_t
os_termux_sources[] = { os_termux_sources[] = {
{&UpstreamProvider, NULL}, {&UpstreamProvider, NULL},
{&Ustc, "https://mirrors.ustc.edu.cn/termux/"}, {&Ustc, "https://mirrors.ustc.edu.cn/termux/", NULL},
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/termux/"}, {&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/termux/", NULL},
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/termux/"}, {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/termux/", NULL},
{&Bfsu, "https://mirrors.bfsu.edu.cn/termux/"}, {&Bfsu, "https://mirrors.bfsu.edu.cn/termux/", NULL},
{&Pku, "https://mirrors.pku.edu.cn/termux/"}, {&Pku, "https://mirrors.pku.edu.cn/termux/", NULL},
{&Nyist, "https://mirror.nyist.edu.cn/termux/"}, {&Nyist, "https://mirror.nyist.edu.cn/termux/", NULL},
{&Nju, "https://mirror.nju.edu.cn/termux/"}, {&Nju, "https://mirror.nju.edu.cn/termux/", NULL},
{&Sustech, "https://mirrors.sustech.edu.cn/termux/"}, {&Sustech, "https://mirrors.sustech.edu.cn/termux/", NULL},
{&Iscas, "https://mirror.iscas.ac.cn/termux/"}, {&Iscas, "https://mirror.iscas.ac.cn/termux/", NULL},
{&Zju, "https://mirrors.zju.edu.cn/termux/"}, {&Zju, "https://mirrors.zju.edu.cn/termux/", NULL},
{&Sdu, "https://mirrors.sdu.edu.cn/termux/"}, {&Sdu, "https://mirrors.sdu.edu.cn/termux/", NULL},
{&Cqupt, "https://mirrors.cqupt.edu.cn/termux/"} {&Cqupt, "https://mirrors.cqupt.edu.cn/termux/", NULL}
}; };
def_sources_n(os_termux); def_sources_n(os_termux);