diff --git a/build-package.sh b/build-package.sh index 35c71cb1a0..254f3e3536 100755 --- a/build-package.sh +++ b/build-package.sh @@ -228,9 +228,9 @@ source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_handle_hostbuild.sh" # shellcheck source=scripts/build/termux_step_host_build.sh source "$TERMUX_SCRIPTDIR/scripts/build/termux_step_host_build.sh" -# Setup a standalone Android NDK 25c toolchain. Called from termux_step_setup_toolchain. -# shellcheck source=scripts/build/toolchain/termux_setup_toolchain_25c.sh -source "$TERMUX_SCRIPTDIR/scripts/build/toolchain/termux_setup_toolchain_25c.sh" +# Setup a standalone Android NDK toolchain. Called from termux_step_setup_toolchain. +# shellcheck source=scripts/build/toolchain/termux_setup_toolchain_26b.sh +source "$TERMUX_SCRIPTDIR/scripts/build/toolchain/termux_setup_toolchain_26b.sh" # Setup a standalone Android NDK 23c toolchain. Called from termux_step_setup_toolchain. # shellcheck source=scripts/build/toolchain/termux_setup_toolchain_23c.sh diff --git a/ndk-patches/25c b/ndk-patches/25c deleted file mode 120000 index 4e60d61a01..0000000000 --- a/ndk-patches/25c +++ /dev/null @@ -1 +0,0 @@ -23c \ No newline at end of file diff --git a/ndk-patches/26b/bits-struct_file.h.patch b/ndk-patches/26b/bits-struct_file.h.patch new file mode 100644 index 0000000000..7e5bf09b33 --- /dev/null +++ b/ndk-patches/26b/bits-struct_file.h.patch @@ -0,0 +1,85 @@ +--- ./usr/include/bits/struct_file.h.orig 2019-06-10 09:40:35.872857650 +1000 ++++ ./usr/include/bits/struct_file.h 2019-06-10 09:55:10.890308649 +1000 +@@ -31,14 +31,79 @@ + #include + + __BEGIN_DECLS ++#if defined(__LP64__) ++struct __sbuf { ++ unsigned char* _base; ++ size_t _size; ++}; ++#else ++struct __sbuf { ++ unsigned char *_base; ++ int _size; ++}; ++#endif ++#if defined(__LP64__) ++typedef int64_t _struct_file_off_t; ++#else ++typedef __kernel_off_t _struct_file_off_t; ++#endif ++ + + /** The opaque structure implementing `FILE`. Do not make any assumptions about its content. */ + struct __sFILE { ++ unsigned char *_p; /* current position in (some) buffer */ ++ int _r; /* read space left for getc() */ ++ int _w; /* write space left for putc() */ + #if defined(__LP64__) +- char __private[152]; ++ int _flags; /* flags, below; this FILE is free if 0 */ ++ int _file; /* fileno, if Unix descriptor, else -1 */ + #else +- char __private[84]; ++ short _flags; /* flags, below; this FILE is free if 0 */ ++ short _file; /* fileno, if Unix descriptor, else -1 */ + #endif +-} __attribute__((aligned(sizeof(void*)))); ++ struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ ++ int _lbfsize; /* 0 or -_bf._size, for inline putc */ ++ ++ /* operations */ ++ void *_cookie; /* cookie passed to io functions */ ++ int (*_close)(void *); ++ int (*_read)(void *, char *, int); ++ _struct_file_off_t (*_seek)(void *, _struct_file_off_t, int); ++ int (*_write)(void *, const char *, int); ++ ++ /* extension data, to avoid further ABI breakage */ ++ struct __sbuf _ext; ++ /* data for long sequences of ungetc() */ ++ unsigned char *_up; /* saved _p when _p is doing ungetc data */ ++ int _ur; /* saved _r when _r is counting ungetc data */ ++ ++ /* tricks to meet minimum requirements even when malloc() fails */ ++ unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ ++ unsigned char _nbuf[1]; /* guarantee a getc() buffer */ ++ ++ /* separate buffer for fgetln() when line crosses buffer boundary */ ++ struct __sbuf _lb; /* buffer for fgetln() */ ++ ++ /* Unix stdio files get aligned to block boundaries on fseek() */ ++ int _blksize; /* stat.st_blksize (may be != _bf._size) */ ++ _struct_file_off_t _offset; /* current lseek offset */ ++}; ++#define __SLBF 0x0001 /* line buffered */ ++#define __SNBF 0x0002 /* unbuffered */ ++#define __SRD 0x0004 /* OK to read */ ++#define __SWR 0x0008 /* OK to write */ ++ /* RD and WR are never simultaneously asserted */ ++#define __SRW 0x0010 /* open for reading & writing */ ++#define __SEOF 0x0020 /* found EOF */ ++#define __SERR 0x0040 /* found error */ ++#define __SMBF 0x0080 /* _buf is from malloc */ ++#define __SAPP 0x0100 /* fdopen()ed in append mode */ ++#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ ++#define __SOPT 0x0400 /* do fseek() optimization */ ++#define __SNPT 0x0800 /* do not do fseek() optimization */ ++#define __SOFF 0x1000 /* set iff _offset is in fact correct */ ++#define __SMOD 0x2000 /* true => fgetln modified _p text */ ++#define __SALC 0x4000 /* allocate string space dynamically */ ++#define __SIGN 0x8000 /* ignore this file in _fwalk */ + + __END_DECLS diff --git a/ndk-patches/26b/dirent.h.patch b/ndk-patches/26b/dirent.h.patch new file mode 100644 index 0000000000..5865a94871 --- /dev/null +++ b/ndk-patches/26b/dirent.h.patch @@ -0,0 +1,12 @@ +--- ./usr/include/dirent.h.orig ++++ ./usr/include/dirent.h +@@ -57,6 +57,9 @@ + #define DT_SOCK 12 + #define DT_WHT 14 + ++#define IFTODT(x) ((x)>>12 & 0xF) ++#define DTTOIF(x) ((x)<<12) ++ + #if defined(__LP64__) + #define __DIRENT64_INO_T ino_t + #else diff --git a/ndk-patches/26b/grp.h.patch b/ndk-patches/26b/grp.h.patch new file mode 100644 index 0000000000..5afe4fa725 --- /dev/null +++ b/ndk-patches/26b/grp.h.patch @@ -0,0 +1,28 @@ +--- ./usr/include/grp.h.orig ++++ ./usr/include/grp.h +@@ -50,21 +50,15 @@ + struct group* _Nullable getgrgid(gid_t __gid); + struct group* _Nullable getgrnam(const char* _Nonnull __name); + +-/* Note: Android has thousands and thousands of ids to iterate through. */ +- +-#if __ANDROID_API__ >= 26 +-struct group* _Nullable getgrent(void) __INTRODUCED_IN(26); +- +-void setgrent(void) __INTRODUCED_IN(26); +-void endgrent(void) __INTRODUCED_IN(26); +-#endif /* __ANDROID_API__ >= 26 */ +- +- + #if __ANDROID_API__ >= 24 + int getgrgid_r(gid_t __gid, struct group* __BIONIC_COMPLICATED_NULLNESS __group, char* _Nonnull __buf, size_t __n, struct group* _Nullable * _Nonnull __result) __INTRODUCED_IN(24); + int getgrnam_r(const char* _Nonnull __name, struct group* __BIONIC_COMPLICATED_NULLNESS __group, char* _Nonnull __buf, size_t __n, struct group* _Nullable *_Nonnull __result) __INTRODUCED_IN(24); + #endif /* __ANDROID_API__ >= 24 */ + ++static struct group* _Nullable getgrent(void) { return 0; } ++static void setgrent(void) {} ++static void endgrent(void) {} ++ + int getgrouplist(const char* _Nonnull __user, gid_t __group, gid_t* __BIONIC_COMPLICATED_NULLNESS __groups, int* _Nonnull __group_count); + int initgroups(const char* _Nonnull __user, gid_t __group); + diff --git a/ndk-patches/26b/linux-fcntl.h.patch b/ndk-patches/26b/linux-fcntl.h.patch new file mode 100644 index 0000000000..727c398328 --- /dev/null +++ b/ndk-patches/26b/linux-fcntl.h.patch @@ -0,0 +1,11 @@ +--- ./usr/include/linux/fcntl.h ++++ ./usr/include/linux/fcntl.h +@@ -54,7 +54,7 @@ + #define DN_MULTISHOT 0x80000000 + #define AT_FDCWD - 100 + #define AT_SYMLINK_NOFOLLOW 0x100 +-#define AT_EACCESS 0x200 ++#define AT_EACCESS 0 + #define AT_REMOVEDIR 0x200 + #define AT_SYMLINK_FOLLOW 0x400 + #define AT_NO_AUTOMOUNT 0x800 diff --git a/ndk-patches/26b/paths.h.patch b/ndk-patches/26b/paths.h.patch new file mode 100644 index 0000000000..b5c2684da4 --- /dev/null +++ b/ndk-patches/26b/paths.h.patch @@ -0,0 +1,29 @@ +--- ./usr/include/paths.h.orig 2021-08-16 11:55:04.492150066 +0200 ++++ ./usr/include/paths.h 2021-08-16 11:55:42.498804733 +0200 +@@ -40,14 +40,14 @@ + + #ifndef _PATH_BSHELL + /** Path to the default system shell. Historically the 'B' was to specify the Bourne shell. */ +-#define _PATH_BSHELL "/system/bin/sh" ++#define _PATH_BSHELL "@TERMUX_PREFIX@/bin/sh" + #endif + + /** Path to the system console. */ + #define _PATH_CONSOLE "/dev/console" + + /** Default shell search path. */ +-#define _PATH_DEFPATH "/product/bin:/apex/com.android.runtime/bin:/apex/com.android.art/bin:/system_ext/bin:/system/bin:/system/xbin:/odm/bin:/vendor/bin:/vendor/xbin" ++#define _PATH_DEFPATH "@TERMUX_PREFIX@/bin" + + /** Path to the directory containing device files. */ + #define _PATH_DEV "/dev/" +@@ -63,3 +63,9 @@ + + /** Path to the calling process' tty. */ + #define _PATH_TTY "/dev/tty" ++ ++#define _PATH_STDPATH _PATH_DEFPATH ++#define _PATH_TMP "@TERMUX_PREFIX@/tmp/" ++#define _PATH_VARDB "@TERMUX_PREFIX@/var/db/" ++#define _PATH_VARRUN "@TERMUX_PREFIX@/var/run/" ++#define _PATH_VARTMP "@TERMUX_PREFIX@/var/tmp/" diff --git a/ndk-patches/26b/pwd.h.patch b/ndk-patches/26b/pwd.h.patch new file mode 100644 index 0000000000..b7e360392d --- /dev/null +++ b/ndk-patches/26b/pwd.h.patch @@ -0,0 +1,64 @@ +--- ./usr/include/pwd.h.orig ++++ ./usr/include/pwd.h +@@ -89,13 +89,60 @@ + struct passwd* _Nullable getpwent(void) __INTRODUCED_IN(26); + + void setpwent(void) __INTRODUCED_IN(26); +-void endpwent(void) __INTRODUCED_IN(26); + #endif /* __ANDROID_API__ >= 26 */ + + + int getpwnam_r(const char* _Nonnull __name, struct passwd* _Nonnull __pwd, char* _Nonnull __buf, size_t __n, struct passwd* _Nullable * _Nonnull __result); + int getpwuid_r(uid_t __uid, struct passwd* _Nonnull __pwd, char* _Nonnull __buf, size_t __n, struct passwd* _Nullable * _Nonnull __result); + ++int access(const char* __path, int __mode); ++ ++static void android_setup_pwd(struct passwd* pw) { ++ char const* result = "@TERMUX_PREFIX@/bin/login"; ++ if (result == NULL || access(result, /*X_OK*/1) == -1) { ++ pw->pw_shell = "@TERMUX_PREFIX@/bin/bash"; ++ } else { ++ pw->pw_shell = (char*) result; ++ } ++ pw->pw_dir = "@TERMUX_HOME@"; ++ pw->pw_passwd = "*"; ++#ifdef __LP64__ ++ pw->pw_gecos = ""; /* Avoid NULL field. */ ++#endif ++} ++ ++static struct passwd* android_polyfill_getpwuid(uid_t t) { ++ struct passwd* pw = getpwuid(t); ++ if (pw == NULL) return NULL; ++ android_setup_pwd(pw); ++ return pw; ++} ++ ++static struct passwd* android_polyfill_getpwnam(const char* name) { ++ struct passwd* pw = getpwnam(name); ++ if (pw == NULL) return NULL; ++ android_setup_pwd(pw); ++ return pw; ++} ++ ++static int android_polyfill_getpwuid_r(uid_t uid, ++ struct passwd *pwd, ++ char *buffer, ++ size_t bufsize, ++ struct passwd **result) { ++ int ret = getpwuid_r(uid, pwd, buffer, bufsize, result); ++ if (ret != 0) return ret; ++ android_setup_pwd(pwd); ++ return 0; ++} ++ ++#define getpwnam android_polyfill_getpwnam ++#define getpwuid android_polyfill_getpwuid ++#define getpwuid_r android_polyfill_getpwuid_r ++static void endpwent(void) { /* Do nothing. */ } ++ ++ ++ + __END_DECLS + + #endif diff --git a/ndk-patches/26b/redefine-TCSAFLUSH.patch b/ndk-patches/26b/redefine-TCSAFLUSH.patch new file mode 100644 index 0000000000..c063a89586 --- /dev/null +++ b/ndk-patches/26b/redefine-TCSAFLUSH.patch @@ -0,0 +1,21 @@ +diff -u -r /home/builder/lib/android-ndk/sysroot/usr/include/asm-generic/termbits.h ./usr/include/asm-generic/termbits.h +--- /home/builder/lib/android-ndk/sysroot/usr/include/asm-generic/termbits.h 2018-09-10 17:37:50.000000000 +0000 ++++ ./usr/include/asm-generic/termbits.h 2019-01-16 04:54:01.117253378 +0000 +@@ -190,5 +190,6 @@ + #define TCIOFLUSH 2 + #define TCSANOW 0 + #define TCSADRAIN 1 +-#define TCSAFLUSH 2 ++/* TCSAFLUSH is patched to be TCSANOW in Termux to work around Android SELinux rule */ ++#define TCSAFLUSH 0 + #endif +--- ./usr/include/bits/termios_inlines.h.orig 2021-08-16 17:05:16.001067630 +0200 ++++ ./usr/include/bits/termios_inlines.h 2021-08-16 17:05:05.851074187 +0200 +@@ -117,7 +117,6 @@ + switch (optional_actions) { + case TCSANOW: cmd = TCSETS; break; + case TCSADRAIN: cmd = TCSETSW; break; +- case TCSAFLUSH: cmd = TCSETSF; break; + default: errno = EINVAL; return -1; + } + return ioctl(fd, cmd, s); diff --git a/ndk-patches/26b/semaphore.h.patch b/ndk-patches/26b/semaphore.h.patch new file mode 100644 index 0000000000..4e02017a71 --- /dev/null +++ b/ndk-patches/26b/semaphore.h.patch @@ -0,0 +1,18 @@ +--- ./usr/include/semaphore.h.orig ++++ ./usr/include/semaphore.h +@@ -71,9 +71,14 @@ + int sem_trywait(sem_t* _Nonnull __sem); + int sem_wait(sem_t* _Nonnull __sem); + +-/* These aren't actually implemented. */ ++#undef sem_open ++#define sem_open libandroid_sem_open + sem_t* _Nullable sem_open(const char* _Nonnull __name, int _flags, ...); ++#undef sem_close ++#define sem_close libandroid_sem_close + int sem_close(sem_t* _Nonnull __sem); ++#undef sem_unlink ++#define sem_unlink libandroid_sem_unlink + int sem_unlink(const char* _Nonnull __name); + + __END_DECLS diff --git a/ndk-patches/26b/stdio.h.patch b/ndk-patches/26b/stdio.h.patch new file mode 100644 index 0000000000..3b8e976dbf --- /dev/null +++ b/ndk-patches/26b/stdio.h.patch @@ -0,0 +1,80 @@ +--- ./usr/include/stdio.h.orig 2021-08-16 11:48:44.308954400 +0200 ++++ ./usr/include/stdio.h 2021-08-16 11:50:00.438924014 +0200 +@@ -44,6 +44,9 @@ + #include + #include + ++#include /* For strcpy(3) used by ctermid() */ ++#include /* For O_RDWR and other O_* constants */ ++ + #include + + #if __ANDROID_API__ < 24 +@@ -165,7 +166,7 @@ + __printflike(2, 0) __warnattr_strict("vsprintf is often misused; please use vsnprintf"); + char* _Nullable tmpnam(char* _Nullable __s) + __warnattr("tmpnam is unsafe, use mkstemp or tmpfile instead"); +-#define P_tmpdir "/tmp/" /* deprecated */ ++#define P_tmpdir "@TERMUX_PREFIX@/tmp/" /* deprecated */ + char* _Nullable tempnam(const char* _Nullable __dir, const char* _Nullable __prefix) + __warnattr("tempnam is unsafe, use mkstemp or tmpfile instead"); + +@@ -289,8 +290,6 @@ + FILE* _Nullable freopen64(const char* _Nullable __path, const char* _Nonnull __mode, FILE* _Nonnull __fp) __INTRODUCED_IN(24); + #endif /* __ANDROID_API__ >= 24 */ + +-FILE* _Nullable tmpfile(void); +- + #if __ANDROID_API__ >= 24 + FILE* _Nullable tmpfile64(void) __INTRODUCED_IN(24); + #endif /* __ANDROID_API__ >= 24 */ +@@ -304,10 +303,15 @@ + + #define L_ctermid 1024 /* size for ctermid() */ + +-#if __ANDROID_API__ >= 26 +-char* _Nonnull ctermid(char* _Nullable __buf) __INTRODUCED_IN(26); +-#endif /* __ANDROID_API__ >= 26 */ ++/* Needed by gnulibs freading(). */ ++#define __sferror(p) (((p)->_flags & __SERR) != 0) + ++/* Used by perl, fish, and others. */ ++static __inline__ char* _Nonnull ctermid(char* _Nullable s) { ++ if (s == 0) return (char*) "/dev/tty"; ++ strcpy(s, "/dev/tty"); ++ return s; ++} + + FILE* fdopen(int __fd, const char* __mode); + int fileno(FILE* __fp); +@@ -376,6 +380,30 @@ + #include + #endif + ++int open(const char*, int, ...); ++extern pid_t getpid(); ++extern int unlink(const char*); ++void free(void* p); ++uint32_t arc4random(void); ++static __inline__ FILE* _Nullable tmpfile() { ++ int p = getpid(); ++ char* path; ++ int i; ++ for (i = 0; i < 100; i++) { ++ unsigned int r = arc4random(); ++ if (asprintf(&path, "@TERMUX_PREFIX@/tmp/tmpfile.%d-%u", p, r) == -1) return NULL; ++ int fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE, 0600); ++ if (fd >= 0) { ++ FILE* result = fdopen(fd, "w+"); ++ unlink(path); ++ free(path); ++ return result; ++ } ++ free(path); ++ } ++ return NULL; ++} ++ + __END_DECLS + + #endif diff --git a/ndk-patches/26b/stdlib.h.patch b/ndk-patches/26b/stdlib.h.patch new file mode 100644 index 0000000000..e00a71d814 --- /dev/null +++ b/ndk-patches/26b/stdlib.h.patch @@ -0,0 +1,24 @@ +--- ./usr/include/stdlib.h.orig 2021-08-16 11:50:47.432239182 +0200 ++++ ./usr/include/stdlib.h 2021-08-16 11:51:31.102222894 +0200 +@@ -33,6 +33,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -223,12 +224,8 @@ + + size_t wcstombs(char* _Nullable __dst, const wchar_t* _Nullable __src, size_t __n) __INTRODUCED_IN_NO_GUARD_FOR_NDK(21); + + +-#if __ANDROID_API__ >= 21 +-size_t __ctype_get_mb_cur_max(void) __INTRODUCED_IN(21); +-#endif /* __ANDROID_API__ >= 21 */ +- +-#define MB_CUR_MAX __ctype_get_mb_cur_max() ++#define MB_CUR_MAX 4 + + #if defined(__BIONIC_INCLUDE_FORTIFY_HEADERS) + #include diff --git a/ndk-patches/26b/sys-cdefs.h.patch b/ndk-patches/26b/sys-cdefs.h.patch new file mode 100644 index 0000000000..35508ca444 --- /dev/null +++ b/ndk-patches/26b/sys-cdefs.h.patch @@ -0,0 +1,9 @@ +--- ./usr/include/sys/cdefs.h.orig 2021-08-16 11:52:08.128876161 +0200 ++++ ./usr/include/sys/cdefs.h 2021-08-16 11:52:08.555542676 +0200 +@@ -372,3 +372,6 @@ + #if __has_include() + #include + #endif ++#define __TERMUX__ 1 ++#define __TERMUX_PREFIX__ "@TERMUX_PREFIX@" ++ diff --git a/ndk-patches/26b/syslog.patch b/ndk-patches/26b/syslog.patch new file mode 100644 index 0000000000..f29784aeda --- /dev/null +++ b/ndk-patches/26b/syslog.patch @@ -0,0 +1,26 @@ +diff -uNr sysroot.orig/usr/include/syslog.h sysroot/usr/include/syslog.h +--- sysroot.orig/usr/include/syslog.h 2019-02-12 16:12:24.000000000 +0000 ++++ sysroot/usr/include/syslog.h 2019-03-20 13:19:44.315965728 +0000 +@@ -158,4 +158,22 @@ + */ + void vsyslog(int __priority, const char* __fmt, va_list __args) __printflike(2, 0); + ++static __inline__ void android_polyfill_syslog_r(int syslog_priority, void* d, const char* format, ...) ++{ ++ (void) d; ++ va_list myargs; ++ va_start(myargs, format); ++ vsyslog(syslog_priority, format, myargs); ++ va_end(myargs); ++} ++ ++static __inline__ void android_polyfill_vsyslog_r(int syslog_priority, void* d, const char* fmt, va_list ap) ++{ ++ (void) d; ++ vsyslog(syslog_priority, fmt, ap); ++} ++ ++#define syslog_r android_polyfill_syslog_r ++#define vsyslog_r android_polyfill_vsyslog_r ++ + __END_DECLS diff --git a/ndk-patches/26b/unistd.h.patch b/ndk-patches/26b/unistd.h.patch new file mode 100644 index 0000000000..37ea0a2fe2 --- /dev/null +++ b/ndk-patches/26b/unistd.h.patch @@ -0,0 +1,77 @@ +--- ./usr/include/unistd.h.orig 2021-08-16 11:52:08.095542840 +0200 ++++ ./usr/include/unistd.h 2021-08-16 11:52:08.565542673 +0200 +@@ -375,6 +375,74 @@ + #undef _UNISTD_H_ + #endif + ++#if !defined GETPASS_H && !defined getpass && !defined HAVE_GETPASS && !defined HAS_GETPASS && !defined NO_INLINE_GETPASS ++#define GETPASS_H 1 ++#define HAVE_GETPASS 1 ++#define HAS_GETPASS 1 ++#define PASSWORDLEN 512 ++ ++static __inline__ char* getpass(const char* prompt) { ++ // termios struct as in asm-generic/termbits.h ++ struct _termios { ++ unsigned int c_iflag; /* input mode flags */ ++ unsigned int c_oflag; /* output mode flags */ ++ unsigned int c_cflag; /* control mode flags */ ++ unsigned int c_lflag; /* local mode flags */ ++ unsigned char c_line; /* line discipline */ ++ unsigned char c_cc[19/* NCCS */]; /* control characters */ ++ }; ++ ++ struct _termios term_old, term_new; ++ static char password[513] = { 0 }; /* 512 1-byte charactes and '0' */ ++ int len = 0, tty_changed = 0; ++ ++ // print prompt ++ while (*prompt) { ++ write(1, prompt, 1); ++ prompt++; ++ } ++ ++ // try to disable echoing on terminal ++ if (ioctl(0, 0x5401 /* TCGETS */, &term_old) == 0) { ++ term_new = term_old; ++ term_new.c_lflag &= ~0000010;/* ~ECHO */ ++ ++ if (ioctl(0, 0x5402+0 /* TCSETS+TCSANOW */, &term_new) == 0) { ++ tty_changed = 1; ++ } else { ++ tty_changed = 0; ++ } ++ } ++ ++ // read password ++ char chr; ++ while (read(0, &chr, sizeof(char)) > 0) { ++ if (chr == '\r' || chr == '\n' || chr == 0) { ++ break; ++ } ++ ++ if (len == sizeof(password)-1) { ++ // we should consume all entered characters even ++ // if maximal input length reached ++ continue; ++ } else { ++ password[len++] = chr; ++ } ++ } ++ password[len] = 0; ++ ++ // restore terminal to previous state if needed ++ if (tty_changed) { ++ ioctl(0, 0x5402+0 /* TCSETS+TCSANOW */, &term_old); ++ } ++ ++ // force new line ++ write(1, "\n", 1); ++ ++ return password; ++} ++#endif ++ + __END_DECLS + + #include diff --git a/ndk-patches/26b/utmp.h.patch b/ndk-patches/26b/utmp.h.patch new file mode 100644 index 0000000000..51932dd25f --- /dev/null +++ b/ndk-patches/26b/utmp.h.patch @@ -0,0 +1,15 @@ +--- ./usr/include/utmp.h.orig 2021-08-16 11:52:08.095542840 +0200 ++++ ./usr/include/utmp.h 2021-08-16 11:52:08.565542673 +0200 +@@ -37,9 +37,9 @@ + #include + #include + +-#define _PATH_UTMP "/var/run/utmp" +-#define _PATH_WTMP "/var/log/wtmp" +-#define _PATH_LASTLOG "/var/log/lastlog" ++#define _PATH_UTMP "@TERMUX_PREFIX@/var/run/utmp" ++#define _PATH_WTMP "@TERMUX_PREFIX@/var/log/wtmp" ++#define _PATH_LASTLOG "@TERMUX_PREFIX@/var/log/lastlog" + + #ifdef __LP64__ + #define UT_NAMESIZE 32 diff --git a/scripts/build/termux_step_setup_toolchain.sh b/scripts/build/termux_step_setup_toolchain.sh index f36c709a77..ca3b4c9573 100644 --- a/scripts/build/termux_step_setup_toolchain.sh +++ b/scripts/build/termux_step_setup_toolchain.sh @@ -6,9 +6,9 @@ termux_step_setup_toolchain() { # Bump TERMUX_STANDALONE_TOOLCHAIN if a change is made in # toolchain setup to ensure that everyone gets an updated # toolchain - if [ "${TERMUX_NDK_VERSION}" = 25c ]; then - TERMUX_STANDALONE_TOOLCHAIN+="-v2" - termux_setup_toolchain_25c + if [ "${TERMUX_NDK_VERSION}" = "26b" ]; then + TERMUX_STANDALONE_TOOLCHAIN+="-v0" + termux_setup_toolchain_26b elif [ "${TERMUX_NDK_VERSION}" = 23c ]; then TERMUX_STANDALONE_TOOLCHAIN+="-v5" termux_setup_toolchain_23c diff --git a/scripts/build/toolchain/termux_setup_toolchain_25c.sh b/scripts/build/toolchain/termux_setup_toolchain_26b.sh similarity index 96% rename from scripts/build/toolchain/termux_setup_toolchain_25c.sh rename to scripts/build/toolchain/termux_setup_toolchain_26b.sh index 4191953d49..3e775cabde 100644 --- a/scripts/build/toolchain/termux_setup_toolchain_25c.sh +++ b/scripts/build/toolchain/termux_setup_toolchain_26b.sh @@ -1,4 +1,4 @@ -termux_setup_toolchain_25c() { +termux_setup_toolchain_26b() { export CFLAGS="" export CPPFLAGS="" export LDFLAGS="-L${TERMUX_PREFIX}/lib" @@ -171,8 +171,8 @@ termux_setup_toolchain_25c() { $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-clang.no-16-porting cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-clang.no-16-porting \ $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-clang.16-porting - sed -i 's/"\$@"/--start-no-unused-arguments -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-function-pointer-types --end-no-unused-arguments \0/g' \ - $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-clang.16-porting + sed -i 's/"\$@"/--start-no-unused-arguments -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=int-conversion -Wno-error=incompatible-function-pointer-types --end-no-unused-arguments \0/g' \ + $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-clang.no-16-porting if [ "$TERMUX_PKG_ENABLE_CLANG16_PORTING" = "true" ]; then cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-clang.16-porting \ $_TERMUX_TOOLCHAIN_TMPDIR/bin/$HOST_PLAT-clang diff --git a/scripts/properties.sh b/scripts/properties.sh index 29500ae46f..4341478c24 100644 --- a/scripts/properties.sh +++ b/scripts/properties.sh @@ -9,12 +9,12 @@ TERMUX_ANDROID_BUILD_TOOLS_VERSION=33.0.1 # change TERMUX_PKG_VERSION (and remove TERMUX_PKG_REVISION if necessary) in: # apksigner, d8 # and trigger rebuild of them -: "${TERMUX_NDK_VERSION_NUM:="25"}" -: "${TERMUX_NDK_REVISION:="c"}" +: "${TERMUX_NDK_VERSION_NUM:="26"}" +: "${TERMUX_NDK_REVISION:="b"}" TERMUX_NDK_VERSION=$TERMUX_NDK_VERSION_NUM$TERMUX_NDK_REVISION # when changing the above: # update version and hashsum in packages -# libc++, ndk-multilib, ndk-sysroot, vulkan-loader-android +# libandroid-stub, libc++, ndk-multilib, ndk-sysroot, vulkan-loader-android # and update SHA256 sums in scripts/setup-android-sdk.sh # check all packages build and run correctly and bump if needed diff --git a/scripts/setup-android-sdk.sh b/scripts/setup-android-sdk.sh index 7bb6359971..691d24906d 100755 --- a/scripts/setup-android-sdk.sh +++ b/scripts/setup-android-sdk.sh @@ -10,9 +10,9 @@ set -e -u ANDROID_SDK_FILE=commandlinetools-linux-${TERMUX_SDK_REVISION}_latest.zip ANDROID_SDK_SHA256=0bebf59339eaa534f4217f8aa0972d14dc49e7207be225511073c661ae01da0a -if [ "$TERMUX_NDK_VERSION" = 25c ]; then +if [ "$TERMUX_NDK_VERSION" = "26b" ]; then ANDROID_NDK_FILE=android-ndk-r${TERMUX_NDK_VERSION}-linux.zip - ANDROID_NDK_SHA256=769ee342ea75f80619d985c2da990c48b3d8eaf45f48783a2d48870d04b46108 + ANDROID_NDK_SHA256=ad73c0370f0b0a87d1671ed2fd5a9ac9acfd1eb5c43a7fbfbd330f85d19dd632 elif [ "$TERMUX_NDK_VERSION" = 23c ]; then ANDROID_NDK_FILE=android-ndk-r${TERMUX_NDK_VERSION}-linux.zip ANDROID_NDK_SHA256=6ce94604b77d28113ecd588d425363624a5228d9662450c48d2e4053f8039242