From 573da57f1e100671f8b228df43c70708e6daba74 Mon Sep 17 00:00:00 2001 From: Leonid Plyushch Date: Wed, 27 Feb 2019 15:30:40 +0200 Subject: [PATCH] new package: chroot Actually it just a "standalone" chroot utility from the coreutils. --- root-packages/chroot/build.sh | 45 +++++++++++++++++++++ root-packages/chroot/configure.patch | 25 ++++++++++++ root-packages/chroot/lib-stdio-impl.h.patch | 12 ++++++ root-packages/chroot/mktemp.patch | 21 ++++++++++ root-packages/chroot/nohup.c.patch | 17 ++++++++ root-packages/chroot/pwd.c.patch | 12 ++++++ root-packages/chroot/src-ls.c.patch | 13 ++++++ 7 files changed, 145 insertions(+) create mode 100644 root-packages/chroot/build.sh create mode 100644 root-packages/chroot/configure.patch create mode 100644 root-packages/chroot/lib-stdio-impl.h.patch create mode 100644 root-packages/chroot/mktemp.patch create mode 100644 root-packages/chroot/nohup.c.patch create mode 100644 root-packages/chroot/pwd.c.patch create mode 100644 root-packages/chroot/src-ls.c.patch diff --git a/root-packages/chroot/build.sh b/root-packages/chroot/build.sh new file mode 100644 index 000000000..22b8fcda9 --- /dev/null +++ b/root-packages/chroot/build.sh @@ -0,0 +1,45 @@ +TERMUX_PKG_HOMEPAGE=https://www.gnu.org/software/coreutils/ +TERMUX_PKG_DESCRIPTION="Chroot utility from the Coreutils" +TERMUX_PKG_LICENSE="GPL-3.0" +TERMUX_PKG_VERSION=8.30 +TERMUX_PKG_SHA256=e831b3a86091496cdba720411f9748de81507798f6130adeaef872d206e1b057 +TERMUX_PKG_SRCURL=https://mirrors.kernel.org/gnu/coreutils/coreutils-${TERMUX_PKG_VERSION}.tar.xz + +TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" +gl_cv_host_operating_system=Android +--disable-xattr +--without-gmp +" + +termux_step_pre_configure() { + CPPFLAGS+=" -DDEFAULT_TMPDIR=\\\"$TERMUX_PREFIX/tmp\\\"" +} + +termux_step_make() { + # deps for chroot. + make lib/configmake.h + make src/version.h + make lib/fcntl.h + make lib/time.h + make lib/sys/stat.h + make lib/selinux/context.h + make lib/selinux/selinux.h + make lib/unitypes.h + make lib/unistr.h + make lib/uniwidth.h + make lib/stdint.h + make lib/stdio.h + make lib/fnmatch.h + make lib/getopt.h + make lib/getopt-cdefs.h + + # build standalone chroot utility. + make src/chroot +} + +termux_step_make_install() { + install -Dm700 $TERMUX_PKG_BUILDDIR/src/chroot \ + $TERMUX_PREFIX/bin/ + install -Dm600 $TERMUX_PKG_SRCDIR/man/chroot.1 \ + $TERMUX_PREFIX/share/man/man1/ +} diff --git a/root-packages/chroot/configure.patch b/root-packages/chroot/configure.patch new file mode 100644 index 000000000..545cf57f3 --- /dev/null +++ b/root-packages/chroot/configure.patch @@ -0,0 +1,25 @@ +diff -r -u ../coreutils-8.22/configure ./configure +--- ../coreutils-8.22/configure 2013-12-13 16:05:30.000000000 +0100 ++++ ./configure 2014-02-12 18:21:28.000000000 +0100 +@@ -39537,7 +39537,7 @@ + + + # Determine how to get the list of mounted file systems. +-ac_list_mounted_fs= ++ac_list_mounted_fs=found + + # If the getmntent function is available but not in the standard library, + # make sure LIBS contains the appropriate -l option. +@@ -40077,12 +40077,6 @@ + esac + fi + +-if test -z "$ac_list_mounted_fs"; then +- as_fn_error $? "could not determine how to read list of mounted file systems" "$LINENO" 5 +- # FIXME -- no need to abort building the whole package +- # Can't build mountlist.c or anything that needs its functions +-fi +- + if test $ac_list_mounted_fs = found; then : + gl_cv_list_mounted_fs=yes + else diff --git a/root-packages/chroot/lib-stdio-impl.h.patch b/root-packages/chroot/lib-stdio-impl.h.patch new file mode 100644 index 000000000..d3bfbd53a --- /dev/null +++ b/root-packages/chroot/lib-stdio-impl.h.patch @@ -0,0 +1,12 @@ +diff -u -r ../coreutils-8.30/lib/stdio-impl.h ./lib/stdio-impl.h +--- ../coreutils-8.30/lib/stdio-impl.h 2018-06-24 06:52:06.000000000 +0200 ++++ ./lib/stdio-impl.h 2018-07-03 11:05:27.353619181 +0200 +@@ -60,7 +60,7 @@ + # define _flags pub._flags + # define _r pub._r + # define _w pub._w +-# elif defined __ANDROID__ /* Android */ ++# elif defined __ANDROID_BUT_THIS_IS_BROKEN__ /* Android */ + /* Up to this commit from 2015-10-12 + + the innards of FILE were public, and fp_ub could be defined like for OpenBSD, diff --git a/root-packages/chroot/mktemp.patch b/root-packages/chroot/mktemp.patch new file mode 100644 index 000000000..58cdbd4c7 --- /dev/null +++ b/root-packages/chroot/mktemp.patch @@ -0,0 +1,21 @@ +diff -u -r ../coreutils-8.22/src/mktemp.c ./src/mktemp.c +--- ../coreutils-8.22/src/mktemp.c 2013-12-04 15:48:30.000000000 +0100 ++++ ./src/mktemp.c 2014-06-03 11:31:58.351787119 +0200 +@@ -269,7 +269,7 @@ + else if (dest_dir_arg && *dest_dir_arg) + dest_dir = dest_dir_arg; + else +- dest_dir = "/tmp"; ++ dest_dir = "@TERMUX_PREFIX@/tmp"; + + if (last_component (template) != template) + error (EXIT_FAILURE, 0, +@@ -283,7 +283,7 @@ + else + { + char *env = getenv ("TMPDIR"); +- dest_dir = (env && *env ? env : "/tmp"); ++ dest_dir = (env && *env ? env : "@TERMUX_PREFIX@/tmp"); + } + if (IS_ABSOLUTE_FILE_NAME (template)) + error (EXIT_FAILURE, 0, diff --git a/root-packages/chroot/nohup.c.patch b/root-packages/chroot/nohup.c.patch new file mode 100644 index 000000000..b8b7b7b12 --- /dev/null +++ b/root-packages/chroot/nohup.c.patch @@ -0,0 +1,17 @@ +Fix + error: call to '__umask_invalid_mode' declared with + attribute error: umask called with invalid mode +on android-21 + +diff -u -r ../coreutils-8.23/src/nohup.c ./src/nohup.c +--- ../coreutils-8.23/src/nohup.c 2014-07-11 07:00:07.000000000 -0400 ++++ ./src/nohup.c 2014-12-14 15:22:47.939242789 -0500 +@@ -141,7 +141,7 @@ + char const *file = "nohup.out"; + int flags = O_CREAT | O_WRONLY | O_APPEND; + mode_t mode = S_IRUSR | S_IWUSR; +- mode_t umask_value = umask (~mode); ++ mode_t umask_value = umask (0777 & ~mode); + out_fd = (redirecting_stdout + ? fd_reopen (STDOUT_FILENO, file, flags, mode) + : open (file, flags, mode)); diff --git a/root-packages/chroot/pwd.c.patch b/root-packages/chroot/pwd.c.patch new file mode 100644 index 000000000..a1503d170 --- /dev/null +++ b/root-packages/chroot/pwd.c.patch @@ -0,0 +1,12 @@ +diff -u -r ../coreutils-8.23/src/pwd.c ./src/pwd.c +--- ../coreutils-8.23/src/pwd.c 2014-07-13 18:09:52.000000000 -0400 ++++ ./src/pwd.c 2015-05-17 19:58:20.692454980 -0400 +@@ -366,7 +366,7 @@ + if (optind < argc) + error (0, 0, _("ignoring non-option arguments")); + +- if (logical) ++ if (true) /* Termux: Always try logical, to avoid permission denied on /data/data */ + { + wd = logical_getcwd (); + if (wd) diff --git a/root-packages/chroot/src-ls.c.patch b/root-packages/chroot/src-ls.c.patch new file mode 100644 index 000000000..1109184d1 --- /dev/null +++ b/root-packages/chroot/src-ls.c.patch @@ -0,0 +1,13 @@ +diff -u -r ../coreutils-8.26/src/ls.c ./src/ls.c +--- ../coreutils-8.26/src/ls.c 2016-11-22 15:04:32.000000000 -0500 ++++ ./src/ls.c 2016-11-30 20:27:28.910732105 -0500 +@@ -1749,6 +1749,9 @@ + } + } + ++ /* Termux patch: Default to colors if terminal. The --color option may override this. */ ++ print_with_color = isatty(STDOUT_FILENO); ++ + while (true) + { + int oi = -1;