Skip to content

Commit 7e3a3f5

Browse files
committed
Add Termux bootstrapper
1 parent a70ae80 commit 7e3a3f5

File tree

3 files changed

+70
-13
lines changed

3 files changed

+70
-13
lines changed

bootstrap/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ end
3030

3131
## `chsrc-bootstrap` to the Rescue
3232

33-
`chsrc-bootstrap` 是一组使用原生脚本语言的脚本,用来完成两件事情:
33+
`chsrc-bootstrap` 是一组使用原生脚本语言的脚本,每个脚本称为 `bootstrapper`用来完成两件事情:
3434

3535
1. 帮助用户进行最基本的换源,让用户能够立即开始使用该系统安装其他软件
3636

bootstrap/Termux.bash

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
# ---------------------------------------------------------------
3+
# File Name : Termux.bash
4+
# File Authors : Aoran Zeng <[email protected]>
5+
# Contributors : Nul None <[email protected]>
6+
# Created On : <2025-07-12>
7+
# Last Modified : <2025-07-12>
8+
#
9+
# Termux:
10+
#
11+
# Bootstrap Termux: https://github.com/RubyMetric/chsrc/issues/173
12+
#
13+
# @consult https://help.mirrors.cernet.edu.cn/termux/
14+
#
15+
# 我们默认采用校园网联合镜像站提供的源
16+
# ---------------------------------------------------------------
17+
18+
bs_echo() {
19+
echo "[chsrc-bootstrap] $*"
20+
}
21+
22+
if command -v termux-change-repo &>/dev/null; then
23+
termux-change-repo
24+
else
25+
# HELP: $PREFIX 有值吗? 是 "/data/data/com.termux/files/usr" 吗?
26+
# 必要的
27+
sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.cernet.edu.cn/termux/apt/termux-main stable main@' $PREFIX/etc/apt/sources.list
28+
apt update
29+
30+
# x11-repo
31+
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
32+
33+
# root-repo
34+
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
35+
fi
36+
37+
# 立即更新测试换源状态
38+
apt update && apt upgrade
39+
40+
bs_echo "基础换源已完成"
41+
42+
read -p "是否需要安装 chsrc ? (y/n): " need_install_chsrc
43+
44+
if [[ $need_install_chsrc == "y" || $need_install_chsrc == "Y" ]]; then
45+
bs_echo "正在安装依赖项..."
46+
apt-get install -y gcc make git
47+
git clone https://gitee.com/RubyMetric/chsrc.git --depth 1
48+
bs_echo "依赖安装完成!"
49+
50+
bs_echo "正在开始编译和安装"
51+
cd chsrc
52+
make build-in-release-mode
53+
make install
54+
bs_echo "chsrc 安装完成!"
55+
fi

src/recipe/os/APT/Termux.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* Contributors : Nul None <[email protected]>
66
* Created On : <2025-03-04>
77
* Last Modified : <2025-03-04>
8+
*
9+
* 该 recipe 存在对应的 bootstrapper
810
* ------------------------------------------------------------*/
911

1012
/**
@@ -13,18 +15,18 @@
1315
static Source_t
1416
os_termux_sources[] = {
1517
{&UpstreamProvider, NULL},
16-
{&Ustc, "https://mirrors.ustc.edu.cn/termux/"},
17-
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/termux/"},
18-
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/termux/"},
19-
{&Bfsu, "https://mirrors.bfsu.edu.cn/termux/"},
20-
{&Pku, "https://mirrors.pku.edu.cn/termux/"},
21-
{&Nyist, "https://mirror.nyist.edu.cn/termux/"},
22-
{&Nju, "https://mirror.nju.edu.cn/termux/"},
23-
{&Sustech, "https://mirrors.sustech.edu.cn/termux/"},
24-
{&Iscas, "https://mirror.iscas.ac.cn/termux/"},
25-
{&Zju, "https://mirrors.zju.edu.cn/termux/"},
26-
{&Sdu, "https://mirrors.sdu.edu.cn/termux/"},
27-
{&Cqupt, "https://mirrors.cqupt.edu.cn/termux/"}
18+
{&Ustc, "https://mirrors.ustc.edu.cn/termux/", NULL},
19+
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/termux/", NULL},
20+
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/termux/", NULL},
21+
{&Bfsu, "https://mirrors.bfsu.edu.cn/termux/", NULL},
22+
{&Pku, "https://mirrors.pku.edu.cn/termux/", NULL},
23+
{&Nyist, "https://mirror.nyist.edu.cn/termux/", NULL},
24+
{&Nju, "https://mirror.nju.edu.cn/termux/", NULL},
25+
{&Sustech, "https://mirrors.sustech.edu.cn/termux/", NULL},
26+
{&Iscas, "https://mirror.iscas.ac.cn/termux/", NULL},
27+
{&Zju, "https://mirrors.zju.edu.cn/termux/", NULL},
28+
{&Sdu, "https://mirrors.sdu.edu.cn/termux/", NULL},
29+
{&Cqupt, "https://mirrors.cqupt.edu.cn/termux/", NULL}
2830

2931
};
3032
def_sources_n(os_termux);

0 commit comments

Comments
 (0)