From 218a2062748fbac7f97689d1f7e1f38934adcffe Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Thu, 19 Aug 2021 16:57:02 +0200 Subject: [PATCH] busybox: fix build with ndk r23 Compiler and tool names need to be updated in Makefile. Also fix some patch offsets while we are at it --- packages/busybox/0000-use-clang.patch | 21 ++++++++++++++----- packages/busybox/0004-Makefile.flags.patch | 6 +++--- ...crond.patch => 0006-miscutils-crond.patch} | 0 ...tab.patch => 0007-miscutils-crontab.patch} | 0 ...h => 0008-networking-ftpd-no-chroot.patch} | 7 +++---- ... 0009-networking-httpd-default-port.patch} | 15 +++++++------ ...010-networking-telnetd-default-port.patch} | 0 .../0011-networking-tftp-no-chroot.patch | 15 +++++++++++++ .../0012-networking-tftp-no-chroot.patch | 16 -------------- packages/busybox/build.sh | 2 +- 10 files changed, 45 insertions(+), 37 deletions(-) rename packages/busybox/{0007-miscutils-crond.patch => 0006-miscutils-crond.patch} (100%) rename packages/busybox/{0008-miscutils-crontab.patch => 0007-miscutils-crontab.patch} (100%) rename packages/busybox/{0009-networking-ftpd-no-chroot.patch => 0008-networking-ftpd-no-chroot.patch} (52%) rename packages/busybox/{0010-networking-httpd-default-port.patch => 0009-networking-httpd-default-port.patch} (77%) rename packages/busybox/{0011-networking-telnetd-default-port.patch => 0010-networking-telnetd-default-port.patch} (100%) create mode 100644 packages/busybox/0011-networking-tftp-no-chroot.patch delete mode 100644 packages/busybox/0012-networking-tftp-no-chroot.patch diff --git a/packages/busybox/0000-use-clang.patch b/packages/busybox/0000-use-clang.patch index 8cf9971a5..49f8700b7 100644 --- a/packages/busybox/0000-use-clang.patch +++ b/packages/busybox/0000-use-clang.patch @@ -1,7 +1,6 @@ -diff -uNr busybox-1.31.1/Makefile busybox-1.31.1.mod/Makefile ---- busybox-1.31.1/Makefile 2019-10-25 11:44:52.000000000 +0300 -+++ busybox-1.31.1.mod/Makefile 2019-11-11 22:19:06.004778909 +0200 -@@ -289,7 +289,7 @@ +--- ./Makefile.orig 2021-08-19 16:48:15.223628163 +0200 ++++ ./Makefile 2021-08-19 16:47:29.456942514 +0200 +@@ -289,14 +289,14 @@ # Make variables (CC, etc...) AS = $(CROSS_COMPILE)as @@ -9,4 +8,16 @@ diff -uNr busybox-1.31.1/Makefile busybox-1.31.1.mod/Makefile +CC = $(CROSS_COMPILE)clang LD = $(CC) -nostdlib CPP = $(CC) -E - AR = $(CROSS_COMPILE)ar +-AR = $(CROSS_COMPILE)ar +-NM = $(CROSS_COMPILE)nm +-STRIP = $(CROSS_COMPILE)strip +-OBJCOPY = $(CROSS_COMPILE)objcopy +-OBJDUMP = $(CROSS_COMPILE)objdump ++AR = llvm-ar ++NM = llvm-nm ++STRIP = llvm-strip ++OBJCOPY = llvm-objcopy ++OBJDUMP = llvm-objdump + PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config + AWK = awk + GENKSYMS = scripts/genksyms/genksyms diff --git a/packages/busybox/0004-Makefile.flags.patch b/packages/busybox/0004-Makefile.flags.patch index 3a9306a68..ed634ddac 100644 --- a/packages/busybox/0004-Makefile.flags.patch +++ b/packages/busybox/0004-Makefile.flags.patch @@ -1,6 +1,6 @@ ---- ../Makefile.flags.orig 2020-07-20 19:17:12.263392471 +0000 -+++ ./Makefile.flags 2020-07-20 19:17:22.988106865 +0000 -@@ -150,9 +150,9 @@ +--- ./Makefile.flags.orig 2021-01-01 11:52:27.000000000 +0100 ++++ ./Makefile.flags 2021-08-19 16:49:06.743647568 +0200 +@@ -151,9 +151,9 @@ # fall back to using a temp file: CRYPT_AVAILABLE := $(shell echo 'int main(void){return 0;}' >crypttest.c; $(CC) $(CFLAGS) -lcrypt -o /dev/null crypttest.c >/dev/null 2>&1 && echo "y"; rm crypttest.c) ifeq ($(CRYPT_AVAILABLE),y) diff --git a/packages/busybox/0007-miscutils-crond.patch b/packages/busybox/0006-miscutils-crond.patch similarity index 100% rename from packages/busybox/0007-miscutils-crond.patch rename to packages/busybox/0006-miscutils-crond.patch diff --git a/packages/busybox/0008-miscutils-crontab.patch b/packages/busybox/0007-miscutils-crontab.patch similarity index 100% rename from packages/busybox/0008-miscutils-crontab.patch rename to packages/busybox/0007-miscutils-crontab.patch diff --git a/packages/busybox/0009-networking-ftpd-no-chroot.patch b/packages/busybox/0008-networking-ftpd-no-chroot.patch similarity index 52% rename from packages/busybox/0009-networking-ftpd-no-chroot.patch rename to packages/busybox/0008-networking-ftpd-no-chroot.patch index ae6f69244..41c38715d 100644 --- a/packages/busybox/0009-networking-ftpd-no-chroot.patch +++ b/packages/busybox/0008-networking-ftpd-no-chroot.patch @@ -1,7 +1,6 @@ -diff -uNr busybox-1.31.1/networking/ftpd.c busybox-1.31.1.mod/networking/ftpd.c ---- busybox-1.31.1/networking/ftpd.c 2019-06-10 13:50:53.000000000 +0300 -+++ busybox-1.31.1.mod/networking/ftpd.c 2019-11-11 22:26:50.216912741 +0200 -@@ -1301,8 +1301,11 @@ +--- ./networking/ftpd.c.orig 2021-08-19 16:49:06.730314230 +0200 ++++ ./networking/ftpd.c 2021-08-19 16:49:06.753647572 +0200 +@@ -1302,8 +1302,11 @@ G.root_fd = xopen("/", O_RDONLY | O_DIRECTORY); close_on_exec_on(G.root_fd); #endif diff --git a/packages/busybox/0010-networking-httpd-default-port.patch b/packages/busybox/0009-networking-httpd-default-port.patch similarity index 77% rename from packages/busybox/0010-networking-httpd-default-port.patch rename to packages/busybox/0009-networking-httpd-default-port.patch index d8154ea25..027d9faed 100644 --- a/packages/busybox/0010-networking-httpd-default-port.patch +++ b/packages/busybox/0009-networking-httpd-default-port.patch @@ -1,7 +1,6 @@ -diff -uNr busybox-1.31.1/networking/httpd.c busybox-1.31.1.mod/networking/httpd.c ---- busybox-1.31.1/networking/httpd.c 2019-11-11 21:31:58.406733857 +0200 -+++ busybox-1.31.1.mod/networking/httpd.c 2019-11-11 22:29:16.534250966 +0200 -@@ -232,7 +232,7 @@ +--- ./networking/httpd.c.orig 2021-08-19 16:49:06.730314230 +0200 ++++ ./networking/httpd.c 2021-08-19 16:49:06.756980906 +0200 +@@ -270,7 +270,7 @@ //usage: "\n -i Inetd mode" //usage: "\n -f Don't daemonize" //usage: "\n -v[v] Verbose" @@ -10,8 +9,8 @@ diff -uNr busybox-1.31.1/networking/httpd.c busybox-1.31.1.mod/networking/httpd. //usage: IF_FEATURE_HTTPD_SETUID( //usage: "\n -u USER[:GRP] Set uid/gid after binding to port") //usage: IF_FEATURE_HTTPD_BASIC_AUTH( -@@ -488,7 +488,7 @@ - asm volatile("":::"memory"); \ +@@ -538,7 +538,7 @@ + SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ IF_FEATURE_HTTPD_RANGES(range_start = -1;) \ - bind_addr_or_port = "80"; \ @@ -19,7 +18,7 @@ diff -uNr busybox-1.31.1/networking/httpd.c busybox-1.31.1.mod/networking/httpd. index_page = index_html; \ file_size = -1; \ } while (0) -@@ -1004,7 +1004,7 @@ +@@ -1030,7 +1030,7 @@ if (!errno && n && n <= 0xffff) n = create_and_bind_stream_or_die(NULL, n); else @@ -28,7 +27,7 @@ diff -uNr busybox-1.31.1/networking/httpd.c busybox-1.31.1.mod/networking/httpd. xlisten(n, 9); return n; } -@@ -2209,7 +2209,7 @@ +@@ -2279,7 +2279,7 @@ if (proxy_entry) { if (verbose > 1) bb_error_msg("proxy:%s", urlcopy); diff --git a/packages/busybox/0011-networking-telnetd-default-port.patch b/packages/busybox/0010-networking-telnetd-default-port.patch similarity index 100% rename from packages/busybox/0011-networking-telnetd-default-port.patch rename to packages/busybox/0010-networking-telnetd-default-port.patch diff --git a/packages/busybox/0011-networking-tftp-no-chroot.patch b/packages/busybox/0011-networking-tftp-no-chroot.patch new file mode 100644 index 000000000..8f5c598a7 --- /dev/null +++ b/packages/busybox/0011-networking-tftp-no-chroot.patch @@ -0,0 +1,15 @@ +--- ./networking/tftp.c.orig 2021-01-01 11:52:27.000000000 +0100 ++++ ./networking/tftp.c 2021-08-19 16:49:06.763647575 +0200 +@@ -917,7 +917,12 @@ + G.pw = xgetpwnam(user_opt); + } + if (argv[0]) { ++#ifdef __ANDROID__ ++ // chroot may trigger seccomp and is allowed only for root anyway. ++ xchdir(argv[0]); ++#else + xchroot(argv[0]); ++#endif + } + + result = recv_from_to(STDIN_FILENO, diff --git a/packages/busybox/0012-networking-tftp-no-chroot.patch b/packages/busybox/0012-networking-tftp-no-chroot.patch deleted file mode 100644 index 9a0eb8cc6..000000000 --- a/packages/busybox/0012-networking-tftp-no-chroot.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff -uNr busybox-1.31.1/networking/tftp.c busybox-1.31.1.mod/networking/tftp.c ---- busybox-1.31.1/networking/tftp.c 2019-06-10 13:50:53.000000000 +0300 -+++ busybox-1.31.1.mod/networking/tftp.c 2019-11-11 22:36:27.592894669 +0200 -@@ -907,7 +907,12 @@ - G.pw = xgetpwnam(user_opt); - } - if (argv[0]) { -+#ifdef __ANDROID__ -+ // chroot may trigger seccomp and is allowed only for root anyway. -+ xchdir(argv[0]); -+#else - xchroot(argv[0]); -+#endif - } - - result = recv_from_to(STDIN_FILENO, diff --git a/packages/busybox/build.sh b/packages/busybox/build.sh index 8d263fc12..74a44b0fa 100644 --- a/packages/busybox/build.sh +++ b/packages/busybox/build.sh @@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Tiny versions of many common UNIX utilities into a singl TERMUX_PKG_LICENSE="GPL-2.0" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION=1.33.1 -TERMUX_PKG_REVISION=4 +TERMUX_PKG_REVISION=5 TERMUX_PKG_SRCURL=https://busybox.net/downloads/busybox-${TERMUX_PKG_VERSION}.tar.bz2 TERMUX_PKG_SHA256=12cec6bd2b16d8a9446dd16130f2b92982f1819f6e1c5f5887b6db03f5660d28 TERMUX_PKG_BUILD_IN_SRC=true