diff --git a/Makefile.am b/Makefile.am
index 28b4b44a..964dedff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,7 +16,14 @@
# along with termux-tools. If not, see
# .
-SUBDIRS = scripts doc mirrors motds
+SUBDIRS = . scripts doc mirrors motds src
+
+CONFFILES = \
+etc/motd \
+etc/motd.sh \
+etc/motd-playstore \
+etc/profile.d/init-termux-properties.sh \
+etc/termux-login.sh
do_subst = sed -e "s%[@]TERMUX_PREFIX[@]%$(termux_prefix)%g" \
-e "s%[@]TERMUX_APP_PACKAGE[@]%${termux_app_package}%g" \
@@ -45,7 +52,18 @@ $(eval $(call sed-rule,init-termux-properties.sh))
$(eval $(call sed-rule,termux-login.sh))
-install-data-local: $(pkgdata_PROFILE)
+
+
+create-deb-control-files:
+ printf "" > conffiles
+ for f in $(CONFFILES); do \
+ printf "%s\n" "$$f" >> conffiles; \
+ done
+ printf "#!%s/bin/bash\n\n" "${termux_prefix}" > preinst
+
+
+
+install-data-local: create-deb-control-files $(pkgdata_PROFILE)
$(MKDIR_P) $(DESTDIR)$(datarootdir)/examples/termux
for f in $(pkgdata_EXAMPLES); do \
$(INSTALL) -m 644 $(srcdir)/$$f \
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 00000000..479f15cb
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1 @@
+Check https://termux.dev/security for info on Termux security policies and how to report vulnerabilities.
diff --git a/configure.ac b/configure.ac
index 452f4728..d4000e59 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@ dnl To rebuild the 'configure' script from this, execute the command
dnl autoconf
dnl in the directory containing this script.
dnl
-dnl Copyright (C) 2022-2024 Termux
+dnl Copyright (C) 2022-2025 Termux
dnl
dnl This file is part of termux-tools.
dnl
@@ -22,13 +22,15 @@ dnl along with termux-tools. If not, see
dnl .
AC_PREREQ([2.69])
-AC_INIT([termux-tools], [1.40.6], [support@termux.dev])
+AC_INIT([termux-tools], [1.47.1], [support@termux.dev])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_MAKE_SET
+AC_PROG_CC
+AC_LANG(C)
-copyright="Copyright (C) 2022 Termux."
+copyright="Copyright (C) 2022-2025 Termux."
if test "${TERMUX_APP_PACKAGE+set}" = set; then
termux_app_package="$TERMUX_APP_PACKAGE"
else
@@ -93,6 +95,6 @@ AC_SUBST(termux_package_manager)
AC_PROG_LN_S
AC_CONFIG_FILES([Makefile scripts/Makefile doc/Makefile
-mirrors/Makefile motds/Makefile])
+mirrors/Makefile motds/Makefile src/Makefile])
AC_OUTPUT
diff --git a/mirrors/Makefile.am b/mirrors/Makefile.am
index 95cb1266..7904f40b 100644
--- a/mirrors/Makefile.am
+++ b/mirrors/Makefile.am
@@ -1,43 +1,96 @@
# Default mirrors
pkgdata_MIRRORS = default
-# Mirrors in Asia (excl. China and Russia)
-pkgdata_ASIA_MIRRORS = mirror.albony.xyz mirror.bardia.tech \
-mirrors.cbrx.io linux.domainesia.com mirror.nevacloud.com \
-mirror.textcord.xyz tmx.xvx.my.id
-
-# Mirrors in China
-pkgdata_CHINA_MIRRORS = mirrors.tuna.tsinghua.edu.cn \
-mirror.iscas.ac.cn mirrors.nju.edu.cn mirrors.pku.edu.cn \
-mirrors.ustc.edu.cn mirrors.hit.edu.cn mirrors.bfsu.edu.cn \
-mirrors.aliyun.com mirrors.cqupt.edu.cn mirrors.dgut.edu.cn \
-mirror.nyist.edu.cn mirrors.njupt.edu.cn mirrors.sau.edu.cn \
-mirrors.scau.edu.cn mirrors.sdu.edu.cn mirrors.sustech.edu.cn \
-mirrors.zju.edu.cn mirror.sjtu.edu.cn mirrors.qvq.net.cn
+# Mirrors in Asia (excl. Chinese_Mainland and Russia)
+pkgdata_ASIA_MIRRORS = mirror.nag.albony.in \
+mirrors.cbrx.io linux.domainesia.com mirror.nevacloud.com \
+tmx.xvx.my.id mirrors.nguyenhoang.cloud \
+mirror.freedif.org mirror.twds.com.tw mirrors.in.sahilister.net \
+mirrors.saswata.cc termux.niranjan.co mirrors.ravidwivedi.in \
+mirror.jeonnam.school mirror.rinarin.dev mirrors.krnk.org \
+mirror.meowsmp.net
+
+# Mirrors in Chinese Mainland
+pkgdata_CHINESE_MAINLAND_MIRRORS = mirrors.tuna.tsinghua.edu.cn \
+mirror.iscas.ac.cn mirrors.nju.edu.cn mirrors.pku.edu.cn \
+mirrors.ustc.edu.cn mirrors.bfsu.edu.cn mirrors.aliyun.com \
+mirrors.cqupt.edu.cn mirror.nyist.edu.cn mirrors.sau.edu.cn \
+mirrors.sdu.edu.cn mirrors.sustech.edu.cn mirrors.zju.edu.cn \
+mirror.sjtu.edu.cn mirrors.hust.edu.cn mirrors.cernet.edu.cn
# Mirrors in Europe
-pkgdata_EUROPE_MIRRORS = grimler.se mirror.termux.dev \
-packages.termux.dev termux.librehat.com mirror.mwt.me \
-termux.mentality.rip mirrors.sahilister.in termux.cdn.lumito.net \
-termux.astra.in.ua termux.3san.dev mirror.accum.se \
-md.mirrors.hacktegic.com ftp.fau.de is.mirror.flokinet.net \
-ro.mirror.flokinet.net mirrors.medzik.dev mirrors.cfe.re \
-mirror.sunred.org mirror.autkin.net mirror.bouwhuis.network
+pkgdata_EUROPE_MIRRORS = grimler.se \
+packages.termux.dev termux.librehat.com \
+termux.mentality.rip mirrors.de.sahilister.net termux.cdn.lumito.net \
+termux.3san.dev mirror.accum.se \
+md.mirrors.hacktegic.com ftp.fau.de is.mirror.flokinet.net \
+ro.mirror.flokinet.net mirrors.medzik.dev \
+mirror.sunred.org mirror.autkin.net mirror.bouwhuis.network \
+mirror.leitecastro.com ftp.agdsn.de ftp.icm.edu.pl \
+nl.mirror.flokinet.net mirror.cutie.dating
# Mirrors in North America
-pkgdata_NORTH_AMERICA_MIRRORS = plug-mirror.rcac.purdue.edu \
-dl.kcubeterm.com mirrors.utermux.dev mirror.fcix.net mirror.mwt.me \
-mirror.vern.cc mirror.csclub.uwaterloo.ca mirror.quantum5.ca
+pkgdata_NORTH_AMERICA_MIRRORS = plug-mirror.rcac.purdue.edu \
+mirrors.utermux.dev mirror.fcix.net mirror.mwt.me \
+mirror.vern.cc mirror.csclub.uwaterloo.ca mirror.quantum5.ca \
+termux.danyael.xyz gnlug.org
# Mirrors in Oceania
-pkgdata_OCEANIA_MIRRORS = mirror.endianness.com
-
-# Mirrors in South America
-pkgdata_SOUTH_AMERICA_MIRRORS = mirrors.rda.run
+pkgdata_OCEANIA_MIRRORS = mirrors.middlendian.com
# Mirrors in Russia
pkgdata_RUSSIA_MIRRORS = mirror.mephi.ru repository.su
+
+# Removed, renamed or moved mirrors
+# Mirrors files are marked as conffiles and they are manually deleted
+# in preinst step of package upgrade as conffiles removed in a newer
+# version of the package are only deleted if package is purged and
+# would otherwise be left as is after package upgrades and would still
+# get used during mirror selection.
+pkgdata_MIRRORS_REMOVED = \
+asia/mirror.bardia.tech \
+asia/mirrors.omsinchan.ac.th \
+asia/mirrors.saswata.xyz \
+asia/mirror.textcord.xyz \
+asia/packages.nscdn.top \
+china/mirror.iscas.ac.cn \
+china/mirror.nyist.edu.cn \
+china/mirrors.aliyun.com \
+china/mirrors.bfsu.edu.cn \
+china/mirrors.cqupt.edu.cn \
+china/mirrors.dgut.edu.cn \
+china/mirrors.hit.edu.cn \
+china/mirror.sjtu.edu.cn \
+china/mirrors.nju.edu.cn \
+china/mirrors.njupt.edu.cn \
+china/mirrors.pku.edu.cn \
+china/mirrors.qvq.net.cn \
+china/mirrors.sau.edu.cn \
+china/mirrors.scau.edu.cn \
+china/mirrors.sdu.edu.cn \
+china/mirrors.sustech.edu.cn \
+china/mirrors.tuna.tsinghua.edu.cn \
+china/mirrors.ustc.edu.cn \
+china/mirrors.zju.edu.cn \
+chinese_mainland/mirrors.qvq.net.cn \
+europe/cdn.lumito.net \
+europe/mirror.mwt.me \
+europe/mirror.polido.pt \
+europe/mirrors.cfe.re \
+europe/mirror.termux.dev \
+europe/mirror.termux.dv \
+europe/termux.astra.in.ua \
+europe/termux.sahilister.in \
+north_america/dl.kcubeterm.com \
+north_america/packages.termux.dev \
+oceania/mirrors.wale.id.au \
+russia/mirror.surf \
+south_america/mirrors.rda.run \
+asia/mirror.albony.in
+
+
+
define install-mirror-rule
install-$1:
$$(MKDIR_P) $$(DESTDIR)$$(sysconfdir)/termux/mirrors/$1
@@ -56,21 +109,21 @@ uninstall-$1:
endef
$(eval $(call install-mirror-rule,asia,ASIA))
-$(eval $(call install-mirror-rule,china,CHINA))
+$(eval $(call install-mirror-rule,chinese_mainland,CHINESE_MAINLAND))
$(eval $(call install-mirror-rule,europe,EUROPE))
$(eval $(call install-mirror-rule,north_america,NORTH_AMERICA))
$(eval $(call install-mirror-rule,oceania,OCEANIA))
-$(eval $(call install-mirror-rule,south_america,SOUTH_AMERICA))
$(eval $(call install-mirror-rule,russia,RUSSIA))
$(eval $(call uninstall-mirror-rule,asia,ASIA))
-$(eval $(call uninstall-mirror-rule,china,CHINA))
+$(eval $(call uninstall-mirror-rule,chinese_mainland,CHINESE_MAINLAND))
$(eval $(call uninstall-mirror-rule,europe,EUROPE))
$(eval $(call uninstall-mirror-rule,north_america,NORTH_AMERICA))
$(eval $(call uninstall-mirror-rule,oceania,OCEANIA))
-$(eval $(call uninstall-mirror-rule,south_america,SOUTH_AMERICA))
$(eval $(call uninstall-mirror-rule,russia,RUSSIA))
+
+
install-default: $(pkgdata_MIRRORS)
$(MKDIR_P) $(DESTDIR)$(sysconfdir)/termux/mirrors
for f in $(pkgdata_MIRRORS); do \
@@ -84,11 +137,25 @@ uninstall-default:
done
-rmdir $(DESTDIR)$(sysconfdir)/termux/mirrors
-install-data-local: install-default install-asia install-china install-europe install-north_america install-oceania install-south_america install-russia
-uninstall-local: uninstall-default uninstall-asia uninstall-china uninstall-europe uninstall-north_america uninstall-oceania uninstall-south_america uninstall-russia
+
+uninstall-removed-mirrors:
+ for f in $(pkgdata_MIRRORS_REMOVED); do \
+ rm -f $(DESTDIR)$(sysconfdir)/termux/mirrors/$$f; \
+ done
+
+
+
+create-deb-control-files:
+ sh -c "cd $$(dirname $(DESTDIR)$(sysconfdir)); find $$(basename $(DESTDIR)$(sysconfdir))/termux/mirrors -type f" >> ../conffiles;
+ printf "# Delete removed mirrors\nfor f in %s; do\n if test -f \"%s/etc/termux/mirrors/\$$f\"; then\n echo \"Deleting removed mirror: \$$f\"; rm -f \"%s/etc/termux/mirrors/\$$f\";\n fi\ndone" "$(pkgdata_MIRRORS_REMOVED)" "$(termux_prefix)" "$(termux_prefix)" >> ../preinst;
+
+
+
+install-data-local: uninstall-removed-mirrors install-default install-asia install-chinese_mainland install-europe install-north_america install-oceania install-russia create-deb-control-files
+
+uninstall-local: uninstall-removed-mirrors uninstall-default uninstall-asia uninstall-chinese_mainland uninstall-europe uninstall-north_america uninstall-oceania uninstall-russia
EXTRA_DIST = $(pkgdata_MIRRORS) $(pkgdata_ASIA_MIRRORS) \
-$(pkgdata_CHINA_MIRRORS) $(pkgdata_EUROPE_MIRRORS) \
-$(pkgdata_NORTH_AMERICA_MIRRORS) $(pkgdata_OCEANIA_MIRRORS) \
-$(pkgdata_SOUTH_AMERICA_MIRRORS)
+$(pkgdata_CHINESE_MAINLAND_MIRRORS) $(pkgdata_EUROPE_MIRRORS) \
+$(pkgdata_NORTH_AMERICA_MIRRORS) $(pkgdata_OCEANIA_MIRRORS)
diff --git a/mirrors/asia/linux.domainesia.com b/mirrors/asia/linux.domainesia.com
index 20c5ec97..76364a92 100644
--- a/mirrors/asia/linux.domainesia.com
+++ b/mirrors/asia/linux.domainesia.com
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by DomaiNesia, hosted in Indonesia
+# Mirror by DomaiNesia. Hosted in Indonesia.
WEIGHT=1
MAIN="https://linux.domainesia.com/applications/termux/termux-main"
ROOT="https://linux.domainesia.com/applications/termux/termux-root"
diff --git a/mirrors/asia/mirror.albony.xyz b/mirrors/asia/mirror.albony.xyz
deleted file mode 100644
index 76e82581..00000000
--- a/mirrors/asia/mirror.albony.xyz
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by Albonycal, hosted in India
-WEIGHT=1
-MAIN="https://mirror.albony.xyz/termux/termux-main"
-ROOT="https://mirror.albony.xyz/termux/termux-root"
-X11="https://mirror.albony.xyz/termux/termux-x11"
diff --git a/mirrors/asia/mirror.bardia.tech b/mirrors/asia/mirror.bardia.tech
deleted file mode 100644
index 37a8f65d..00000000
--- a/mirrors/asia/mirror.bardia.tech
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by Bardia Moshiri, hosted in Iran
-WEIGHT=1
-MAIN="https://mirror.bardia.tech/termux/termux-main"
-ROOT="https://mirror.bardia.tech/termux/termux-root"
-X11="https://mirror.bardia.tech/termux/termux-x11"
diff --git a/mirrors/asia/mirror.freedif.org b/mirrors/asia/mirror.freedif.org
new file mode 100644
index 00000000..ea8c497a
--- /dev/null
+++ b/mirrors/asia/mirror.freedif.org
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by karibu. Hosted in Singapore.
+WEIGHT=1
+MAIN="https://mirror.freedif.org/termux/termux-main"
+ROOT="https://mirror.freedif.org/termux/termux-root"
+X11="https://mirror.freedif.org/termux/termux-x11"
diff --git a/mirrors/asia/mirror.jeonnam.school b/mirrors/asia/mirror.jeonnam.school
new file mode 100644
index 00000000..c7507ffa
--- /dev/null
+++ b/mirrors/asia/mirror.jeonnam.school
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Jeonnam High School Software Solution Club. Hosted in Republic of Korea.
+WEIGHT=1
+MAIN="https://mirror.jeonnam.school/termux/termux-main"
+ROOT="https://mirror.jeonnam.school/termux/termux-root"
+X11="https://mirror.jeonnam.school/termux/termux-x11"
diff --git a/mirrors/asia/mirror.meowsmp.net b/mirrors/asia/mirror.meowsmp.net
new file mode 100644
index 00000000..a442242c
--- /dev/null
+++ b/mirrors/asia/mirror.meowsmp.net
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by MeowIce. Hosted in Ho Chi Minh, Vietnam.
+WEIGHT=1
+MAIN="https://mirror.meowsmp.net/termux/termux-main"
+ROOT="https://mirror.meowsmp.net/termux/termux-root"
+X11="https://mirror.meowsmp.net/termux/termux-x11"
diff --git a/mirrors/asia/mirror.nag.albony.in b/mirrors/asia/mirror.nag.albony.in
new file mode 100644
index 00000000..ae3f9a7f
--- /dev/null
+++ b/mirrors/asia/mirror.nag.albony.in
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Albonycal. Hosted in India.
+WEIGHT=1
+MAIN="https://mirror.nag.albony.in/termux/termux-main"
+ROOT="https://mirror.nag.albony.in/termux/termux-root"
+X11="https://mirror.nag.albony.in/termux/termux-x11"
diff --git a/mirrors/asia/mirror.nevacloud.com b/mirrors/asia/mirror.nevacloud.com
index 1b4ed043..3966551d 100644
--- a/mirrors/asia/mirror.nevacloud.com
+++ b/mirrors/asia/mirror.nevacloud.com
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Nevacloud, hosted in Indonesia
+# Mirror by Nevacloud. Hosted in Indonesia.
WEIGHT=1
MAIN="https://mirror.nevacloud.com/applications/termux/termux-main"
ROOT="https://mirror.nevacloud.com/applications/termux/termux-root"
diff --git a/mirrors/asia/mirror.rinarin.dev b/mirrors/asia/mirror.rinarin.dev
new file mode 100644
index 00000000..69c9b280
--- /dev/null
+++ b/mirrors/asia/mirror.rinarin.dev
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Bombyeol. Hosted in Daegu, Republic of Korea.
+WEIGHT=1
+MAIN="https://mirror.rinarin.dev/termux/termux-main"
+ROOT="https://mirror.rinarin.dev/termux/termux-root"
+X11="https://mirror.rinarin.dev/termux/termux-x11"
diff --git a/mirrors/asia/mirror.textcord.xyz b/mirrors/asia/mirror.textcord.xyz
deleted file mode 100644
index a04847ac..00000000
--- a/mirrors/asia/mirror.textcord.xyz
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by Dev-Nergis, hosted in Republic of Korea
-WEIGHT=1
-MAIN="https://mirror.textcord.xyz/termux/termux-main"
-ROOT="https://mirror.textcord.xyz/termux/termux-root"
-X11="https://mirror.textcord.xyz/termux/termux-x11"
diff --git a/mirrors/asia/mirror.twds.com.tw b/mirrors/asia/mirror.twds.com.tw
new file mode 100644
index 00000000..ac4bf253
--- /dev/null
+++ b/mirrors/asia/mirror.twds.com.tw
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Taiwan Digital Streaming Co. Hosted in Taiwan.
+WEIGHT=1
+MAIN="https://mirror.twds.com.tw/termux/termux-main"
+ROOT="https://mirror.twds.com.tw/termux/termux-root"
+X11="https://mirror.twds.com.tw/termux/termux-x11"
diff --git a/mirrors/asia/mirrors.cbrx.io b/mirrors/asia/mirrors.cbrx.io
index 7b9e6023..286ffcb9 100644
--- a/mirrors/asia/mirrors.cbrx.io
+++ b/mirrors/asia/mirrors.cbrx.io
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by cyberrex0, hosted in Japan
+# Mirror by cyberrex0. Hosted in Japan.
WEIGHT=1
MAIN="https://mirrors.cbrx.io/apt/termux/termux-main"
ROOT="https://mirrors.cbrx.io/apt/termux/termux-root"
diff --git a/mirrors/asia/mirrors.in.sahilister.net b/mirrors/asia/mirrors.in.sahilister.net
new file mode 100644
index 00000000..7a8206cf
--- /dev/null
+++ b/mirrors/asia/mirrors.in.sahilister.net
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Sahil Dhiman. Hosted in India.
+WEIGHT=1
+MAIN="https://mirrors.in.sahilister.net/termux/termux-main/"
+ROOT="https://mirrors.in.sahilister.net/termux/termux-root/"
+X11="https://mirrors.in.sahilister.net/termux/termux-x11/"
\ No newline at end of file
diff --git a/mirrors/asia/mirrors.krnk.org b/mirrors/asia/mirrors.krnk.org
new file mode 100644
index 00000000..9d47c7f7
--- /dev/null
+++ b/mirrors/asia/mirrors.krnk.org
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by KuronekoServer (@kuroneko6423). Hosted in Tokyo, Japan.
+WEIGHT=1
+MAIN="https://mirrors.krnk.org/apt/termux/termux-main"
+ROOT="https://mirrors.krnk.org/apt/termux/termux-root"
+X11="https://mirrors.krnk.org/apt/termux/termux-x11"
diff --git a/mirrors/asia/mirrors.nguyenhoang.cloud b/mirrors/asia/mirrors.nguyenhoang.cloud
new file mode 100644
index 00000000..195fbf85
--- /dev/null
+++ b/mirrors/asia/mirrors.nguyenhoang.cloud
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Nguyen Hoang. Hosted in Hanoi, Vietnam.
+WEIGHT=1
+MAIN="https://mirrors.nguyenhoang.cloud/termux/termux-main"
+ROOT="https://mirrors.nguyenhoang.cloud/termux/termux-root"
+X11="https://mirrors.nguyenhoang.cloud/termux/termux-x11"
diff --git a/mirrors/asia/mirrors.ravidwivedi.in b/mirrors/asia/mirrors.ravidwivedi.in
new file mode 100644
index 00000000..e94da72c
--- /dev/null
+++ b/mirrors/asia/mirrors.ravidwivedi.in
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Ravi. Hosted in Mumbai, India.
+WEIGHT=1
+MAIN="https://mirrors.ravidwivedi.in/termux/termux-main"
+ROOT="https://mirrors.ravidwivedi.in/termux/termux-root"
+X11="https://mirrors.ravidwivedi.in/termux/termux-x11"
diff --git a/mirrors/asia/mirrors.saswata.cc b/mirrors/asia/mirrors.saswata.cc
new file mode 100644
index 00000000..498f7ae7
--- /dev/null
+++ b/mirrors/asia/mirrors.saswata.cc
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by saswatasarkar13. Hosted in India.
+WEIGHT=1
+MAIN="https://mirrors.saswata.cc/termux/termux-main"
+ROOT="https://mirrors.saswata.cc/termux/termux-root"
+X11="https://mirrors.saswata.cc/termux/termux-x11"
diff --git a/mirrors/asia/termux.niranjan.co b/mirrors/asia/termux.niranjan.co
new file mode 100644
index 00000000..811ae4fd
--- /dev/null
+++ b/mirrors/asia/termux.niranjan.co
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Niranjan Fartare. Hosted in Mumbai, India.
+WEIGHT=1
+MAIN="https://termux.niranjan.co/termux-main"
+ROOT="https://termux.niranjan.co/termux-root"
+X11="https://termux.niranjan.co/termux-x11"
diff --git a/mirrors/asia/tmx.xvx.my.id b/mirrors/asia/tmx.xvx.my.id
index aba261f5..dac306c9 100644
--- a/mirrors/asia/tmx.xvx.my.id
+++ b/mirrors/asia/tmx.xvx.my.id
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by MyDapitt, hosted in Singapore
+# Mirror by MyDapitt. Hosted in Singapore.
WEIGHT=1
MAIN="https://tmx.xvx.my.id/apt/termux-main"
ROOT="https://tmx.xvx.my.id/apt/termux-root"
diff --git a/mirrors/china/mirrors.cqupt.edu.cn b/mirrors/china/mirrors.cqupt.edu.cn
deleted file mode 100644
index b2266d74..00000000
--- a/mirrors/china/mirrors.cqupt.edu.cn
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by CQUPT - Chongqing University of Posts and Telecommunications
-WEIGHT=1
-MAIN="https://mirrors.cqupt.edu.cn/termux/apt/termux-main"
-ROOT="https://mirrors.cqupt.edu.cn/termux/apt/termux-root"
-X11="https://mirrors.cqupt.edu.cn/termux/apt/termux-x11"
diff --git a/mirrors/china/mirrors.dgut.edu.cn b/mirrors/china/mirrors.dgut.edu.cn
deleted file mode 100644
index ab3ee4f5..00000000
--- a/mirrors/china/mirrors.dgut.edu.cn
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by Dongguan University of Technology
-WEIGHT=1
-MAIN="https://mirrors.dgut.edu.cn/termux/apt/termux-main"
-ROOT="https://mirrors.dgut.edu.cn/termux/apt/termux-root"
-X11="https://mirrors.dgut.edu.cn/termux/apt/termux-x11"
diff --git a/mirrors/china/mirrors.hit.edu.cn b/mirrors/china/mirrors.hit.edu.cn
deleted file mode 100644
index 2564761b..00000000
--- a/mirrors/china/mirrors.hit.edu.cn
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by Harbin Institute of Technology
-WEIGHT=1
-MAIN="https://mirrors.hit.edu.cn/termux/apt/termux-main"
-ROOT="https://mirrors.hit.edu.cn/termux/apt/termux-root"
-X11="https://mirrors.hit.edu.cn/termux/apt/termux-x11"
diff --git a/mirrors/china/mirrors.njupt.edu.cn b/mirrors/china/mirrors.njupt.edu.cn
deleted file mode 100644
index bcc33288..00000000
--- a/mirrors/china/mirrors.njupt.edu.cn
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by Nanjing University of Posts and Telecommunications
-WEIGHT=1
-MAIN="https://mirrors.njupt.edu.cn/termux/apt/termux-main"
-ROOT="https://mirrors.njupt.edu.cn/termux/apt/termux-root"
-X11="https://mirrors.njupt.edu.cn/termux/apt/termux-x11"
diff --git a/mirrors/china/mirrors.qvq.net.cn b/mirrors/china/mirrors.qvq.net.cn
deleted file mode 100644
index adeef8a6..00000000
--- a/mirrors/china/mirrors.qvq.net.cn
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by @lrinQVQ
-WEIGHT=1
-MAIN="https://mirrors.qvq.net.cn/termux/termux-main"
-ROOT="https://mirrors.qvq.net.cn/termux/termux-root"
-X11="https://mirrors.qvq.net.cn/termux/termux-x11"
diff --git a/mirrors/china/mirrors.scau.edu.cn b/mirrors/china/mirrors.scau.edu.cn
deleted file mode 100644
index 13618fce..00000000
--- a/mirrors/china/mirrors.scau.edu.cn
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by South China Agricultural University
-WEIGHT=1
-MAIN="https://mirrors.scau.edu.cn/termux/apt/termux-main"
-ROOT="https://mirrors.scau.edu.cn/termux/apt/termux-root"
-X11="https://mirrors.scau.edu.cn/termux/apt/termux-x11"
diff --git a/mirrors/china/mirrors.ustc.edu.cn b/mirrors/china/mirrors.ustc.edu.cn
deleted file mode 100644
index decb3c60..00000000
--- a/mirrors/china/mirrors.ustc.edu.cn
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by University of Science and Technology of China
-WEIGHT=1
-MAIN="https://mirrors.ustc.edu.cn/termux/apt/termux-main"
-ROOT="https://mirrors.ustc.edu.cn/termux/apt/termux-root"
-X11="https://mirrors.ustc.edu.cn/termux/apt/termux-x11"
diff --git a/mirrors/china/mirror.iscas.ac.cn b/mirrors/chinese_mainland/mirror.iscas.ac.cn
similarity index 70%
rename from mirrors/china/mirror.iscas.ac.cn
rename to mirrors/chinese_mainland/mirror.iscas.ac.cn
index 908a77fd..d44bb363 100644
--- a/mirrors/china/mirror.iscas.ac.cn
+++ b/mirrors/chinese_mainland/mirror.iscas.ac.cn
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by ISCAS - Institute of Software, Chinese Academy of Sciences
+# Mirror by Institute of Software Chinese Academy of Sciences (ISCAS). Hosted in China.
WEIGHT=1
MAIN="https://mirror.iscas.ac.cn/termux/apt/termux-main"
ROOT="https://mirror.iscas.ac.cn/termux/apt/termux-root"
diff --git a/mirrors/china/mirror.nyist.edu.cn b/mirrors/chinese_mainland/mirror.nyist.edu.cn
similarity index 77%
rename from mirrors/china/mirror.nyist.edu.cn
rename to mirrors/chinese_mainland/mirror.nyist.edu.cn
index bff2afb0..64e0f62a 100644
--- a/mirrors/china/mirror.nyist.edu.cn
+++ b/mirrors/chinese_mainland/mirror.nyist.edu.cn
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Nanyang Institute of Technology
+# Mirror by Nanyang Institute of Technology. Hosted in China.
WEIGHT=1
MAIN="https://mirror.nyist.edu.cn/termux/apt/termux-main"
ROOT="https://mirror.nyist.edu.cn/termux/apt/termux-root"
diff --git a/mirrors/china/mirror.sjtu.edu.cn b/mirrors/chinese_mainland/mirror.sjtu.edu.cn
similarity index 74%
rename from mirrors/china/mirror.sjtu.edu.cn
rename to mirrors/chinese_mainland/mirror.sjtu.edu.cn
index 2d14263e..ed977c11 100644
--- a/mirrors/china/mirror.sjtu.edu.cn
+++ b/mirrors/chinese_mainland/mirror.sjtu.edu.cn
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by SJTUG, Shanghai Jiao Tong University
+# Mirror by Shanghai Jiao Tong University (@truc0). Hosted in China.
WEIGHT=1
MAIN="https://mirror.sjtu.edu.cn/termux/termux-main/"
ROOT="https://mirror.sjtu.edu.cn/termux/termux-root/"
diff --git a/mirrors/china/mirrors.aliyun.com b/mirrors/chinese_mainland/mirrors.aliyun.com
similarity index 56%
rename from mirrors/china/mirrors.aliyun.com
rename to mirrors/chinese_mainland/mirrors.aliyun.com
index f1d8649c..b942a9de 100644
--- a/mirrors/china/mirrors.aliyun.com
+++ b/mirrors/chinese_mainland/mirrors.aliyun.com
@@ -1,6 +1,6 @@
# This file is sourced by pkg
-# Mirror by Alibaba Open Source Mirror Site
+# Mirror by Alibaba Open Source Mirror Site. Hosted in China.
WEIGHT=1
MAIN="https://mirrors.aliyun.com/termux/termux-main"
ROOT="https://mirrors.aliyun.com/termux/termux-root"
-X11="https://mirrors.aliyun.com/termux/x11-packages"
+X11="https://mirrors.aliyun.com/termux/termux-x11"
diff --git a/mirrors/china/mirrors.bfsu.edu.cn b/mirrors/chinese_mainland/mirrors.bfsu.edu.cn
similarity index 76%
rename from mirrors/china/mirrors.bfsu.edu.cn
rename to mirrors/chinese_mainland/mirrors.bfsu.edu.cn
index 4b955cf1..1a3932c1 100644
--- a/mirrors/china/mirrors.bfsu.edu.cn
+++ b/mirrors/chinese_mainland/mirrors.bfsu.edu.cn
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Beijing Foreign Studies University
+# Mirror by Beijing Foreign Studies University. Hosted in China.
WEIGHT=1
MAIN="https://mirrors.bfsu.edu.cn/termux/apt/termux-main"
ROOT="https://mirrors.bfsu.edu.cn/termux/apt/termux-root"
diff --git a/mirrors/chinese_mainland/mirrors.cernet.edu.cn b/mirrors/chinese_mainland/mirrors.cernet.edu.cn
new file mode 100644
index 00000000..82a8d084
--- /dev/null
+++ b/mirrors/chinese_mainland/mirrors.cernet.edu.cn
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by CERNET. Mirrorbits geo-based mirror selection.
+WEIGHT=1
+MAIN="https://mirrors.cernet.edu.cn/termux/apt/termux-main"
+ROOT="https://mirrors.cernet.edu.cn/termux/apt/termux-root"
+X11="https://mirrors.cernet.edu.cn/termux/apt/termux-x11"
diff --git a/mirrors/chinese_mainland/mirrors.cqupt.edu.cn b/mirrors/chinese_mainland/mirrors.cqupt.edu.cn
new file mode 100644
index 00000000..c8b97565
--- /dev/null
+++ b/mirrors/chinese_mainland/mirrors.cqupt.edu.cn
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Chongqing University of Posts and Telecommunications (CQUPT). Hosted in China.
+WEIGHT=1
+MAIN="https://mirrors.cqupt.edu.cn/termux/termux-main"
+ROOT="https://mirrors.cqupt.edu.cn/termux/termux-root"
+X11="https://mirrors.cqupt.edu.cn/termux/termux-x11"
diff --git a/mirrors/chinese_mainland/mirrors.hust.edu.cn b/mirrors/chinese_mainland/mirrors.hust.edu.cn
new file mode 100644
index 00000000..38b32a99
--- /dev/null
+++ b/mirrors/chinese_mainland/mirrors.hust.edu.cn
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Huazhong University of Science and Technology. Hosted in China.
+WEIGHT=1
+MAIN="https://mirrors.hust.edu.cn/termux/apt/termux-main"
+ROOT="https://mirrors.hust.edu.cn/termux/apt/termux-root"
+X11="https://mirrors.hust.edu.cn/termux/apt/termux-x11"
diff --git a/mirrors/china/mirrors.nju.edu.cn b/mirrors/chinese_mainland/mirrors.nju.edu.cn
similarity index 75%
rename from mirrors/china/mirrors.nju.edu.cn
rename to mirrors/chinese_mainland/mirrors.nju.edu.cn
index e65d4b3e..874f5114 100644
--- a/mirrors/china/mirrors.nju.edu.cn
+++ b/mirrors/chinese_mainland/mirrors.nju.edu.cn
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by eScience Center, Nanjing University
+# Mirror by eScience Center in Nanjing University. Hosted in China.
WEIGHT=1
MAIN="https://mirrors.nju.edu.cn/termux/apt/termux-main"
ROOT="https://mirrors.nju.edu.cn/termux/apt/termux-root"
diff --git a/mirrors/china/mirrors.pku.edu.cn b/mirrors/chinese_mainland/mirrors.pku.edu.cn
similarity index 80%
rename from mirrors/china/mirrors.pku.edu.cn
rename to mirrors/chinese_mainland/mirrors.pku.edu.cn
index 599ab821..f168d2ea 100644
--- a/mirrors/china/mirrors.pku.edu.cn
+++ b/mirrors/chinese_mainland/mirrors.pku.edu.cn
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Peking University
+# Mirror by Peking University. Hosted in China.
WEIGHT=1
MAIN="https://mirrors.pku.edu.cn/termux/termux-main/"
ROOT="https://mirrors.pku.edu.cn/termux/termux-root/"
diff --git a/mirrors/china/mirrors.sau.edu.cn b/mirrors/chinese_mainland/mirrors.sau.edu.cn
similarity index 77%
rename from mirrors/china/mirrors.sau.edu.cn
rename to mirrors/chinese_mainland/mirrors.sau.edu.cn
index 9c254508..d18f1c59 100644
--- a/mirrors/china/mirrors.sau.edu.cn
+++ b/mirrors/chinese_mainland/mirrors.sau.edu.cn
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Shenyang Aerospace University
+# Mirror by Shenyang Aerospace University. Hosted in China.
WEIGHT=1
MAIN="https://mirrors.sau.edu.cn/termux/apt/termux-main"
ROOT="https://mirrors.sau.edu.cn/termux/apt/termux-root"
diff --git a/mirrors/china/mirrors.sdu.edu.cn b/mirrors/chinese_mainland/mirrors.sdu.edu.cn
similarity index 79%
rename from mirrors/china/mirrors.sdu.edu.cn
rename to mirrors/chinese_mainland/mirrors.sdu.edu.cn
index eb647fdf..bc063cd8 100644
--- a/mirrors/china/mirrors.sdu.edu.cn
+++ b/mirrors/chinese_mainland/mirrors.sdu.edu.cn
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Shandong University
+# Mirror by Shandong University. Hosted in China.
WEIGHT=1
MAIN="https://mirrors.sdu.edu.cn/termux/termux-main"
ROOT="https://mirrors.sdu.edu.cn/termux/termux-root"
diff --git a/mirrors/china/mirrors.sustech.edu.cn b/mirrors/chinese_mainland/mirrors.sustech.edu.cn
similarity index 74%
rename from mirrors/china/mirrors.sustech.edu.cn
rename to mirrors/chinese_mainland/mirrors.sustech.edu.cn
index 91771419..60d11ec4 100644
--- a/mirrors/china/mirrors.sustech.edu.cn
+++ b/mirrors/chinese_mainland/mirrors.sustech.edu.cn
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Southern University of Science and Technology
+# Mirror by Southern University of Science and Technology. Hosted in China.
WEIGHT=1
MAIN="https://mirrors.sustech.edu.cn/termux/apt/termux-main"
ROOT="https://mirrors.sustech.edu.cn/termux/apt/termux-root"
diff --git a/mirrors/china/mirrors.tuna.tsinghua.edu.cn b/mirrors/chinese_mainland/mirrors.tuna.tsinghua.edu.cn
similarity index 78%
rename from mirrors/china/mirrors.tuna.tsinghua.edu.cn
rename to mirrors/chinese_mainland/mirrors.tuna.tsinghua.edu.cn
index de596658..0175821f 100644
--- a/mirrors/china/mirrors.tuna.tsinghua.edu.cn
+++ b/mirrors/chinese_mainland/mirrors.tuna.tsinghua.edu.cn
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Tsinghua University TUNA Association
+# Mirror by Tsinghua University TUNA Association. Hosted in China.
WEIGHT=1
MAIN="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main"
ROOT="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-root"
diff --git a/mirrors/chinese_mainland/mirrors.ustc.edu.cn b/mirrors/chinese_mainland/mirrors.ustc.edu.cn
new file mode 100644
index 00000000..e84c5d12
--- /dev/null
+++ b/mirrors/chinese_mainland/mirrors.ustc.edu.cn
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by University of Science and Technology of China / ustclug. Hosted in China.
+WEIGHT=1
+MAIN="https://mirrors.ustc.edu.cn/termux/termux-main"
+ROOT="https://mirrors.ustc.edu.cn/termux/termux-root"
+X11="https://mirrors.ustc.edu.cn/termux/termux-x11"
diff --git a/mirrors/china/mirrors.zju.edu.cn b/mirrors/chinese_mainland/mirrors.zju.edu.cn
similarity index 71%
rename from mirrors/china/mirrors.zju.edu.cn
rename to mirrors/chinese_mainland/mirrors.zju.edu.cn
index e9a3778f..2f0ffe2d 100644
--- a/mirrors/china/mirrors.zju.edu.cn
+++ b/mirrors/chinese_mainland/mirrors.zju.edu.cn
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Information Technology Center, Zhejiang University
+# Mirror by Information Technology Center in Zhejiang University. Hosted in China.
WEIGHT=1
MAIN="https://mirrors.zju.edu.cn/termux/apt/termux-main"
ROOT="https://mirrors.zju.edu.cn/termux/apt/termux-root"
diff --git a/mirrors/default b/mirrors/default
index 24795acd..3153cc12 100644
--- a/mirrors/default
+++ b/mirrors/default
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Cached (by cloudflare) variant of packages.termux.dev
+# Termux origin repo. Cloudflare cached mirror of 'packages.termux.dev'.
WEIGHT=10
MAIN="https://packages-cf.termux.dev/apt/termux-main"
ROOT="https://packages-cf.termux.dev/apt/termux-root"
diff --git a/mirrors/europe/ftp.agdsn.de b/mirrors/europe/ftp.agdsn.de
new file mode 100644
index 00000000..8a0fe493
--- /dev/null
+++ b/mirrors/europe/ftp.agdsn.de
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by AG DSN. Hosted in Dresden, Germany.
+WEIGHT=1
+MAIN="https://ftp.agdsn.de/termux/termux-main"
+ROOT="https://ftp.agdsn.de/termux/termux-root"
+X11="https://ftp.agdsn.de/termux/termux-x11"
diff --git a/mirrors/europe/ftp.fau.de b/mirrors/europe/ftp.fau.de
index 4c05b642..dffa2f03 100644
--- a/mirrors/europe/ftp.fau.de
+++ b/mirrors/europe/ftp.fau.de
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by FAU, Hosted in Erlangen, Germany.
+# Mirror by FAU. Hosted in Erlangen, Germany.
WEIGHT=1
MAIN="https://ftp.fau.de/termux/termux-main"
ROOT="https://ftp.fau.de/termux/termux-root"
diff --git a/mirrors/europe/ftp.icm.edu.pl b/mirrors/europe/ftp.icm.edu.pl
new file mode 100644
index 00000000..84ca0cd0
--- /dev/null
+++ b/mirrors/europe/ftp.icm.edu.pl
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Warsaw University / rzm1. Hosted in Warsaw, Poland.
+WEIGHT=1
+MAIN="https://ftp.icm.edu.pl/pub/Linux/dist/termux/termux-main"
+ROOT="https://ftp.icm.edu.pl/pub/Linux/dist/termux/termux-root"
+X11="https://ftp.icm.edu.pl/pub/Linux/dist/termux/termux-x11"
diff --git a/mirrors/europe/grimler.se b/mirrors/europe/grimler.se
index 3ae6ea5a..e133a55d 100644
--- a/mirrors/europe/grimler.se
+++ b/mirrors/europe/grimler.se
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by grimler, hosted in the Netherlands
+# Mirror by grimler. Hosted in Netherlands.
WEIGHT=4
MAIN="https://grimler.se/termux/termux-main"
ROOT="https://grimler.se/termux/termux-root"
diff --git a/mirrors/europe/is.mirror.flokinet.net b/mirrors/europe/is.mirror.flokinet.net
index ca2d28f7..b74c4a9e 100644
--- a/mirrors/europe/is.mirror.flokinet.net
+++ b/mirrors/europe/is.mirror.flokinet.net
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by FlokiNET, Hosted in Reykjavík,Iceland.
+# Mirror by FlokiNET. Hosted in Reykjavík, Iceland.
WEIGHT=1
MAIN="https://is.mirror.flokinet.net/termux/termux-main"
ROOT="https://is.mirror.flokinet.net/termux/termux-root"
diff --git a/mirrors/europe/md.mirrors.hacktegic.com b/mirrors/europe/md.mirrors.hacktegic.com
index f0fc0883..d8502d80 100644
--- a/mirrors/europe/md.mirrors.hacktegic.com
+++ b/mirrors/europe/md.mirrors.hacktegic.com
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by amocrenco, Hosted in Chisinau, Moldova.
+# Mirror by artiommocrenco. Hosted in Chisinau, Moldova.
WEIGHT=1
MAIN="https://md.mirrors.hacktegic.com/termux/termux-main"
ROOT="https://md.mirrors.hacktegic.com/termux/termux-root"
diff --git a/mirrors/europe/mirror.accum.se b/mirrors/europe/mirror.accum.se
index fd2c2a13..004da706 100644
--- a/mirrors/europe/mirror.accum.se
+++ b/mirrors/europe/mirror.accum.se
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by the Academic Computer Club in Umeå, Hosted in Sweden
+# Mirror by Academic Computer Club in Umeå. Hosted in Sweden.
WEIGHT=1
MAIN="https://mirror.accum.se/mirror/termux.dev/termux-main"
ROOT="https://mirror.accum.se/mirror/termux.dev/termux-root"
diff --git a/mirrors/europe/mirror.autkin.net b/mirrors/europe/mirror.autkin.net
index 8209ae33..c936f0e2 100644
--- a/mirrors/europe/mirror.autkin.net
+++ b/mirrors/europe/mirror.autkin.net
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Andriy Utkin, hosted in Cambridge, UK, updated nightly
+# Mirror by Andriy Utkin. Hosted in Cambridge, UK.
WEIGHT=1
MAIN="https://mirror.autkin.net/termux/termux-main"
ROOT="https://mirror.autkin.net/termux/termux-root"
diff --git a/mirrors/europe/mirror.bouwhuis.network b/mirrors/europe/mirror.bouwhuis.network
index b09a8f79..5a133bb9 100644
--- a/mirrors/europe/mirror.bouwhuis.network
+++ b/mirrors/europe/mirror.bouwhuis.network
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by bouwhuis.network, hosted in Amsterdam, Netherlands.
+# Mirror by bouwhuis.network. Hosted in Amsterdam, Netherlands.
WEIGHT=1
MAIN="https://mirror.bouwhuis.network/termux/termux-main"
ROOT="https://mirror.bouwhuis.network/termux/termux-root"
diff --git a/mirrors/europe/mirror.cutie.dating b/mirrors/europe/mirror.cutie.dating
new file mode 100644
index 00000000..af6ba2ba
--- /dev/null
+++ b/mirrors/europe/mirror.cutie.dating
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by @CutiesDomain. Hosted in Germany.
+WEIGHT=1
+MAIN="https://mirror.cutie.dating/termux/termux-main"
+ROOT="https://mirror.cutie.dating/termux/termux-root"
+X11="https://mirror.cutie.dating/termux/termux-x11"
diff --git a/mirrors/europe/mirror.leitecastro.com b/mirrors/europe/mirror.leitecastro.com
new file mode 100644
index 00000000..399de6a1
--- /dev/null
+++ b/mirrors/europe/mirror.leitecastro.com
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Tomás Leite de Castro. Hosted in Lisbon, Portugal.
+WEIGHT=1
+MAIN="https://mirror.leitecastro.com/termux/termux-main"
+ROOT="https://mirror.leitecastro.com/termux/termux-root"
+X11="https://mirror.leitecastro.com/termux/termux-x11"
diff --git a/mirrors/europe/mirror.mwt.me b/mirrors/europe/mirror.mwt.me
deleted file mode 100644
index 77465f2e..00000000
--- a/mirrors/europe/mirror.mwt.me
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by Mwt, hosted in Luxembourg
-WEIGHT=1
-MAIN="https://mirror.mwt.me/termux/main"
-ROOT="https://mirror.mwt.me/termux/root"
-X11="https://mirror.mwt.me/termux/x11"
diff --git a/mirrors/europe/mirror.sunred.org b/mirrors/europe/mirror.sunred.org
index e3426984..c2b57e16 100644
--- a/mirrors/europe/mirror.sunred.org
+++ b/mirrors/europe/mirror.sunred.org
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by SunRed, hosted in Falkenstein, Germany.
+# Mirror by SunRed. Hosted in Falkenstein, Germany.
WEIGHT=1
MAIN="https://mirror.sunred.org/termux/termux-main"
ROOT="https://mirror.sunred.org/termux/termux-root"
diff --git a/mirrors/europe/mirror.termux.dev b/mirrors/europe/mirror.termux.dev
deleted file mode 100644
index 24535c2d..00000000
--- a/mirrors/europe/mirror.termux.dev
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Geo-based mirror selection with mirrorbits
-WEIGHT=1
-MAIN="https://mirror.termux.dev/termux-main"
-ROOT="https://mirror.termux.dev/termux-root"
-X11="https://mirror.termux.dev/termux-x11"
diff --git a/mirrors/europe/mirrors.cfe.re b/mirrors/europe/mirrors.cfe.re
deleted file mode 100644
index 74a35e9c..00000000
--- a/mirrors/europe/mirrors.cfe.re
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by cfxproxy, Hosted in Kalisz, Poland.
-WEIGHT=1
-MAIN="https://mirrors.cfe.re/termux/termux-main"
-ROOT="https://mirrors.cfe.re/termux/termux-root"
-X11="https://mirrors.cfe.re/termux/termux-x11"
diff --git a/mirrors/europe/mirrors.de.sahilister.net b/mirrors/europe/mirrors.de.sahilister.net
new file mode 100644
index 00000000..d898311b
--- /dev/null
+++ b/mirrors/europe/mirrors.de.sahilister.net
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Sahil Dhiman. Hosted in Germany.
+WEIGHT=1
+MAIN="https://mirrors.de.sahilister.net/termux/termux-main"
+ROOT="https://mirrors.de.sahilister.net/termux/termux-root"
+X11="https://mirrors.de.sahilister.net/termux/termux-x11"
diff --git a/mirrors/europe/mirrors.medzik.dev b/mirrors/europe/mirrors.medzik.dev
index 036dada5..8dc589e2 100644
--- a/mirrors/europe/mirrors.medzik.dev
+++ b/mirrors/europe/mirrors.medzik.dev
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by M3DZIK, Hosted in Frankfurt, Germany.
+# Mirror by M3DZIK. Hosted in Frankfurt, Germany.
WEIGHT=1
MAIN="https://mirrors.medzik.dev/termux/termux-main"
ROOT="https://mirrors.medzik.dev/termux/termux-root"
diff --git a/mirrors/europe/mirrors.sahilister.in b/mirrors/europe/mirrors.sahilister.in
deleted file mode 100644
index eccded5c..00000000
--- a/mirrors/europe/mirrors.sahilister.in
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by Sahilister hosted in Germany
-WEIGHT=1
-MAIN="https://mirrors.sahilister.in/termux/termux-main"
-ROOT="https://mirrors.sahilister.in/termux/termux-root"
-X11="https://mirrors.sahilister.in/termux/termux-x11"
diff --git a/mirrors/europe/nl.mirror.flokinet.net b/mirrors/europe/nl.mirror.flokinet.net
new file mode 100644
index 00000000..70aca8be
--- /dev/null
+++ b/mirrors/europe/nl.mirror.flokinet.net
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by FlokiNET. Hosted in Netherlands.
+WEIGHT=1
+MAIN="https://nl.mirror.flokinet.net/termux/termux-main"
+ROOT="https://nl.mirror.flokinet.net/termux/termux-root"
+X11="https://nl.mirror.flokinet.net/termux/termux-x11"
diff --git a/mirrors/europe/packages.termux.dev b/mirrors/europe/packages.termux.dev
index e47a1964..df5571c9 100644
--- a/mirrors/europe/packages.termux.dev
+++ b/mirrors/europe/packages.termux.dev
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Termux's origin repo, hosted in Falkenstein, Germany
+# Termux origin repo. Hosted in Falkenstein, Germany.
WEIGHT=1
MAIN="https://packages.termux.dev/apt/termux-main"
ROOT="https://packages.termux.dev/apt/termux-root"
diff --git a/mirrors/europe/ro.mirror.flokinet.net b/mirrors/europe/ro.mirror.flokinet.net
index b72c0dc4..313d3218 100644
--- a/mirrors/europe/ro.mirror.flokinet.net
+++ b/mirrors/europe/ro.mirror.flokinet.net
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by FlokiNET, Hosted in Bucharest,Romania.
+# Mirror by FlokiNET. Hosted in Bucharest, Romania.
WEIGHT=1
MAIN="https://ro.mirror.flokinet.net/termux/termux-main"
ROOT="https://ro.mirror.flokinet.net/termux/termux-root"
diff --git a/mirrors/europe/termux.3san.dev b/mirrors/europe/termux.3san.dev
index 9d68e9b2..f359bf60 100644
--- a/mirrors/europe/termux.3san.dev
+++ b/mirrors/europe/termux.3san.dev
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Exosunandnet
+# Mirror by Exosunandnet. Hosted in Spain.
WEIGHT=1
MAIN="https://termux.3san.dev/termux/termux-main"
ROOT="https://termux.3san.dev/termux/termux-root"
diff --git a/mirrors/europe/termux.astra.in.ua b/mirrors/europe/termux.astra.in.ua
deleted file mode 100644
index 28d6bb4e..00000000
--- a/mirrors/europe/termux.astra.in.ua
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by Astra ISP
-WEIGHT=1
-MAIN="https://termux.astra.in.ua/apt/termux-main"
-ROOT="https://termux.astra.in.ua/apt/termux-root"
-X11="https://termux.astra.in.ua/apt/termux-x11"
diff --git a/mirrors/europe/termux.cdn.lumito.net b/mirrors/europe/termux.cdn.lumito.net
index 9863404a..822606e9 100644
--- a/mirrors/europe/termux.cdn.lumito.net
+++ b/mirrors/europe/termux.cdn.lumito.net
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Lumito, hosted in Germany
+# Mirror by Lumito. Hosted in Germany.
WEIGHT=1
MAIN="https://termux.cdn.lumito.net/termux-main"
ROOT="https://termux.cdn.lumito.net/termux-root"
diff --git a/mirrors/europe/termux.librehat.com b/mirrors/europe/termux.librehat.com
index ab670fd3..203f5b06 100644
--- a/mirrors/europe/termux.librehat.com
+++ b/mirrors/europe/termux.librehat.com
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by librehat, hosted in the UK
+# Mirror by librehat. Hosted in UK.
WEIGHT=1
MAIN="https://termux.librehat.com/apt/termux-main"
ROOT="https://termux.librehat.com/apt/termux-root"
diff --git a/mirrors/europe/termux.mentality.rip b/mirrors/europe/termux.mentality.rip
index 9b295d6d..7a974d9d 100644
--- a/mirrors/europe/termux.mentality.rip
+++ b/mirrors/europe/termux.mentality.rip
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by A1batross, hosted in Finland
+# Mirror by A1batross. Hosted in Finland.
WEIGHT=1
MAIN="https://termux.mentality.rip/termux-main"
ROOT="https://termux.mentality.rip/termux-root"
diff --git a/mirrors/north_america/dl.kcubeterm.com b/mirrors/north_america/dl.kcubeterm.com
deleted file mode 100644
index 4ce69b47..00000000
--- a/mirrors/north_america/dl.kcubeterm.com
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by Kcubeterm, in California, US
-WEIGHT=1
-MAIN="https://dl.kcubeterm.com/termux-main"
-ROOT="https://dl.kcubeterm.com/termux-root"
-X11="https://dl.kcubeterm.com/termux-x11"
diff --git a/mirrors/north_america/gnlug.org b/mirrors/north_america/gnlug.org
new file mode 100644
index 00000000..3c319e63
--- /dev/null
+++ b/mirrors/north_america/gnlug.org
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by GNLUG, in Virginia, US
+WEIGHT=1
+MAIN="https://gnlug.org/pub/termux/termux-main"
+ROOT="https://gnlug.org/pub/termux/termux-root"
+X11="https://gnlug.org/pub/termux/termux-x11"
diff --git a/mirrors/north_america/mirror.csclub.uwaterloo.ca b/mirrors/north_america/mirror.csclub.uwaterloo.ca
index 3a389357..d3625481 100644
--- a/mirrors/north_america/mirror.csclub.uwaterloo.ca
+++ b/mirrors/north_america/mirror.csclub.uwaterloo.ca
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Computer Science Club of the University of Waterloo
+# Mirror by Computer Science Club in University of Waterloo. Hosted in Ontario, Canada.
WEIGHT=1
MAIN="https://mirror.csclub.uwaterloo.ca/termux/termux-main"
ROOT="https://mirror.csclub.uwaterloo.ca/termux/termux-root"
diff --git a/mirrors/north_america/mirror.fcix.net b/mirrors/north_america/mirror.fcix.net
index 7f0f0d34..c36fd22b 100644
--- a/mirrors/north_america/mirror.fcix.net
+++ b/mirrors/north_america/mirror.fcix.net
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Fremont Cabal Internet Exchange
+# Mirror by Fremont Cabal Internet Exchange. Hosted in Fremont, California, US.
WEIGHT=1
MAIN="https://mirror.fcix.net/termux/termux-main"
ROOT="https://mirror.fcix.net/termux/termux-root"
diff --git a/mirrors/north_america/mirror.mwt.me b/mirrors/north_america/mirror.mwt.me
index f7ed56d7..686b8a24 100644
--- a/mirrors/north_america/mirror.mwt.me
+++ b/mirrors/north_america/mirror.mwt.me
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Mwt, hosted in New Jersey, USA
+# Mirror by Mwt. Hosted in New Jersey, US.
WEIGHT=1
MAIN="https://mirror.mwt.me/termux/main"
ROOT="https://mirror.mwt.me/termux/root"
diff --git a/mirrors/north_america/mirror.quantum5.ca b/mirrors/north_america/mirror.quantum5.ca
index 6b906188..51fec692 100644
--- a/mirrors/north_america/mirror.quantum5.ca
+++ b/mirrors/north_america/mirror.quantum5.ca
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by quantum5
+# Mirror by quantum5. Hosted in Toronto, Ontario, Canada.
WEIGHT=1
MAIN="https://mirror.quantum5.ca/termux/termux-main"
ROOT="https://mirror.quantum5.ca/termux/termux-root"
diff --git a/mirrors/north_america/mirror.vern.cc b/mirrors/north_america/mirror.vern.cc
index 58441d70..f2c09ec3 100644
--- a/mirrors/north_america/mirror.vern.cc
+++ b/mirrors/north_america/mirror.vern.cc
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by vern.cc
+# Mirror by vern.cc. Hosted in New York, US.
WEIGHT=1
MAIN="https://mirror.vern.cc/termux/termux-main"
ROOT="https://mirror.vern.cc/termux/termux-root"
diff --git a/mirrors/north_america/mirrors.utermux.dev b/mirrors/north_america/mirrors.utermux.dev
index 5173ea00..d55d2717 100644
--- a/mirrors/north_america/mirrors.utermux.dev
+++ b/mirrors/north_america/mirrors.utermux.dev
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Utermux, hosted in San Jose, California, USA
+# Mirror by Utermux. Hosted in San Jose, California, US.
WEIGHT=1
MAIN="https://mirrors.utermux.dev/termux/termux-main"
ROOT="https://mirrors.utermux.dev/termux/termux-root"
diff --git a/mirrors/north_america/plug-mirror.rcac.purdue.edu b/mirrors/north_america/plug-mirror.rcac.purdue.edu
index e04fa9f6..2a9d3b0e 100644
--- a/mirrors/north_america/plug-mirror.rcac.purdue.edu
+++ b/mirrors/north_america/plug-mirror.rcac.purdue.edu
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by Purdue Linux User Group
+# Mirror by Purdue Linux User Group. Hosted in US.
WEIGHT=1
MAIN="https://plug-mirror.rcac.purdue.edu/termux/termux-main"
ROOT="https://plug-mirror.rcac.purdue.edu/termux/termux-root"
diff --git a/mirrors/north_america/termux.danyael.xyz b/mirrors/north_america/termux.danyael.xyz
new file mode 100644
index 00000000..030348f6
--- /dev/null
+++ b/mirrors/north_america/termux.danyael.xyz
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by Dan Yael. Hosted in Las Vegas, US.
+WEIGHT=1
+MAIN="https://termux.danyael.xyz/termux/termux-main"
+ROOT="https://termux.danyael.xyz/termux/termux-root"
+X11="https://termux.danyael.xyz/termux/termux-x11"
diff --git a/mirrors/oceania/mirror.endianness.com b/mirrors/oceania/mirror.endianness.com
deleted file mode 100644
index 28b49212..00000000
--- a/mirrors/oceania/mirror.endianness.com
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by DiffieHellman, hosted in Australia
-WEIGHT=1
-MAIN="https://mirror.endianness.com/termux/termux-main"
-ROOT="https://mirror.endianness.com/termux/termux-root"
-X11="https://mirror.endianness.com/termux/termux-x11"
diff --git a/mirrors/oceania/mirrors.middlendian.com b/mirrors/oceania/mirrors.middlendian.com
new file mode 100644
index 00000000..fc593656
--- /dev/null
+++ b/mirrors/oceania/mirrors.middlendian.com
@@ -0,0 +1,6 @@
+# This file is sourced by pkg
+# Mirror by DiffieHellman. Hosted in Australia.
+WEIGHT=1
+MAIN="https://mirrors.middlendian.com/termux/termux-main"
+ROOT="https://mirrors.middlendian.com/termux/termux-root"
+X11="https://mirrors.middlendian.com/termux/termux-x11"
diff --git a/mirrors/russia/mirror.mephi.ru b/mirrors/russia/mirror.mephi.ru
index af15d55a..57ddb544 100644
--- a/mirrors/russia/mirror.mephi.ru
+++ b/mirrors/russia/mirror.mephi.ru
@@ -1,5 +1,6 @@
# This file is sourced by pkg
-# Mirrors by National Research Nuclear University MEPhI
+# Mirror by National Research Nuclear University MEPhI. Hosted in Russia.
+# contact by email only: mirror-private@ut.mephi.ru
WEIGHT=1
MAIN="http://mirror.mephi.ru/termux/termux-main"
ROOT="http://mirror.mephi.ru/termux/termux-root"
diff --git a/mirrors/russia/repository.su b/mirrors/russia/repository.su
index a1ddee31..d6c183b5 100644
--- a/mirrors/russia/repository.su
+++ b/mirrors/russia/repository.su
@@ -1,5 +1,5 @@
# This file is sourced by pkg
-# Mirror by dmitry
+# Mirror by dmitry. Hosted in Russia.
WEIGHT=1
MAIN="https://repository.su/termux/termux-main/"
ROOT="https://repository.su/termux/termux-root/"
diff --git a/mirrors/south_america/mirrors.rda.run b/mirrors/south_america/mirrors.rda.run
deleted file mode 100644
index a021f0e8..00000000
--- a/mirrors/south_america/mirrors.rda.run
+++ /dev/null
@@ -1,6 +0,0 @@
-# This file is sourced by pkg
-# Mirror by Rodrigo de Avila, Hosted in Brochier, Brazil.
-WEIGHT=1
-MAIN="https://mirrors.rda.run/termux/termux-main"
-ROOT="https://mirrors.rda.run/termux/termux-root"
-X11="https://mirrors.rda.run/termux/termux-x11"
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 9dca981e..34d0fde5 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -24,7 +24,7 @@ termux-setup-package-manager termux-setup-storage termux-wake-lock \
termux-wake-unlock
# wrappers around tools in /system/bin:
-bin_SCRIPTS += cmd df getprop logcat ping ping6 pm settings top
+bin_SCRIPTS += df getprop logcat ping ping6 pm settings top
CLEANFILES = $(bin_SCRIPTS)
@@ -90,4 +90,3 @@ $(eval $(call wrapper-rule,pm))
$(eval $(call wrapper-rule,settings))
$(eval $(call wrapper-rule,top))
$(eval $(call wrapper-rule,umount))
-$(eval $(call wrapper-rule,cmd))
diff --git a/scripts/chsh.in b/scripts/chsh.in
index b74f58e6..32702b07 100644
--- a/scripts/chsh.in
+++ b/scripts/chsh.in
@@ -1,24 +1,58 @@
#!/bin/sh
+# shellcheck shell=dash
-set -e -u
+set -eu
-show_usage () {
+is_executable_file() {
+ test -f "$1" -a -x "$1"
+}
+
+show_usage() {
echo "usage: chsh [-s shell]"
echo "Change the login shell."
+ echo
+ if [ "${1:-}" = "login" ]; then
+ echo "The shell value must be one of following and cannot be 'login':"
+ else
+ echo "The shell value must be one of following:"
+ fi
+ echo " - Empty value to restore default shell."
+ echo " - Absolute path to shell starting with a '/'."
+ echo " - Relative path to shell not starting with a '/' relative to '@TERMUX_PREFIX@/bin'."
}
-set_shell () {
- if [ "$1" = login ]; then
- echo "login is not a valid shell"
+set_shell() {
+ if [ -z "${1:-}" ]; then
+ echo "Restoring default shell"
+ rm -f "$HOME/.termux/shell"
+ exit 0
+ fi
+
+ if [ "$1" = "login" ]; then
+ show_usage "login"
exit 1
fi
- mkdir -p $HOME/.termux
- NEW_SHELL=@TERMUX_PREFIX@/bin/$1
- if test -x $NEW_SHELL -a ! -d $NEW_SHELL; then
- ln -f -s $NEW_SHELL $HOME/.termux/shell
- else
- echo "$NEW_SHELL is not an executable file!"
+ mkdir -p "$HOME/.termux"
+
+ unset NEW_SHELL
+ case "$1" in
+ "/"*) NEW_SHELL="$1" ;;
+ *) NEW_SHELL="@TERMUX_PREFIX@/bin/$1" ;;
+ esac
+
+ SHELL_TARGET="$(realpath -s "$NEW_SHELL")"
+
+ if ! is_executable_file "$SHELL_TARGET"; then
+ echo "The shell file '$SHELL_TARGET' is not an executable file." 1>&2
+ exit 1
fi
+
+ if [ "$SHELL_TARGET" -ef "@TERMUX_PREFIX@/bin/login" ]; then
+ echo "The shell file '$SHELL_TARGET' must not point to the '@TERMUX_PREFIX@/bin/login' script." 1>&2
+ exit 1
+ fi
+
+ ln -sf "$SHELL_TARGET" "$HOME/.termux/shell"
}
O=`getopt -l help -- hs: "$@"`
@@ -26,19 +60,18 @@ eval set -- "$O"
while true; do
case "$1" in
-h|--help) show_usage; exit 0;;
- -s) set_shell $2; exit 0;;
+ -s) set_shell "$2"; exit 0;;
--) shift; break;;
*) echo Error; show_usage; exit 1;;
esac
done
DEFAULT_SHELL=bash
-if [ ! -x @TERMUX_PREFIX@/bin/$DEFAULT_SHELL ]; then DEFAULT_SHELL=sh; fi
+if ! is_executable_file "@TERMUX_PREFIX@/bin/$DEFAULT_SHELL"; then DEFAULT_SHELL=sh; fi
echo Changing the login shell
echo Enter the new value, or press ENTER for the default
printf " Login Shell [$DEFAULT_SHELL]: "
read shell
-if [ -z "$shell" ]; then shell=$DEFAULT_SHELL; fi
-set_shell $shell
+set_shell "$shell"
diff --git a/scripts/login.in b/scripts/login.in
index 393322e3..e8620898 100644
--- a/scripts/login.in
+++ b/scripts/login.in
@@ -1,4 +1,18 @@
#!/bin/sh
+# shellcheck shell=dash
+
+is_executable_file() {
+ test -f "$1" -a -x "$1"
+}
+
+set_default_shell() {
+ for file in "@TERMUX_PREFIX@/bin/bash" "@TERMUX_PREFIX@/bin/sh" "/system/bin/sh"; do
+ if is_executable_file "$file"; then
+ SHELL="$file"
+ break
+ fi
+ done
+}
if tty >/dev/null 2>&1 && [ $# = 0 ] && [ ! -f ~/.hushlogin ] && [ -z "$TERMUX_HUSHLOGIN" ]; then
# Use user defined dynamic motd file if it exists
@@ -19,17 +33,24 @@ if tty >/dev/null 2>&1 && [ $# = 0 ] && [ -f @TERMUX_PREFIX@/etc/motd-playstore
printf '\033[0;31m'; cat @TERMUX_PREFIX@/etc/motd-playstore; printf '\033[0m'
fi
-if [ -G ~/.termux/shell ]; then
- export SHELL="`realpath ~/.termux/shell`"
-else
- for file in @TERMUX_PREFIX@/bin/bash @TERMUX_PREFIX@/bin/sh /system/bin/sh; do
- if [ -x $file ]; then
- export SHELL=$file
- break
- fi
- done
+unset SHELL
+SHELL_FILE=~/.termux/shell
+
+if [ -L "$SHELL_FILE" ]; then
+ # Set the symlink's value as the shell target.
+ SHELL_TARGET="$(readlink "$SHELL_FILE")"
+ if is_executable_file "$SHELL_TARGET" &&
+ [ ! "$SHELL_TARGET" -ef "@TERMUX_PREFIX@/bin/login" ]; then
+ SHELL="$SHELL_TARGET"
+ fi
fi
+if [ -z "${SHELL:-}" ]; then
+ set_default_shell
+fi
+
+export SHELL
+
# TERMUX_APP_PACKAGE_MANAGER should be exported by termux-app v0.119.0+ itself
if [ -z "${TERMUX_APP_PACKAGE_MANAGER-}" ]; then
if { [ -n "$(command -v dpkg)" ] && dpkg --compare-versions "$TERMUX_VERSION" lt 0.119.0; } || # apt
@@ -39,8 +60,17 @@ if [ -z "${TERMUX_APP_PACKAGE_MANAGER-}" ]; then
fi
fi
-if [ -f @TERMUX_PREFIX@/lib/libtermux-exec.so ]; then
- export LD_PRELOAD=@TERMUX_PREFIX@/lib/libtermux-exec.so
+# Export `libtermux-exec-ld-preload.so` for `termux-exec`
+# package version `>= 2.0.0`.
+# Some devices may not support setting `$LD_PRELOAD`.
+# - https://github.com/termux/termux-packages/issues/2066
+# - https://github.com/termux/termux-packages/commit/1ec6c042
+# - https://github.com/termux/termux-packages/commit/6fb2bb2f
+if [ -f "@TERMUX_PREFIX@/lib/libtermux-exec-ld-preload.so" ]; then
+ export LD_PRELOAD="@TERMUX_PREFIX@/lib/libtermux-exec-ld-preload.so"
+ $SHELL -c "coreutils --coreutils-prog=true" > /dev/null 2>&1 || unset LD_PRELOAD
+elif [ -f "@TERMUX_PREFIX@/lib/libtermux-exec.so" ]; then
+ export LD_PRELOAD="@TERMUX_PREFIX@/lib/libtermux-exec.so"
$SHELL -c "coreutils --coreutils-prog=true" > /dev/null 2>&1 || unset LD_PRELOAD
fi
diff --git a/scripts/pkg.in b/scripts/pkg.in
index 33c89cde..8fc9ea8a 100644
--- a/scripts/pkg.in
+++ b/scripts/pkg.in
@@ -8,6 +8,7 @@ if [[ "$(id -u)" == "0" ]]; then
fi
# Setup TERMUX_APP_PACKAGE_MANAGER
+# shellcheck source=/dev/null
source "@TERMUX_PREFIX@/bin/termux-setup-package-manager" || exit 1
MIRROR_BASE_DIR="@TERMUX_PREFIX@/etc/termux/mirrors"
@@ -77,6 +78,24 @@ check_mirror() {
"$mirror/dists/stable/Release" >/dev/null 2>&1
}
+check_command() {
+ local command="$1"
+
+ local errors
+ if ! errors="$("$@" 2>&1 1>/dev/null)"; then
+ echo "$errors" 1>&2
+ echo "Failed to run the '$command' command." 1>&2
+ if [[ "$errors" == *"CANNOT LINK EXECUTABLE"* ]]; then
+ echo -n "To fix the '$command' command, manually upgrade all packages by running: " 1>&2
+ case "$TERMUX_APP_PACKAGE_MANAGER" in
+ apt) echo "\`apt update && apt full-upgrade\`" 1>&2;;
+ pacman) echo "\`pacman -Syu\`" 1>&2;;
+ esac
+ fi
+ exit 1
+ fi
+}
+
hostname() {
echo "$1" | awk -F'[/:]' '{print $4}'
}
@@ -90,34 +109,90 @@ last_modified() {
echo $((now - mtime))
}
+sed_escape_replacement() {
+ local r="$1"
+ r="${r//[\\]/\\\\}" # Escape `\`.
+ r="${r//[\/]/\\\/}" # Escape `/`.
+ r="${r//[&]/\\\&}" # Escape `&`.
+ echo "$r"
+}
+
has_repo() {
# Check if root-repo or x11-repo are installed
repo="$1"
- if [ -f "@TERMUX_PREFIX@/etc/apt/sources.list.d/$repo.list" ]; then
- echo true
- else
- echo false
+ if [[ -f "@TERMUX_PREFIX@/etc/apt/sources.list.d/$repo.sources" ]]; then
+ echo deb822
+ elif [[ -f "@TERMUX_PREFIX@/etc/apt/sources.list.d/$repo.list" ]]; then
+ echo legacy
fi
}
+unset_mirror_variables() {
+ unset MAIN
+ unset X11
+ unset ROOT
+ unset WEIGHT
+}
+
get_mirror_url() {
- source "$1"
- echo $MAIN
+ local -r _mirror="$1"
+ local -r _has_repo_x11="$2"
+ local -r _has_repo_root="$3"
+
+ unset_mirror_variables
+ # shellcheck source=/dev/null
+ source "$_mirror"
+
+ if [[ -z "${MAIN:-}" ]]; then
+ echo "Warn: Ignoring mirror '$_mirror' without main channel url" >&2
+ return 0
+ elif [[ ! "${MAIN:-}" =~ ^https?://[^[:space:]]+$ ]]; then
+ echo "Warn: Ignoring mirror '$_mirror' with invalid main channel url '${MAIN:-}'" >&2
+ return 0
+ fi
+
+ if [[ "$_has_repo_x11" == "true" ]]; then
+ if [[ -z "${X11:-}" ]]; then
+ echo "Warn: Ignoring mirror '$_mirror' without x11 channel url" >&2
+ return 0
+ elif [[ ! "${X11:-}" =~ ^https?://[^[:space:]]+$ ]]; then
+ echo "Warn: Ignoring mirror '$_mirror' with invalid x11 channel url '${X11:-}'" >&2
+ return 0
+ fi
+ fi
+
+ if [[ "$_has_repo_root" == "true" ]]; then
+ if [[ -z "${ROOT:-}" ]]; then
+ echo "Warn: Ignoring mirror '$_mirror' without root channel url" >&2
+ return 0
+ elif [[ ! "${ROOT:-}" =~ ^https?://[^[:space:]]+$ ]]; then
+ echo "Warn: Ignoring mirror '$_mirror' with invalid root channel url '${ROOT:-}'" >&2
+ return 0
+ fi
+ fi
+
+ if [[ ! "${WEIGHT:-}" =~ ^[0-9]+$ ]]; then
+ echo "Warn: Ignoring mirror '$_mirror' with invalid weight '${WEIGHT:-}'" >&2
+ return 0
+ fi
+
+ echo "$MAIN"
}
get_mirror_weight() {
+ unset_mirror_variables
source "$1"
- if [[ ! "$WEIGHT" =~ ^[0-9]+$ ]]; then
- echo "Error: Invalid weight in mirror $1" >&2
- exit 1
- fi
- echo $WEIGHT
+ echo "$WEIGHT"
}
select_mirror() {
local current_mirror
- current_mirror=$(grep -oP 'https?://[^\s]+' <(grep -m 1 -P "^\s*deb\s+" @TERMUX_PREFIX@/etc/apt/sources.list) || true)
+ if [ -f "@TERMUX_PREFIX@/etc/apt/sources.list.d/main.sources" ]; then
+ current_mirror=$(grep -oE 'https?://[^ ]+' <(grep -m 1 -E '^[[:space:]]*URIs:[[:space:]]+' "@TERMUX_PREFIX@/etc/apt/sources.list.d/main.sources") || :)
+ elif [ -f "@TERMUX_PREFIX@/etc/apt/sources.list" ]; then
+ current_mirror=$(grep -oE 'https?://[^ ]+' <(grep -m 1 -E '^[[:space:]]*deb[[:space:]]+' "@TERMUX_PREFIX@/etc/apt/sources.list") || :)
+ fi
# Do not update mirror if $TERMUX_PKG_NO_MIRROR_SELECT was set.
if [ -n "${TERMUX_PKG_NO_MIRROR_SELECT-}" ] && [ -n "$current_mirror" ]; then
@@ -128,20 +203,23 @@ select_mirror() {
if [ -d "@TERMUX_PREFIX@/etc/termux/chosen_mirrors" ]; then
# Mirror group selected
- mirrors=($(find @TERMUX_PREFIX@/etc/termux/chosen_mirrors/ -type f ! -name "*\.dpkg-old" ! -name "*\.dpkg-new" ! -name "*~"))
+ mirrors=($(find "@TERMUX_PREFIX@/etc/termux/chosen_mirrors/" -type f ! -name "*\.dpkg-old" ! -name "*\.dpkg-new" ! -name "*~"))
elif [ -f "@TERMUX_PREFIX@/etc/termux/chosen_mirrors" ]; then
# Single mirror selected
- mirrors=("$(realpath @TERMUX_PREFIX@/etc/termux/chosen_mirrors)")
+ mirrors=("$(realpath "@TERMUX_PREFIX@/etc/termux/chosen_mirrors")")
elif [ -L "@TERMUX_PREFIX@/etc/termux/chosen_mirrors" ]; then
# Broken symlink, use all mirrors
mirrors=("${MIRROR_BASE_DIR}/default")
- mirrors+=($(find ${MIRROR_BASE_DIR}/{asia,china,europe,north_america,oceania,south_america,russia}/ -type f ! -name "*\.dpkg-old" ! -name "*\.dpkg-new" ! -name "*~"))
+ mirrors+=($(find "${MIRROR_BASE_DIR}"/{asia,chinese_mainland,europe,north_america,oceania,russia}/ -type f ! -name "*\.dpkg-old" ! -name "*\.dpkg-new" ! -name "*~"))
else
echo "No mirror or mirror group selected. You might want to select one by running 'termux-change-repo'"
mirrors=("${MIRROR_BASE_DIR}/default")
- mirrors+=($(find ${MIRROR_BASE_DIR}/{asia,china,europe,north_america,oceania,south_america,russia}/ -type f ! -name "*\.dpkg-old" ! -name "*\.dpkg-new" ! -name "*~"))
+ mirrors+=($(find ${MIRROR_BASE_DIR}/{asia,chinese_mainland,europe,north_america,oceania,russia}/ -type f ! -name "*\.dpkg-old" ! -name "*\.dpkg-new" ! -name "*~"))
fi
+ # Ensure `curl` can execute, otherwise all mirror checks will fail with `bad`.
+ check_command curl --version
+
# Mirrors are rotated if 6 hours timeout has been passed or mirror is no longer accessible.
local pkgcache="@TERMUX_CACHE_DIR@/apt/pkgcache.bin"
if [ -e "$pkgcache" ] && (( $(last_modified "$pkgcache") <= 6 * 3600 )) && [ "$force_check_mirror" = "false" ]; then
@@ -178,10 +256,17 @@ select_mirror() {
local total_mirrors=${#mirrors[@]}
local parallel_jobs_current_count=1
+ has_repo_x11="$(has_repo x11)"
+ has_repo_root="$(has_repo root)"
+
set +e
i=0
for mirror in "${!mirrors[@]}"; do
- url="$(get_mirror_url ${mirrors[$mirror]})"
+ url="$(get_mirror_url "${mirrors[$mirror]}" "$has_repo_x11" "$has_repo_root")"
+ if [ -z "$url" ]; then
+ unset "mirrors[$mirror]"
+ continue
+ fi
job_number=$parallel_jobs_current_count
parallel_jobs_current_count=$((parallel_jobs_current_count + 1))
@@ -268,28 +353,53 @@ select_mirror() {
selected_mirror="${weighted_mirrors[${random_weight}]}"
fi
- if [ -n "$selected_mirror" ]; then
- (
- source "$selected_mirror"
- echo "deb $MAIN stable main" > @TERMUX_PREFIX@/etc/apt/sources.list
- if [ "$(has_repo x11)" == "true" ]; then
- echo "deb $X11 x11 main" > @TERMUX_PREFIX@/etc/apt/sources.list.d/x11.list
- fi
- if [ "$(has_repo root)" == "true" ]; then
- echo "deb $ROOT root stable" > @TERMUX_PREFIX@/etc/apt/sources.list.d/root.list
- fi
- )
- else
+ if [ -z "$selected_mirror" ]; then
# Should not happen unless there is some issue with
# the script, or the mirror files
echo "Error: None of the mirrors are accessible"
exit 1
fi
+
+ (
+ unset_mirror_variables
+ # shellcheck source=/dev/null
+ source "$selected_mirror"
+
+ case "$(has_repo main)" in
+ 'deb822')
+ sed -i -e "s|URIs:.*|$(sed_escape_replacement "URIs: $MAIN")|" \
+ "@TERMUX_PREFIX@/etc/apt/sources.list.d/main.sources"
+ ;;
+ # There should always be a main repo, so fallback to
+ # creating sources.list if the `main.sources` file is missing
+ *) echo "deb $MAIN stable main" > "@TERMUX_PREFIX@/etc/apt/sources.list";;
+ esac
+
+ case "${has_repo_x11:-}" in
+ 'deb822')
+ sed -i -e "s|URIs:.*|$(sed_escape_replacement "URIs: $X11")|" \
+ "@TERMUX_PREFIX@/etc/apt/sources.list.d/x11.sources"
+ ;;
+ 'legacy') echo "deb $X11 x11 main" > "@TERMUX_PREFIX@/etc/apt/sources.list.d/x11.list";;
+ esac
+
+ case "${has_repo_root:-}" in
+ 'deb822')
+ sed -i -e "s|URIs:.*|$(sed_escape_replacement "URIs: $ROOT")|" \
+ "@TERMUX_PREFIX@/etc/apt/sources.list.d/root.sources"
+ ;;
+ 'legacy') echo "deb $ROOT root stable" > "@TERMUX_PREFIX@/etc/apt/sources.list.d/root.list";;
+ esac
+ )
}
update_apt_cache() {
local current_host
- current_host=$(head -n 1 <(sed -nE -e 's|^\s*deb\s+https?://(.+)\s+stable\s+main$|\1|p' @TERMUX_PREFIX@/etc/apt/sources.list) || true)
+ if [ -f "@TERMUX_PREFIX@/etc/apt/sources.list.d/main.sources" ]; then
+ current_host=$(head -n 1 <(sed -nE 's|^\s*URIs:\s+https?://(.+)$|\1|p' "@TERMUX_PREFIX@/etc/apt/sources.list.d/main.sources") || :)
+ elif [ -f "@TERMUX_PREFIX@/etc/apt/sources.list" ]; then
+ current_host=$(head -n 1 <(sed -nE 's|^\s*deb\s+https?://(.+)\s+stable\s+main$|\1|p' "@TERMUX_PREFIX@/etc/apt/sources.list") || :)
+ fi
if [ -z "$current_host" ]; then
# No primary repositories configured?
@@ -313,7 +423,11 @@ update_apt_cache() {
cache_modified=$(last_modified "@TERMUX_CACHE_DIR@/apt/pkgcache.bin")
local sources_modified
- sources_modified=$(last_modified "@TERMUX_PREFIX@/etc/apt/sources.list")
+ if [ -f "@TERMUX_PREFIX@/etc/apt/sources.list.d/main.sources" ]; then
+ sources_modified=$(last_modified "@TERMUX_PREFIX@/etc/apt/sources.list.d/main.sources")
+ elif [ -f "@TERMUX_PREFIX@/etc/apt/sources.list" ]; then
+ sources_modified=$(last_modified "@TERMUX_PREFIX@/etc/apt/sources.list")
+ fi
if (( sources_modified <= cache_modified )) || (( cache_modified > 1200 )); then
apt update
@@ -322,8 +436,8 @@ update_apt_cache() {
force_check_mirror=false
if [ "${1-}" = "--check-mirror" ]; then
- force_check_mirror=true
- shift 1
+ force_check_mirror=true
+ shift 1
fi
if [[ $# = 0 || $(echo "$1" | grep "^h") ]]; then
@@ -347,7 +461,7 @@ case "$TERMUX_APP_PACKAGE_MANAGER" in
rei*) apt install --reinstall "$@";;
se*) select_mirror; update_apt_cache; apt search "$@";;
un*|rem*|rm|del*) apt remove "$@";;
- upd*) select_mirror; apt update;;
+ upd*) select_mirror; apt update;;
up|upg*) select_mirror; apt update; apt full-upgrade "$@";;
*) ERROR=true;;
esac;;
@@ -363,7 +477,7 @@ case "$TERMUX_APP_PACKAGE_MANAGER" in
rei*) pacman -S "$@";;
se*) pacman -Sys "$@";;
un*|rem*|rm|del*) pacman -Rcns "$@";;
- upd*) pacman -Sy "$@";;
+ upd*) pacman -Sy "$@";;
up|upg*) pacman -Syu "$@";;
*) ERROR=true;;
esac;;
diff --git a/scripts/termux-backup.in b/scripts/termux-backup.in
index 99c47359..4c05bb41 100644
--- a/scripts/termux-backup.in
+++ b/scripts/termux-backup.in
@@ -132,8 +132,7 @@ else
fi
msg "Ensure that all files and directories are accessible..."
-find "@TERMUX_BASE_DIR@/usr" -type d -print0 | xargs -0 -r chmod u+rx || true
-find "@TERMUX_BASE_DIR@/usr" -type f -print0 | xargs -0 -r chmod u+r || true
+find "@TERMUX_BASE_DIR@/usr" -type d,f -print0 | xargs -0 -r chmod u+rX || true
msg "Backing up installed packages..."
tar --warning=no-file-ignored $TAR_EXTRA_OPTS -c \
diff --git a/scripts/termux-change-repo.in b/scripts/termux-change-repo.in
index 323ea0ee..666d4405 100644
--- a/scripts/termux-change-repo.in
+++ b/scripts/termux-change-repo.in
@@ -22,19 +22,18 @@ unlink_and_link() {
select_repository_group() {
MIRRORS=()
- MIRRORS+=("All mirrors" "All in the entire world" "on")
- MIRRORS+=("Mirrors in Asia" "All in Asia (excl. China and Russia)" "off")
- MIRRORS+=("Mirrors in China" "All in China" "off")
- MIRRORS+=("Mirrors in Europe" "All in Europe" "off")
- MIRRORS+=("Mirrors in North America" "All in North America" "off")
- MIRRORS+=("Mirrors in Oceania" "All in Oceania" "off")
- MIRRORS+=("Mirrors in South America" "All in South America" "off")
- MIRRORS+=("Mirrors in Russia" "All in Russia" "off")
+ MIRRORS+=("All mirrors" "All in the entire world")
+ MIRRORS+=("Mirrors in Asia" "All in Asia (excl. Chinese Mainland and Russia)")
+ MIRRORS+=("Mirrors in Chinese Mainland" "All in Chinese Mainland")
+ MIRRORS+=("Mirrors in Europe" "All in Europe")
+ MIRRORS+=("Mirrors in North America" "All in North America")
+ MIRRORS+=("Mirrors in Oceania" "All in Oceania")
+ MIRRORS+=("Mirrors in Russia" "All in Russia")
local TEMPFILE="$(mktemp @TERMUX_PREFIX@/tmp/mirror.XXXXXX)"
dialog \
--title "termux-change-repo" --clear \
- --radiolist "Which group of mirrors do you want to use? Select with space." 0 0 0 \
+ --menu "Which group of mirrors do you want to use?" 0 0 0 \
"${MIRRORS[@]}" --and-widget \
2> "$TEMPFILE"
retval=$?
@@ -55,12 +54,12 @@ select_repository_group() {
rm "$TEMPFILE"
if [ "$mirror_group" == "Mirrors in Asia" ]; then
- echo "[*] Mirrors in Asia (excl. China and Russia) selected"
+ echo "[*] Mirrors in Asia (excl. Chinese Mainland and Russia) selected"
unlink_and_link ${MIRROR_BASE_DIR}/asia
- elif [ "$mirror_group" == "Mirrors in China" ]; then
- echo "[*] Mirrors in China selected"
- unlink_and_link ${MIRROR_BASE_DIR}/china
+ elif [ "$mirror_group" == "Mirrors in Chinese Mainland" ]; then
+ echo "[*] Mirrors in Chinese Mainland selected"
+ unlink_and_link ${MIRROR_BASE_DIR}/chinese_mainland
elif [ "$mirror_group" == "Mirrors in Europe" ]; then
echo "[*] Mirrors in Europe selected"
@@ -74,10 +73,6 @@ select_repository_group() {
echo "[*] Mirrors in Oceania selected"
unlink_and_link ${MIRROR_BASE_DIR}/oceania
- elif [ "$mirror_group" == "Mirrors in South America" ]; then
- echo "[*] Mirrors in South America selected"
- unlink_and_link ${MIRROR_BASE_DIR}/south_america
-
elif [ "$mirror_group" == "Mirrors in Russia" ]; then
echo "[*] Mirrors in Russia selected"
unlink_and_link ${MIRROR_BASE_DIR}/russia
@@ -93,30 +88,36 @@ select_repository_group() {
}
get_mirror_url() {
- basename "$1"
+ echo "${1##*/}"
}
get_mirror_description() {
- head -n 2 "$1" | tail -n 1 | cut -d" " -f2-
+ local -a lines
+ readarray -t lines < "$1"
+ local mirror_description="${lines[1]#* }"
+ mirror_description="${mirror_description//Mirror by /M: }"
+ mirror_description="${mirror_description//. Hosted in /. }"
+ mirror_description="${mirror_description%.}"
+ printf '%s\n' "$mirror_description"
}
select_individual_mirror() {
- mirrors=($(find ${MIRROR_BASE_DIR}/{asia,china,europe,north_america,oceania,south_america,russia}/ -type f ! -name "*\.dpkg-old" ! -name "*\.dpkg-new" ! -name "*~"))
+ mirrors=($(find ${MIRROR_BASE_DIR}/{asia,chinese_mainland,europe,north_america,oceania,russia}/ -type f ! -name "*\.dpkg-old" ! -name "*\.dpkg-new" ! -name "*~"))
# Choose default mirror per default
- MIRRORS=("$(get_mirror_url "${MIRROR_BASE_DIR}/default")" "$(get_mirror_description "${MIRROR_BASE_DIR}/default")" "on")
+ MIRRORS=("$(get_mirror_url "${MIRROR_BASE_DIR}/default")" "$(get_mirror_description "${MIRROR_BASE_DIR}/default")")
# Special handling of packages.termux.dev mirror to put it on top:
- MIRRORS+=("$(get_mirror_url "${MIRROR_BASE_DIR}/europe/packages.termux.dev")" "$(get_mirror_description "${MIRROR_BASE_DIR}/europe/packages.termux.dev")" "off")
+ MIRRORS+=("$(get_mirror_url "${MIRROR_BASE_DIR}/europe/packages.termux.dev")" "$(get_mirror_description "${MIRROR_BASE_DIR}/europe/packages.termux.dev")")
for mirror in ${mirrors[@]}; do
mirror_url=$(get_mirror_url "$mirror")
if [ "$mirror_url" == "packages.termux.dev" ]; then continue; fi
- MIRRORS+=("$mirror_url" "$(get_mirror_description "$mirror")" "off")
+ MIRRORS+=("$mirror_url" "$(get_mirror_description "$mirror")")
done
local TEMPFILE="$(mktemp @TERMUX_PREFIX@/tmp/mirror.XXXXXX)"
dialog \
--title "termux-change-repo" --clear \
- --radiolist "Which mirror do you want to use? Select with space." 0 0 0 \
+ --menu "Which mirror do you want to use?" 0 0 0 \
"${MIRRORS[@]}" --and-widget \
2> "$TEMPFILE"
retval=$?
@@ -167,11 +168,11 @@ mkdir -p "@TERMUX_PREFIX@/tmp" || exit $?
TEMPFILE="$(mktemp @TERMUX_PREFIX@/tmp/termux-change-repo.XXXXXX)"
MODES=()
-MODES+=("Mirror group" "Rotate between several mirrors (recommended)" "on")
-MODES+=("Single mirror" "Choose a single mirror to use" "off")
+MODES+=("Mirror group" "Rotate between several mirrors (recommended)")
+MODES+=("Single mirror" "Choose a single mirror to use")
dialog \
--title "termux-change-repo" --clear \
- --radiolist "Do you want to choose a mirror group or a single mirror? Select with space." 0 0 0 \
+ --menu "Do you want to choose a mirror group or a single mirror?" 0 0 0 \
"${MODES[@]}" --and-widget \
2> "$TEMPFILE"
retval=$?
diff --git a/scripts/termux-info.in b/scripts/termux-info.in
index d5a8f738..9cfc07fc 100644
--- a/scripts/termux-info.in
+++ b/scripts/termux-info.in
@@ -3,7 +3,7 @@
NO_SET_CLIPBOARD=0
show_usage () {
- echo 'usage: termux-info'
+ echo 'usage: termux-info [--no-set-clipboard]'
echo 'Provides information about Termux, and the current system. Helpful for debugging.'
exit 0
@@ -44,30 +44,33 @@ updates() {
}
repo_subscriptions_apt() {
- local main_sources
- main_sources=$(grep -P '^\s*deb\s' "@TERMUX_PREFIX@/etc/apt/sources.list")
-
- if [ -n "$main_sources" ]; then
- echo "# sources.list"
- echo "$main_sources"
- fi
+ local apt_dir="@TERMUX_PREFIX@/etc/apt"
+
+ local filename source_entry repo_package sources_type
+ for filename in "${apt_dir}"/sources.list{,.d/*}; do
+ [[ -f "$filename" ]] || continue
+ case "$filename" in
+ *.sources) sources_type="deb822";;
+ *.list) sources_type="legacy";;
+ *) continue;; # Not a valid source type, skip
+ esac
+ source_entry="$(<"$filename")"
+ repo_package=$(dpkg -S "$filename" 2>/dev/null | cut -d : -f 1)
+
+ local printf_format=""
+ if [[ -n "$repo_package" ]]; then
+ printf_format="# %s(%s) [%s]\n"
+ else
+ printf_format="# %s%s [%s]\n"
+ fi
- if [ -d "@TERMUX_PREFIX@/etc/apt/sources.list.d" ]; then
- local filename repo_package supl_sources
- while read -r filename; do
- repo_package=$(dpkg -S "$filename" 2>/dev/null | cut -d : -f 1)
- supl_sources=$(grep -P '^\s*deb\s' "$filename")
-
- if [ -n "$supl_sources" ]; then
- if [ -n "$repo_package" ]; then
- echo "# $repo_package (sources.list.d/$(basename "$filename"))"
- else
- echo "# sources.list.d/$(basename "$filename")"
- fi
- echo "$supl_sources"
- fi
- done < <(find "@TERMUX_PREFIX@/etc/apt/sources.list.d" -maxdepth 1 ! -type d)
- fi
+ # shellcheck disable=SC2059
+ printf "${printf_format}" \
+ "${repo_package}" \
+ "${filename/$apt_dir\/}" \
+ "${sources_type}"
+ echo "$source_entry"
+ done
}
repo_subscriptions_pacman() {
@@ -86,6 +89,7 @@ repo_subscriptions_pacman() {
}
# Setup TERMUX_APP_PACKAGE_MANAGER
+# shellcheck source=/dev/null
source "@TERMUX_PREFIX@/bin/termux-setup-package-manager" || exit 1
case "${TERMUX__USER_ID:-}" in ''|*[!0-9]*|0[0-9]*) TERMUX__USER_ID=0;; esac
@@ -96,7 +100,7 @@ output=""
if [ -n "${TERMUX_VERSION:-}" ]; then
# Application version is exported in Termux v0.107 or higher only.
output+="Termux Variables:
-$(compgen -e TERMUX_ | while read v; do echo "${v}=${!v}"; done)
+$(compgen -e TERMUX_ | while read -r v; do echo "${v}=${!v}"; done)
"
else
output+="Termux Variables:
@@ -132,6 +136,10 @@ Device manufacturer:
$(getprop ro.product.manufacturer)
Device model:
$(getprop ro.product.model)
+Supported ABIs:
+SUPPORTED_ABIS: $(getprop ro.product.cpu.abilist)
+SUPPORTED_32_BIT_ABIS: $(getprop ro.product.cpu.abilist32)
+SUPPORTED_64_BIT_ABIS: $(getprop ro.product.cpu.abilist64)
LD Variables:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH
LD_PRELOAD=$LD_PRELOAD"
@@ -144,7 +152,7 @@ if [[ "$sdk_version" =~ ^[0-9]+$ ]] && [ "$sdk_version" -ge "26" ]; then
fi
TERMUX_PLUGINS="$(pm list packages --user "$TERMUX__USER_ID" $show_version_code 2>&1 /dev/null
diff --git a/scripts/termux-reload-settings.in b/scripts/termux-reload-settings.in
index 4e71f8a9..25239a18 100644
--- a/scripts/termux-reload-settings.in
+++ b/scripts/termux-reload-settings.in
@@ -11,4 +11,4 @@ fi
case "${TERMUX__USER_ID:-}" in ''|*[!0-9]*|0[0-9]*) TERMUX__USER_ID=0;; esac
-am broadcast --user "$TERMUX__USER_ID" -a com.termux.app.reload_style com.termux > /dev/null
+am broadcast --user "$TERMUX__USER_ID" -a "@TERMUX_APP_PACKAGE@.app.reload_style" "@TERMUX_APP_PACKAGE@" > /dev/null
diff --git a/scripts/termux-reset.in b/scripts/termux-reset.in
index 6f807a74..aa14b7ce 100644
--- a/scripts/termux-reset.in
+++ b/scripts/termux-reset.in
@@ -2,6 +2,9 @@
unset LD_PRELOAD LD_LIBRARY_PATH
+AM_APK_PATH="@TERMUX_PREFIX@/libexec/termux-am/am.apk"
+AM_APK_TMP_PATH="@TERMUX_CACHE_DIR@/termux-am/am.apk"
+
echo
echo "You are going to reset your Termux installation."
echo
@@ -18,7 +21,7 @@ if ! [[ $CHOICE =~ (Y|y) ]]; then
else
HAS_TERMUX_AM=false
- if [ -f "@TERMUX_PREFIX@/libexec/termux-am/am.apk" ]; then
+ if [ -f "$AM_APK_PATH" ]; then
HAS_TERMUX_AM=true
echo "Preserving package 'termux-am' for later use..."
@@ -26,10 +29,10 @@ else
if [ -d "@TERMUX_CACHE_DIR@" ]; then
/system/bin/rm -rf "@TERMUX_CACHE_DIR@/termux-am"
/system/bin/mkdir -p "@TERMUX_CACHE_DIR@/termux-am"
- /system/bin/cp "@TERMUX_PREFIX@/libexec/termux-am/am.apk" "@TERMUX_CACHE_DIR@/termux-am/am.apk"
+ /system/bin/cp "$AM_APK_PATH" "$AM_APK_TMP_PATH"
# In case copying am.apk failed.
- if [ ! -e "@TERMUX_CACHE_DIR@/termux-am/am.apk" ]; then
+ if [ ! -e "$AM_APK_TMP_PATH" ]; then
HAS_TERMUX_AM=false
fi
fi
@@ -44,7 +47,12 @@ else
echo "Terminating all sessions..."
/system/bin/killall -9 "$SHELL"
else
- export CLASSPATH="@TERMUX_CACHE_DIR@/termux-am/am.apk"
- /system/bin/app_process / com.termux.termuxam.Am stopservice com.termux/.app.TermuxService
+ # - https://github.com/termux/TermuxAm/commit/598a9c06
+ if [ -w "$AM_APK_TMP_PATH" ]; then
+ chmod 0400 "$AM_APK_TMP_PATH"
+ fi
+
+ export CLASSPATH="$AM_APK_TMP_PATH"
+ /system/bin/app_process -Xnoimage-dex2oat / "com.termux.termuxam.Am" stopservice "@TERMUX_APP_PACKAGE@/@TERMUX_APP_PACKAGE@.app.TermuxService"
fi
fi
diff --git a/scripts/termux-restore.in b/scripts/termux-restore.in
index ef2d9607..39efa467 100644
--- a/scripts/termux-restore.in
+++ b/scripts/termux-restore.in
@@ -99,8 +99,7 @@ fi
# Ensure that prefix doesn't contain read-only files.
msg "Fixing read-write access to files where necessary..."
-find "@TERMUX_PREFIX@" -type d -print0 | xargs -0 -r chmod u+rwx
-find "@TERMUX_PREFIX@" -type f -print0 | xargs -0 -r chmod u+rw
+find "@TERMUX_PREFIX@" -type d,f -print0 | xargs -0 -r chmod u+rwX
# --recursive-unlink is added intentionally to delete all orphan/extra files
# in $PREFIX. It must be restored to a clean state as in backup tarball.
diff --git a/scripts/termux-setup-storage.in b/scripts/termux-setup-storage.in
index c6212345..51961abb 100644
--- a/scripts/termux-setup-storage.in
+++ b/scripts/termux-setup-storage.in
@@ -27,5 +27,6 @@ fi
case "${TERMUX__USER_ID:-}" in ''|*[!0-9]*|0[0-9]*) TERMUX__USER_ID=0;; esac
am broadcast --user "$TERMUX__USER_ID" \
- --es com.termux.app.reload_style storage \
- -a com.termux.app.reload_style com.termux > /dev/null
+ -a "@TERMUX_APP_PACKAGE@.app.reload_style" \
+ --es "@TERMUX_APP_PACKAGE@.app.reload_style" "storage" \
+ "@TERMUX_APP_PACKAGE@" > /dev/null
diff --git a/scripts/termux-wake-lock.in b/scripts/termux-wake-lock.in
index ba4b8996..088f55a3 100644
--- a/scripts/termux-wake-lock.in
+++ b/scripts/termux-wake-lock.in
@@ -10,6 +10,6 @@ case "${TERMUX__USER_ID:-}" in ''|*[!0-9]*|0[0-9]*) TERMUX__USER_ID=0;; esac
am startservice \
--user "$TERMUX__USER_ID" \
- -a com.termux.service_wake_lock \
- com.termux/com.termux.app.TermuxService \
+ -a "@TERMUX_APP_PACKAGE@.service_wake_lock" \
+ "@TERMUX_APP_PACKAGE@/@TERMUX_APP_PACKAGE@.app.TermuxService" \
> /dev/null
diff --git a/scripts/termux-wake-unlock.in b/scripts/termux-wake-unlock.in
index a4b1f57a..ca2ac6b7 100644
--- a/scripts/termux-wake-unlock.in
+++ b/scripts/termux-wake-unlock.in
@@ -10,6 +10,6 @@ case "${TERMUX__USER_ID:-}" in ''|*[!0-9]*|0[0-9]*) TERMUX__USER_ID=0;; esac
am startservice \
--user "$TERMUX__USER_ID" \
- -a com.termux.service_wake_unlock \
- com.termux/com.termux.app.TermuxService \
+ -a "@TERMUX_APP_PACKAGE@.service_wake_unlock" \
+ "@TERMUX_APP_PACKAGE@/@TERMUX_APP_PACKAGE@.app.TermuxService" \
> /dev/null
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 00000000..d2b3d76a
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,23 @@
+# Copyright (C) 2024 Termux
+
+# This file is part of termux-tools.
+
+# termux-tools is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# termux-tools is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with termux-tools. If not, see
+# .
+
+AM_CFLAGS = -Wall -Wextra -pedantic
+
+bin_PROGRAMS = cmd
+
+cmd_SOURCES = cmd.c
diff --git a/src/cmd.c b/src/cmd.c
new file mode 100644
index 00000000..a47aec3d
--- /dev/null
+++ b/src/cmd.c
@@ -0,0 +1,123 @@
+/* cmd.c
+Copyright (C) 2024 5ec1cff
+This file is part of termux-tools.
+termux-tools is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
+termux-tools is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+You should have received a copy of the GNU General Public License
+along with termux-tools. If not, see
+. */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(expression) \
+ (__extension__({ \
+ long int __result; \
+ do \
+ __result = (long int)(expression); \
+ while (__result == -1L && errno == EINTR); \
+ __result; \
+ }))
+#endif
+
+void pump(int in_fd, int out_fd) {
+ char buf[4096];
+ ssize_t sz, t;
+ for (;;) {
+ sz = TEMP_FAILURE_RETRY(read(in_fd, buf, sizeof(buf)));
+ if (sz <= 0) return;
+ while (sz) {
+ t = TEMP_FAILURE_RETRY(write(out_fd, buf, sz));
+ if (t <= 0) return;
+ sz -= t;
+ }
+ }
+}
+
+int p_std_in[2], p_std_out[2], p_std_err[2];
+
+void *pump_stdin(void *ignore) {
+ pump(STDIN_FILENO, p_std_in[1]);
+ close(p_std_in[1]);
+ return NULL;
+}
+
+void *pump_stdout(void *ignore) {
+ pump(p_std_out[0], STDOUT_FILENO);
+ close(p_std_out[0]);
+ return NULL;
+}
+
+void *pump_stderr(void *ignore) {
+ pump(p_std_err[0], STDERR_FILENO);
+ close(p_std_err[0]);
+ return NULL;
+}
+
+void replace_fd(int fd, int target_fd) {
+ if (dup2(fd, target_fd) == -1) err(EXIT_FAILURE, "dup");
+ close(fd);
+ if (fcntl(target_fd, F_SETFD, fcntl(target_fd, F_GETFD) & ~FD_CLOEXEC) == -1)
+ err(EXIT_FAILURE, "replace_fd");
+}
+
+int main(int argc, char **argv) {
+ if (pipe(p_std_in) == -1) err(EXIT_FAILURE, "pipe");
+ if (pipe(p_std_out) == -1) err(EXIT_FAILURE, "pipe");
+ if (pipe(p_std_err) == -1) err(EXIT_FAILURE, "pipe");
+
+ pid_t pid = fork();
+
+ if (pid < 0) {
+ err(EXIT_FAILURE, "fork");
+ } else if (pid > 0) {
+ close(p_std_in[0]);
+ close(p_std_out[1]);
+ close(p_std_err[1]);
+
+ signal(SIGPIPE, SIG_IGN);
+
+ pthread_t t_stdin;
+ pthread_create(&t_stdin, NULL, pump_stdin, NULL);
+ pthread_detach(t_stdin);
+
+ pthread_t t_stdout;
+ pthread_create(&t_stdout, NULL, pump_stdout, NULL);
+
+ pthread_t t_stderr;
+ pthread_create(&t_stderr, NULL, pump_stderr, NULL);
+
+ int status;
+ if (TEMP_FAILURE_RETRY(waitpid(pid, &status, 0)) < 0) err(EXIT_FAILURE, "wait");
+
+ pthread_join(t_stdout, NULL);
+ pthread_join(t_stderr, NULL);
+
+ if (WIFEXITED(status))
+ exit(WEXITSTATUS(status));
+ else
+ exit(EXIT_FAILURE);
+ } else {
+ replace_fd(p_std_in[0], STDIN_FILENO);
+ replace_fd(p_std_out[1], STDOUT_FILENO);
+ replace_fd(p_std_err[1], STDERR_FILENO);
+
+ execv("/system/bin/cmd", argv);
+ err(EXIT_FAILURE, "exec");
+ }
+}
diff --git a/termux.properties b/termux.properties
index 0ae6b7f2..da7b335d 100644
--- a/termux.properties
+++ b/termux.properties
@@ -178,3 +178,13 @@
### ctrl+space (for marking text in emacs) does not work on some devices
# ctrl-space-workaround = true
+
+###############
+# Terminal Margin adjustments
+###############
+
+### Horizontal (left/right) Margin
+# terminal-margin-horizontal=3
+
+### Vertical (top/bottom) Margin
+# terminal-margin-vertical=0