Switching to a more "soft" solution which will be focused on apt only.
Apt will now send an application package name (com.termux) and prefix
(/data/data/com.termux/files/usr) as part of user-agent string. That
will allow to distinguish real Termux users from parties which download
our packages and binary-patching them for the custom prefix.
Note that this will disable user's possibility to set custom User-Agent
for apt.
In issue https://github.com/termux/termux-packages/issues/6160 I have found
that community repo "its-pointless.github.io" specifies us as maintainer
for its packages. This is NOT TRUE and potentially misleads people using
these packages.
Now TERMUX_PKG_MAINTAINER will contain a default value which is neutral
and not specify maintainer. So all packages now have to override it to
the correct value.
[skip ci]
%ci:no-build
Add a small stub which verifies whether /data/data/com.termux/files/usr is readable
into few important packages such like Bash or APT. If this check fails, e.g.
in case if binary was executed in program with different package name (non-Termux),
program will print warning and exit with error status immediately.
This should prevent use of prebuilt packages by third-party applications.
NOTE: for now it uses /data/data/com.termux/files/usr in reversed order to
prevent automatic "blind" patching with sed. Will replace with randomized
XOR-based variant in case if that measure won't be enough.
Variables
TERMUX_PKG_PLATFORM_INDEPENDENT
TERMUX_DEBUG
TERMUX_PKG_HAS_DEBUG
TERMUX_PKG_ESSENTIAL
TERMUX_SUBPKG_ESSENTIAL
TERMUX_PKG_NO_STATICSPLIT
TERMUX_PKG_BUILD_IN_SRC
TERMUX_PKG_FORCE_CMAKE
TERMUX_PKG_HOSTBUILD
should not accept arbitrary values for marking them "enabled". Instead
they should accept boolean values which makes them easier to handle and
also makes their meaning clear.
build-package.sh should make decision based on variable's value but not on
whether it is set or empty.
%ci:no-build
It can delete utility 'ln' in the process of installation:
make install-exec-hook
make[4]: Entering directory '/data/data/com.termux/files/home/.termux-build/coreutils/build'
/bin/sh: 12: ln: not found
The platform headers has the following macro:
#define MB_CUR_MAX __ctype_get_mb_cur_max()
where __ctype_get_mb_cur_max() tries to handle UTF-8 encodings.
However, even in Android 7.0 setlocale(LC_ALL, ""), which many
programs do at startup, doesn't work in that it sets the locale
as non-utf8:
https://android.googlesource.com/platform/bionic/+/nougat-release/libc/bionic/locale.cpp#139
So we just always consider us being in an utf-8 locale.
Also rebuild coreutils to fix#1136.
32-bit android uses 32-bit off_t by default. When building with
-D_FILE_OFFSET_BITS=64 with unified headers off_t are promoted
to 64-bit, but there are bugs in the toolchain and spotty support
for it in the platform (not all functions are available until
android-24, and the platform zlib is compiled with 32-bit off_t).
Also, unless every library&program is rebuilt with 64-bit off_t,
including user-built ones, we risk a mismatch between programs and
libraries which can cause serious (but sometimes subtle) runtime
failures.
As -D_FILE_OFFSET_BITS=64 is not that important for most users
(with mariadb requiring it as an exception), we drop the support
for now by patching it away in <sys/cdefs.h>.