ndk_patches: Define _POSIX2_VERSION to 200809
authorFredrik Fornwall <fredrik@fornwall.net>
Sat, 7 Jan 2017 06:45:46 +0000 (01:45 -0500)
committerFredrik Fornwall <fredrik@fornwall.net>
Sat, 7 Jan 2017 06:45:46 +0000 (01:45 -0500)
coreutils looks at _POSIX2_VERSION and enables broken obsolete
behaviour if not set.

Fixes https://github.com/termux/termux-app/issues/232.

build-package.sh
ndk_patches/sys-limits.h.patch [new file with mode: 0644]
packages/coreutils/build.sh
packages/coreutils/tests/tails-c-flag.sh [new file with mode: 0644]

index 6dc2cf9..93c8bdc 100755 (executable)
@@ -187,7 +187,7 @@ termux_step_setup_variables() {
        TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_TOPDIR/_lib/toolchain-${TERMUX_ARCH}-ndk${TERMUX_NDK_VERSION}-api${TERMUX_API_LEVEL}"
        # Bump the below version if a change is made in toolchain setup to ensure
        # that everyone gets an updated toolchain:
-       TERMUX_STANDALONE_TOOLCHAIN+="-v3"
+       TERMUX_STANDALONE_TOOLCHAIN+="-v4"
 
        export TERMUX_TAR="tar"
        export TERMUX_TOUCH="touch"
diff --git a/ndk_patches/sys-limits.h.patch b/ndk_patches/sys-limits.h.patch
new file mode 100644 (file)
index 0000000..3a2de49
--- /dev/null
@@ -0,0 +1,12 @@
+diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm64/usr/include/sys/limits.h ./usr/include/sys/limits.h
+--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm64/usr/include/sys/limits.h    2016-09-29 14:42:26.000000000 -0400
++++ ./usr/include/sys/limits.h 2017-01-07 01:23:19.004048281 -0500
+@@ -116,7 +116,7 @@
+ /* Bionic-specific definitions */
+ #define  _POSIX_VERSION             200112L   /* Posix C language bindings version */
+-#define  _POSIX2_VERSION            -1        /* we don't support Posix command-line tools */
++#define  _POSIX2_VERSION            200809    /* Termux change to avoid coreutils obsolete breakage */
+ #define  _POSIX2_C_VERSION          _POSIX_VERSION
+ #define  _XOPEN_VERSION             500       /* by Posix definition */
+ #define  _XOPEN_XCU_VERSION         -1        /* we don't support command-line utilities */
index f392a18..1977e90 100755 (executable)
@@ -1,6 +1,7 @@
 TERMUX_PKG_HOMEPAGE=https://www.gnu.org/software/coreutils/
 TERMUX_PKG_DESCRIPTION="Basic file, shell and text manipulation utilities from the GNU project"
 TERMUX_PKG_VERSION=8.26
+TERMUX_PKG_BUILD_REVISION=1
 TERMUX_PKG_SRCURL=https://mirrors.kernel.org/gnu/coreutils/coreutils-${TERMUX_PKG_VERSION}.tar.xz
 TERMUX_PKG_SHA256=155e94d748f8e2bc327c66e0cbebdb8d6ab265d2f37c3c928f7bf6c3beba9a8e
 TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_mkfifo=yes gl_cv_host_operating_system=Android --without-gmp --enable-single-binary=symlinks ac_cv_func_endpwent=no"
diff --git a/packages/coreutils/tests/tails-c-flag.sh b/packages/coreutils/tests/tails-c-flag.sh
new file mode 100644 (file)
index 0000000..1993d1a
--- /dev/null
@@ -0,0 +1,7 @@
+set -e -u
+
+RESULT=$(echo -n 123456 | tail -c 3)
+if [ "$RESULT" != 456 ]; then
+       echo "Test failed - expectd 456, got $RESULT"
+       exit 1
+fi