Skip to content

Commit e2fd640

Browse files
committed
Support Termux
[GitHub #173]
1 parent 915adab commit e2fd640

File tree

5 files changed

+112
-2
lines changed

5 files changed

+112
-2
lines changed

src/chsrc-main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
#include "recipe/os/APT/Armbian.c"
9090
// Independent
9191
#include "recipe/os/APT/ROS.c"
92+
#include "recipe/os/APT/Termux.c"
9293
#include "recipe/os/APT/openKylin.c"
9394
#include "recipe/os/APT/deepin.c"
9495

src/recipe/menu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ static const char
9090
*os_raspberrypi[] = {"raspi", "raspberrypi",NULL, t(&os_raspberrypi_target)},
9191
*os_armbian [] = {"armbian", NULL, t(&os_armbian_target)},
9292
*os_openwrt [] = {"openwrt", "opkg", "LEDE", NULL, t(&os_openwrt_target)},
93+
*os_termux [] = {"termux", NULL, t(&os_termux_target)},
9394

9495
*os_openkylin [] = {"openkylin", NULL, t(&os_openkylin_target)},
9596
*os_openeuler [] = {"openeuler", NULL, t(&os_openeuler_target)},
@@ -103,7 +104,7 @@ static const char
103104
**os_systems[] =
104105
{
105106
os_debian, os_ubuntu, os_linuxmint, os_kali,
106-
os_trisquel, os_linuxlite, os_raspberrypi, os_armbian, os_openwrt,
107+
os_trisquel, os_linuxlite, os_raspberrypi, os_armbian, os_openwrt, os_termux,
107108
os_deepin, os_openkylin, os_ros,
108109

109110
os_fedora, os_rockylinux, os_almalinux, os_openeuler, os_anolis,

src/recipe/os/APT/Termux.c

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/** ------------------------------------------------------------
2+
* SPDX-License-Identifier: GPL-3.0-or-later
3+
* -------------------------------------------------------------
4+
* File Authors : Aoran Zeng <[email protected]>
5+
* Contributors : Nul None <[email protected]>
6+
* Created On : <2025-03-04>
7+
* Last Modified : <2025-03-04>
8+
* ------------------------------------------------------------*/
9+
10+
/**
11+
* @update 2025-03-04
12+
*/
13+
static Source_t
14+
os_termux_sources[] = {
15+
{&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/"}
28+
29+
};
30+
def_sources_n(os_termux);
31+
32+
33+
/**
34+
* chsrc get termux
35+
*/
36+
void
37+
os_termux_getsrc (char *option)
38+
{
39+
chsrc_view_file (OS_Termux_SourceList);
40+
}
41+
42+
43+
/**
44+
* @consult https://help.mirrors.cernet.edu.cn/termux/
45+
*
46+
* chsrc set termux
47+
*/
48+
void
49+
os_termux_setsrc (char *option)
50+
{
51+
52+
// chsrc_ensure_root (); Termux下禁止使用root
53+
54+
chsrc_yield_source_and_confirm (os_termux);
55+
56+
char *cmd = xy_strjoin (3, "sed -i 's@^\\(deb.*stable main\\)$@#\\1\\ndeb ",
57+
source.url, "apt/termux-main stable main@' " OS_Termux_SourceList);
58+
59+
chsrc_run (cmd, RunOpt_Default);
60+
61+
chsrc_run ("apt update", RunOpt_Default);
62+
chsrc_run ("apt upgrade", RunOpt_Default);
63+
64+
ProgMode_ChgType = ChgType_Auto;
65+
chsrc_conclude (&source);
66+
}
67+
68+
69+
/**
70+
* chsrc reset termux
71+
*
72+
* 暂时缺乏原地址
73+
*/
74+
void
75+
os_termux_resetsrc (char *option)
76+
{
77+
os_termux_setsrc (option);
78+
}
79+
80+
81+
/**
82+
* chsrc ls termux
83+
*/
84+
Feature_t
85+
os_termux_feat (char *option)
86+
{
87+
Feature_t f = {0};
88+
89+
f.can_get = true;
90+
f.can_reset = false;
91+
92+
f.cap_locally = CanNot;
93+
f.cap_locally_explain = NULL;
94+
95+
f.can_english = false;
96+
f.can_user_define = false;
97+
98+
f.note = NULL;
99+
return f;
100+
}
101+
102+
103+
def_target_gsf(os_termux);

src/recipe/os/APT/Trisquel.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ os_trisquel_getsrc (char *option)
3030
chsrc_view_file (OS_Apt_SourceList);
3131
}
3232

33+
3334
/**
34-
* 参考: https://help.mirrors.cernet.edu.cn/trisquel/
35+
* @consult: https://help.mirrors.cernet.edu.cn/trisquel/
3536
*/
3637
void
3738
os_trisquel_setsrc (char *option)
@@ -51,4 +52,5 @@ os_trisquel_setsrc (char *option)
5152
chsrc_conclude (&source);
5253
}
5354

55+
5456
def_target(os_trisquel);

src/recipe/os/APT/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
// independent
3131
#define OS_ROS_SourceList OS_Apt_SourceList_D "ros-latest.list"
3232

33+
#define OS_Termux_SourceList "/data/data/com.termux/files/usr" OS_Apt_SourceList
34+
35+
3336
// Ubuntu based
3437
#define OS_LinuxMint_SourceList OS_Apt_SourceList_D "official-package-repositories.list"
3538

0 commit comments

Comments
 (0)