From a44893e979dc6e961cb952f8f0c80d94bfc79646 Mon Sep 17 00:00:00 2001 From: Ronald Y Date: Mon, 16 Sep 2024 08:45:56 +0800 Subject: [PATCH 1/4] moved from termux-packages: openssl-1.1 --- .../Configurations-15-android.conf.patch | 47 +++++++++++ tur/openssl-1.1/apps-ocsp.c.patch | 11 +++ tur/openssl-1.1/build.sh | 77 +++++++++++++++++++ tur/openssl-1.1/e_os.h.patch | 12 +++ tur/openssl-1.1/openssl1.1-tool.subpackage.sh | 2 + 5 files changed, 149 insertions(+) create mode 100644 tur/openssl-1.1/Configurations-15-android.conf.patch create mode 100644 tur/openssl-1.1/apps-ocsp.c.patch create mode 100644 tur/openssl-1.1/build.sh create mode 100644 tur/openssl-1.1/e_os.h.patch create mode 100644 tur/openssl-1.1/openssl1.1-tool.subpackage.sh diff --git a/tur/openssl-1.1/Configurations-15-android.conf.patch b/tur/openssl-1.1/Configurations-15-android.conf.patch new file mode 100644 index 000000000..cabdfa800 --- /dev/null +++ b/tur/openssl-1.1/Configurations-15-android.conf.patch @@ -0,0 +1,47 @@ +diff -u -r ../openssl-1.1.1-pre9/Configurations/15-android.conf ./Configurations/15-android.conf +--- ../openssl-1.1.1-pre9/Configurations/15-android.conf 2018-08-21 12:14:11.000000000 +0000 ++++ ./Configurations/15-android.conf 2018-08-22 09:48:30.506584421 +0000 +@@ -130,10 +130,10 @@ + # systems are perfectly capable of executing binaries targeting + # Froyo. Keep in mind that in the nutshell Android builds are + # about JNI, i.e. shared libraries, not applications. +- cflags => add(sub { android_ndk()->{cflags} }), +- cppflags => add(sub { android_ndk()->{cppflags} }), +- cxxflags => add(sub { android_ndk()->{cflags} }), +- bn_ops => sub { android_ndk()->{bn_ops} }, ++ #cflags => add(sub { android_ndk()->{cflags} }), ++ #cppflags => add(sub { android_ndk()->{cppflags} }), ++ #cxxflags => add(sub { android_ndk()->{cflags} }), ++ #bn_ops => sub { android_ndk()->{bn_ops} }, + bin_cflags => "-pie", + enable => [ ], + }, +@@ -166,11 +166,11 @@ + # Newer NDK versions reportedly require additional -latomic. + # + inherit_from => [ "android", asm("armv4_asm") ], +- bn_ops => add("RC4_CHAR"), ++ bn_ops => "BN_LLONG RC4_CHAR", + }, + "android-arm64" => { + inherit_from => [ "android", asm("aarch64_asm") ], +- bn_ops => add("RC4_CHAR"), ++ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", + perlasm_scheme => "linux64", + }, + +@@ -197,12 +197,12 @@ + "android-x86" => { + inherit_from => [ "android", asm("x86_asm") ], + CFLAGS => add(picker(release => "-fomit-frame-pointer")), +- bn_ops => add("RC4_INT"), ++ bn_ops => "BN_LLONG RC4_INT", + perlasm_scheme => "android", + }, + "android-x86_64" => { + inherit_from => [ "android", asm("x86_64_asm") ], +- bn_ops => add("RC4_INT"), ++ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_INT", + perlasm_scheme => "elf", + }, + diff --git a/tur/openssl-1.1/apps-ocsp.c.patch b/tur/openssl-1.1/apps-ocsp.c.patch new file mode 100644 index 000000000..26046c324 --- /dev/null +++ b/tur/openssl-1.1/apps-ocsp.c.patch @@ -0,0 +1,11 @@ +diff -u -r ../openssl-1.1.1g/apps/ocsp.c ./apps/ocsp.c +--- ../openssl-1.1.1g/apps/ocsp.c 2020-04-21 12:22:39.000000000 +0000 ++++ ./apps/ocsp.c 2020-04-28 22:42:57.312189000 +0000 +@@ -48,6 +48,7 @@ + #endif + + #if !defined(NO_FORK) && !defined(OPENSSL_NO_SOCK) \ ++ && !defined(__ANDROID__) \ + && !defined(OPENSSL_NO_POSIX_IO) + # define OCSP_DAEMON + # include diff --git a/tur/openssl-1.1/build.sh b/tur/openssl-1.1/build.sh new file mode 100644 index 000000000..26a75fd2f --- /dev/null +++ b/tur/openssl-1.1/build.sh @@ -0,0 +1,77 @@ +TERMUX_PKG_HOMEPAGE=https://www.openssl.org/ +TERMUX_PKG_DESCRIPTION="Library implementing the SSL and TLS protocols as well as general purpose cryptography functions" +TERMUX_PKG_LICENSE="custom" +TERMUX_PKG_LICENSE_FILE="LICENSE" +TERMUX_PKG_MAINTAINER="@termux" +_VERSION=1.1.1w +TERMUX_PKG_VERSION=1:${_VERSION} +TERMUX_PKG_SRCURL=https://www.openssl.org/source/openssl-${_VERSION/\~/-}.tar.gz +TERMUX_PKG_SHA256=cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8 +TERMUX_PKG_AUTO_UPDATE=false +TERMUX_PKG_DEPENDS="ca-certificates, zlib" +TERMUX_PKG_CONFFILES="etc/tls/openssl.cnf" +TERMUX_PKG_RM_AFTER_INSTALL="bin/c_rehash etc/" +TERMUX_PKG_BUILD_IN_SRC=true +TERMUX_PKG_CONFLICTS="libcurl (<< 7.61.0-1)" +TERMUX_PKG_BREAKS="openssl (<< 1.1.1m)" +TERMUX_PKG_REPLACES="openssl (<< 1.1.1m)" + +termux_step_pre_configure() { + test -d $TERMUX_PREFIX/include/openssl && mv $TERMUX_PREFIX/include/openssl{,.tmp} || : + LDFLAGS="-L$TERMUX_PREFIX/lib/openssl-1.1 -Wl,-rpath=$TERMUX_PREFIX/lib/openssl-1.1 $LDFLAGS" +} + +termux_step_configure() { + # Certain packages are not safe to build on device because their + # build.sh script deletes specific files in $TERMUX_PREFIX. + if $TERMUX_ON_DEVICE_BUILD; then + termux_error_exit "Package '$TERMUX_PKG_NAME' is not safe for on-device builds." + fi + + CFLAGS+=" -DNO_SYSLOG" + + perl -p -i -e "s@TERMUX_CFLAGS@$CFLAGS@g" Configure + test $TERMUX_ARCH = "arm" && TERMUX_OPENSSL_PLATFORM="android-arm" + test $TERMUX_ARCH = "aarch64" && TERMUX_OPENSSL_PLATFORM="android-arm64" + test $TERMUX_ARCH = "i686" && TERMUX_OPENSSL_PLATFORM="android-x86" + test $TERMUX_ARCH = "x86_64" && TERMUX_OPENSSL_PLATFORM="android-x86_64" + + install -m755 -d $TERMUX_PREFIX/lib/openssl-1.1 + + ./Configure $TERMUX_OPENSSL_PLATFORM \ + --prefix=$TERMUX_PREFIX \ + --openssldir=$TERMUX_PREFIX/etc/tls \ + --libdir=$TERMUX_PREFIX/lib/openssl-1.1 \ + shared \ + zlib-dynamic \ + no-ssl \ + no-hw \ + no-srp \ + no-tests +} + +termux_step_make() { + make depend + make -j $TERMUX_PKG_MAKE_PROCESSES all +} + +termux_step_make_install() { + # "install_sw" instead of "install" to not install man pages: + make -j 1 install_sw MANDIR=$TERMUX_PREFIX/share/man MANSUFFIX=.ssl + + mkdir -p $TERMUX_PREFIX/etc/tls/ + + cp apps/openssl.cnf $TERMUX_PREFIX/etc/tls/openssl.cnf + + install -m755 -d $TERMUX_PREFIX/include/openssl-1.1 + mv $TERMUX_PREFIX/include/openssl $TERMUX_PREFIX/include/openssl-1.1/ + mv $TERMUX_PREFIX/bin/openssl $TERMUX_PREFIX/bin/openssl-1.1 +} + +termux_step_post_make_install() { + test -d $TERMUX_PREFIX/include/openssl.tmp && mv $TERMUX_PREFIX/include/openssl{.tmp,} || : +} + +termux_step_post_massage() { + rm -rf include/openssl +} diff --git a/tur/openssl-1.1/e_os.h.patch b/tur/openssl-1.1/e_os.h.patch new file mode 100644 index 000000000..26ee3d7a1 --- /dev/null +++ b/tur/openssl-1.1/e_os.h.patch @@ -0,0 +1,12 @@ +diff -u -r ../openssl-1.1.1c/e_os.h ./e_os.h +--- ../openssl-1.1.1c/e_os.h 2019-05-28 13:12:21.000000000 +0000 ++++ ./e_os.h 2019-05-29 20:59:46.153243395 +0000 +@@ -38,7 +38,7 @@ + * sockets will be tried in the order listed in case accessing the device + * files listed in DEVRANDOM did not return enough randomness. + */ +-# define DEVRANDOM_EGD "/var/run/egd-pool", "/dev/egd-pool", "/etc/egd-pool", "/etc/entropy" ++# define DEVRANDOM_EGD "@TERMUX_PREFIX@/var/run/egd-pool", "/dev/egd-pool", "@TERMUX_PREFIX@/etc/egd-pool", "@TERMUX_PREFIX@/etc/entropy" + # endif + + # if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) diff --git a/tur/openssl-1.1/openssl1.1-tool.subpackage.sh b/tur/openssl-1.1/openssl1.1-tool.subpackage.sh new file mode 100644 index 000000000..af673bb66 --- /dev/null +++ b/tur/openssl-1.1/openssl1.1-tool.subpackage.sh @@ -0,0 +1,2 @@ +TERMUX_SUBPKG_INCLUDE="bin" +TERMUX_SUBPKG_DESCRIPTION="The openssl command line cryptographic tool" From 4688bb4c7d6e35c95f23c0ec472f237b3e5bfb49 Mon Sep 17 00:00:00 2001 From: Ronald Y Date: Tue, 10 Sep 2024 23:40:45 +0800 Subject: [PATCH 2/4] new package: tor-browser --- ...0001-configure-treat-termux-as-linux.patch | 11 ++ .../0002-configure-fix-arm-options.patch | 11 ++ .../0003-configure-fix-rustflags.patch | 44 +++++++ ...igure-do-not-check-libstdcxx-headers.patch | 21 ++++ ...0005-configure-do-not-append-sysroot.patch | 22 ++++ .../0006-configure-do-not-enable-alsa.patch | 11 ++ .../0007-fix-link-with-libcxx-18.patch | 14 +++ tur/tor-browser/0008-fix-marcos.patch | 88 ++++++++++++++ tur/tor-browser/0009-impl-posix-shmem.patch | 77 ++++++++++++ ...not-check-time_t-for-system-libevent.patch | 10 ++ .../0011-use-UnderrunHandlerNoop.patch | 23 ++++ .../0012-do-not-use-adaptive-mutex.patch | 20 ++++ tur/tor-browser/0013-fix-rust-compile.patch | 52 ++++++++ ...set-thread-priority-scheduling-macro.patch | 15 +++ tur/tor-browser/0015-skia-termux.patch | 22 ++++ .../0016-protobuf-no-android-log.patch | 20 ++++ tur/tor-browser/0017-icu-74.patch | 17 +++ ...0018-fix-include-dir-for-cpufeatures.patch | 11 ++ tur/tor-browser/0019-fix-sigbus.patch | 17 +++ .../0020-do-not-call-get-pci-status.patch | 12 ++ ...-fix-missing-include-for-zlib-module.patch | 11 ++ ...22-configure-no-pack-relative-relocs.patch | 10 ++ ...if-dlpi_name-is-nullptr-before-using.patch | 13 ++ ...de-for-macro-MOZ_TRY-in-TimeZone.cpp.patch | 10 ++ ...025-disable-native-https-dns-resolve.patch | 32 +++++ ...026-partially-disable-unified-builds.patch | 11 ++ .../0027-fix-compile-with-libcxx.patch | 11 ++ tur/tor-browser/build.sh | 112 ++++++++++++++++++ tur/tor-browser/mozconfig.cfg | 45 +++++++ tur/tor-browser/tor-browser.desktop | 24 ++++ 30 files changed, 797 insertions(+) create mode 100644 tur/tor-browser/0001-configure-treat-termux-as-linux.patch create mode 100644 tur/tor-browser/0002-configure-fix-arm-options.patch create mode 100644 tur/tor-browser/0003-configure-fix-rustflags.patch create mode 100644 tur/tor-browser/0004-configure-do-not-check-libstdcxx-headers.patch create mode 100644 tur/tor-browser/0005-configure-do-not-append-sysroot.patch create mode 100644 tur/tor-browser/0006-configure-do-not-enable-alsa.patch create mode 100644 tur/tor-browser/0007-fix-link-with-libcxx-18.patch create mode 100644 tur/tor-browser/0008-fix-marcos.patch create mode 100644 tur/tor-browser/0009-impl-posix-shmem.patch create mode 100644 tur/tor-browser/0010-do-not-check-time_t-for-system-libevent.patch create mode 100644 tur/tor-browser/0011-use-UnderrunHandlerNoop.patch create mode 100644 tur/tor-browser/0012-do-not-use-adaptive-mutex.patch create mode 100644 tur/tor-browser/0013-fix-rust-compile.patch create mode 100644 tur/tor-browser/0014-unset-thread-priority-scheduling-macro.patch create mode 100644 tur/tor-browser/0015-skia-termux.patch create mode 100644 tur/tor-browser/0016-protobuf-no-android-log.patch create mode 100644 tur/tor-browser/0017-icu-74.patch create mode 100644 tur/tor-browser/0018-fix-include-dir-for-cpufeatures.patch create mode 100644 tur/tor-browser/0019-fix-sigbus.patch create mode 100644 tur/tor-browser/0020-do-not-call-get-pci-status.patch create mode 100644 tur/tor-browser/0021-fix-missing-include-for-zlib-module.patch create mode 100644 tur/tor-browser/0022-configure-no-pack-relative-relocs.patch create mode 100644 tur/tor-browser/0023-check-if-dlpi_name-is-nullptr-before-using.patch create mode 100644 tur/tor-browser/0024-fix-missing-include-for-macro-MOZ_TRY-in-TimeZone.cpp.patch create mode 100644 tur/tor-browser/0025-disable-native-https-dns-resolve.patch create mode 100644 tur/tor-browser/0026-partially-disable-unified-builds.patch create mode 100644 tur/tor-browser/0027-fix-compile-with-libcxx.patch create mode 100644 tur/tor-browser/build.sh create mode 100644 tur/tor-browser/mozconfig.cfg create mode 100644 tur/tor-browser/tor-browser.desktop diff --git a/tur/tor-browser/0001-configure-treat-termux-as-linux.patch b/tur/tor-browser/0001-configure-treat-termux-as-linux.patch new file mode 100644 index 000000000..0fafbaa6b --- /dev/null +++ b/tur/tor-browser/0001-configure-treat-termux-as-linux.patch @@ -0,0 +1,11 @@ +--- a/build/moz.configure/init.configure ++++ b/build/moz.configure/init.configure +@@ -500,7 +500,7 @@ + abi = None + sub_configure_alias = triplet + if "android" in os: +- canonical_os = "Android" ++ canonical_os = "GNU" + canonical_kernel = "Linux" + elif os.startswith("linux"): + canonical_os = "GNU" diff --git a/tur/tor-browser/0002-configure-fix-arm-options.patch b/tur/tor-browser/0002-configure-fix-arm-options.patch new file mode 100644 index 000000000..c080185a1 --- /dev/null +++ b/tur/tor-browser/0002-configure-fix-arm-options.patch @@ -0,0 +1,11 @@ +--- a/build/moz.configure/arm.configure ++++ b/build/moz.configure/arm.configure +@@ -7,7 +7,7 @@ + + @depends(target.os) + def arm_option_defaults(os): +- if os == "Android": ++ if True: + arch = "armv7-a" + thumb = "yes" + fpu = "neon" diff --git a/tur/tor-browser/0003-configure-fix-rustflags.patch b/tur/tor-browser/0003-configure-fix-rustflags.patch new file mode 100644 index 000000000..5242cd14f --- /dev/null +++ b/tur/tor-browser/0003-configure-fix-rustflags.patch @@ -0,0 +1,44 @@ +--- a/build/moz.configure/rust.configure ++++ b/build/moz.configure/rust.configure +@@ -514,17 +514,27 @@ + assert_rust_compile(host, rustc_target, rustc) + return rustc_target + ++option("--custom-rust-target-triple", nargs=1, help="Customize Rust Target Triple") ++ ++@depends("--custom-rust-target-triple") ++def get_custom_rust_target_triple(custom_rust_target_triple): ++ if custom_rust_target_triple: ++ return custom_rust_target_triple[0] ++ return None + + @depends( +- rustc, target, c_compiler, rust_supported_targets, arm_target, when=rust_compiler ++ get_custom_rust_target_triple, rustc, target, c_compiler, rust_supported_targets, arm_target, when=rust_compiler + ) + @checking("for rust target triplet") + def rust_target_triple( +- rustc, target, compiler_info, rust_supported_targets, arm_target ++ custom_rust_target_triple, rustc, target, compiler_info, rust_supported_targets, arm_target + ): +- rustc_target = detect_rustc_target( +- target, compiler_info, arm_target, rust_supported_targets +- ) ++ if custom_rust_target_triple: ++ rustc_target = custom_rust_target_triple ++ else: ++ rustc_target = detect_rustc_target( ++ target, compiler_info, arm_target, rust_supported_targets ++ ) + assert_rust_compile(target, rustc_target, rustc) + return rustc_target + +@@ -599,8 +609,6 @@ + + # ============================================================== + +-option(env="RUSTFLAGS", nargs=1, help="Rust compiler flags") +-set_config("RUSTFLAGS", depends("RUSTFLAGS")(lambda flags: flags)) + + + # Rust compiler flags diff --git a/tur/tor-browser/0004-configure-do-not-check-libstdcxx-headers.patch b/tur/tor-browser/0004-configure-do-not-check-libstdcxx-headers.patch new file mode 100644 index 000000000..446e0719e --- /dev/null +++ b/tur/tor-browser/0004-configure-do-not-check-libstdcxx-headers.patch @@ -0,0 +1,21 @@ +--- a/build/moz.configure/toolchain.configure ++++ b/build/moz.configure/toolchain.configure +@@ -1981,17 +1981,7 @@ + + @depends(cxx_compiler, target) + def needs_libstdcxx_newness_check(cxx_compiler, target): +- # We only have to care about this on Linux and MinGW. +- if cxx_compiler.type == "clang-cl": +- return +- +- if target.kernel not in ("Linux", "WINNT"): +- return +- +- if target.os == "Android": +- return +- +- return True ++ return + + + def die_on_old_libstdcxx(): diff --git a/tur/tor-browser/0005-configure-do-not-append-sysroot.patch b/tur/tor-browser/0005-configure-do-not-append-sysroot.patch new file mode 100644 index 000000000..bd4830603 --- /dev/null +++ b/tur/tor-browser/0005-configure-do-not-append-sysroot.patch @@ -0,0 +1,22 @@ +--- a/build/moz.configure/toolchain.configure ++++ b/build/moz.configure/toolchain.configure +@@ -1256,7 +1256,7 @@ + ): + wrapper = list(compiler_wrapper or ()) + flags = [] +- if sysroot.path: ++ if False: + if host_or_target.kernel == "Darwin": + # While --sysroot and -isysroot are roughly equivalent, when not using + # -isysroot on mac, clang takes the SDKROOT environment variable into +--- a/build/moz.configure/pkg.configure ++++ b/build/moz.configure/pkg.configure +@@ -56,7 +56,7 @@ + @imports(_from="os", _import="environ") + @imports(_from="os", _import="pathsep") + def pkg_config_vars(target, sysroot_path, multiarch_dir): +- if sysroot_path and target.kernel != "Darwin": ++ if False: + pkgconfig_dirs = [ + "usr/lib/pkgconfig", + "usr/lib/{}/pkgconfig".format(multiarch_dir), diff --git a/tur/tor-browser/0006-configure-do-not-enable-alsa.patch b/tur/tor-browser/0006-configure-do-not-enable-alsa.patch new file mode 100644 index 000000000..a70a5b384 --- /dev/null +++ b/tur/tor-browser/0006-configure-do-not-enable-alsa.patch @@ -0,0 +1,11 @@ +--- a/toolkit/moz.configure ++++ b/toolkit/moz.configure +@@ -174,7 +174,7 @@ + @depends(target) + def midir_linux_support(target): + return ( +- target.kernel == "Linux" and target.os != "Android" and target.cpu != "riscv64" ++ False + ) + + diff --git a/tur/tor-browser/0007-fix-link-with-libcxx-18.patch b/tur/tor-browser/0007-fix-link-with-libcxx-18.patch new file mode 100644 index 000000000..888df0e8e --- /dev/null +++ b/tur/tor-browser/0007-fix-link-with-libcxx-18.patch @@ -0,0 +1,14 @@ +https://bugzilla.mozilla.org/show_bug.cgi?id=1874059 +https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276746 + +--- a/build/moz.configure/toolchain.configure ++++ b/build/moz.configure/toolchain.configure +@@ -2344,7 +2344,7 @@ + @depends(target, build_environment) + def visibility_flags(target, env): + if target.os != "WINNT": +- if target.kernel == "Darwin": ++ if True: + return ("-fvisibility=hidden", "-fvisibility-inlines-hidden") + return ( + "-I%s/system_wrappers" % os.path.join(env.dist), diff --git a/tur/tor-browser/0008-fix-marcos.patch b/tur/tor-browser/0008-fix-marcos.patch new file mode 100644 index 000000000..256c71192 --- /dev/null +++ b/tur/tor-browser/0008-fix-marcos.patch @@ -0,0 +1,88 @@ +--- a/dom/media/systemservices/VideoEngine.cpp ++++ b/dom/media/systemservices/VideoEngine.cpp +@@ -30,7 +30,7 @@ + #define LOG(args) MOZ_LOG(gVideoEngineLog, mozilla::LogLevel::Debug, args) + #define LOG_ENABLED() MOZ_LOG_TEST(gVideoEngineLog, mozilla::LogLevel::Debug) + +-#if defined(ANDROID) ++#if defined(ANDROID) && !defined(__TERMUX__) + int VideoEngine::SetAndroidObjects() { + LOG(("%s", __PRETTY_FUNCTION__)); + +--- a/ipc/chromium/src/base/lock_impl_posix.cc ++++ b/ipc/chromium/src/base/lock_impl_posix.cc +@@ -22,7 +22,7 @@ + // Lock::PriorityInheritanceAvailable still must be checked as the code may + // compile but the underlying platform still may not correctly support priority + // inheritance locks. +-#if defined(ANDROID) ++#if defined(ANDROID) || defined(__TERMUX__) + # define PRIORITY_INHERITANCE_LOCKS_POSSIBLE() 0 + #else + # define PRIORITY_INHERITANCE_LOCKS_POSSIBLE() 1 +--- a/js/src/ctypes/libffi/src/closures.c ++++ b/js/src/ctypes/libffi/src/closures.c +@@ -112,7 +112,7 @@ + #else /* !NetBSD with PROT_MPROTECT */ + + #if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE +-# if __linux__ && !defined(__ANDROID__) ++# if __linux__ && !defined(__TERMUX__) + /* This macro indicates it may be forbidden to map anonymous memory + with both write and execute permission. Code compiled when this + option is defined will attempt to map such pages once, but if it +--- a/memory/build/malloc_decls.h ++++ b/memory/build/malloc_decls.h +@@ -39,7 +39,7 @@ + // consistent declare certain functions as `throw()`, though. + + // Bionic and OS X don't seem to care about `throw()`ness. +-# if defined(ANDROID) || defined(XP_DARWIN) ++# if defined(__TERMUX__) || defined(XP_DARWIN) + # undef NOTHROW_MALLOC_DECL + # define NOTHROW_MALLOC_DECL MALLOC_DECL + // Some places don't care about the distinction. +--- a/dom/media/CubebUtils.cpp ++++ b/dom/media/CubebUtils.cpp +@@ -57,7 +57,7 @@ + #define PREF_AUDIOIPC_STACK_SIZE "media.audioipc.stack_size" + #define PREF_AUDIOIPC_SHM_AREA_SIZE "media.audioipc.shm_area_size" + +-#if defined(XP_LINUX) || defined(XP_MACOSX) || defined(XP_WIN) ++#if (defined(XP_LINUX) && !defined(__TERMUX__)) || defined(XP_MACOSX) || defined(XP_WIN) + # define MOZ_CUBEB_REMOTING + #endif + +--- a/mozglue/misc/ConditionVariable_posix.cpp ++++ b/mozglue/misc/ConditionVariable_posix.cpp +@@ -23,7 +23,7 @@ + // Android 4.4 or earlier & macOS 10.12 has the clock functions, but not + // pthread_condattr_setclock. + #if defined(HAVE_CLOCK_MONOTONIC) && \ +- !(defined(__ANDROID__) && __ANDROID_API__ < 21) && !defined(__APPLE__) ++ defined(__TERMUX__) + # define CV_USE_CLOCK_API + #endif + +--- a/mozglue/misc/StackWalk.cpp ++++ b/mozglue/misc/StackWalk.cpp +@@ -692,7 +692,7 @@ + stackEnd = __libc_stack_end; + # elif defined(XP_DARWIN) + stackEnd = pthread_get_stackaddr_np(pthread_self()); +-# elif defined(ANDROID) ++# elif defined(__TERMUX__) + pthread_attr_t sattr; + pthread_attr_init(&sattr); + pthread_getattr_np(pthread_self(), &sattr); +--- a/nsprpub/pr/src/pthreads/ptsynch.c ++++ b/nsprpub/pr/src/pthreads/ptsynch.c +@@ -953,7 +953,7 @@ + #if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) \ + || (defined(FREEBSD) && __FreeBSD_version < 1200059) \ + || defined(OPENBSD) || defined(BSDI) \ +- || defined(DARWIN) ++ || defined(DARWIN) || defined(__TERMUX__) + /* union semun is defined by including */ + #else + /* according to X/OPEN we have to define it ourselves */ diff --git a/tur/tor-browser/0009-impl-posix-shmem.patch b/tur/tor-browser/0009-impl-posix-shmem.patch new file mode 100644 index 000000000..e736e9e63 --- /dev/null +++ b/tur/tor-browser/0009-impl-posix-shmem.patch @@ -0,0 +1,77 @@ +--- a/ipc/chromium/src/base/shared_memory_posix.cc ++++ b/ipc/chromium/src/base/shared_memory_posix.cc +@@ -40,6 +40,65 @@ + #include "mozilla/UniquePtrExtensions.h" + #include "prenv.h" + ++static int shm_unlink(const char *name) { ++ size_t namelen; ++ char *fname; ++ ++ /* Construct the filename. */ ++ while (name[0] == '/') ++name; ++ ++ if (name[0] == '\0') { ++ /* The name "/" is not supported. */ ++ errno = EINVAL; ++ return -1; ++ } ++ ++ namelen = strlen(name); ++ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1); ++ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1); ++ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1); ++ ++ return unlink(fname); ++} ++ ++static int shm_open(const char *name, int oflag, mode_t mode) { ++ size_t namelen; ++ char *fname; ++ int fd; ++ ++ /* Construct the filename. */ ++ while (name[0] == '/') ++name; ++ ++ if (name[0] == '\0') { ++ /* The name "/" is not supported. */ ++ errno = EINVAL; ++ return -1; ++ } ++ ++ namelen = strlen(name); ++ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1); ++ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1); ++ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1); ++ ++ fd = open(fname, oflag, mode); ++ if (fd != -1) { ++ /* We got a descriptor. Now set the FD_CLOEXEC bit. */ ++ int flags = fcntl(fd, F_GETFD, 0); ++ flags |= FD_CLOEXEC; ++ flags = fcntl(fd, F_SETFD, flags); ++ ++ if (flags == -1) { ++ /* Something went wrong. We cannot return the descriptor. */ ++ int save_errno = errno; ++ close(fd); ++ fd = -1; ++ errno = save_errno; ++ } ++ } ++ ++ return fd; ++} ++ + namespace base { + + void SharedMemory::MappingDeleter::operator()(void* ptr) { +@@ -153,7 +212,7 @@ + // FreeBSD in version 13. + + # if !defined(HAVE_MEMFD_CREATE) && defined(XP_LINUX) && \ +- defined(SYS_memfd_create) ++ defined(SYS_memfd_create) && !defined(__TERMUX__) + + // Older libc versions (e.g., glibc before 2.27) don't have the + // wrapper, but we can supply our own; see `linux_memfd_defs.h`. diff --git a/tur/tor-browser/0010-do-not-check-time_t-for-system-libevent.patch b/tur/tor-browser/0010-do-not-check-time_t-for-system-libevent.patch new file mode 100644 index 000000000..e216d0799 --- /dev/null +++ b/tur/tor-browser/0010-do-not-check-time_t-for-system-libevent.patch @@ -0,0 +1,10 @@ +--- a/ipc/chromium/src/base/message_pump_libevent.cc ++++ b/ipc/chromium/src/base/message_pump_libevent.cc +@@ -41,7 +41,6 @@ + CHECK_EVENT_SIZEOF(PTHREAD_T, pthread_t); + CHECK_EVENT_SIZEOF(SHORT, short); + CHECK_EVENT_SIZEOF(SIZE_T, size_t); +-CHECK_EVENT_SIZEOF(TIME_T, time_t); + CHECK_EVENT_SIZEOF(VOID_P, void*); + + // Lifecycle of struct event diff --git a/tur/tor-browser/0011-use-UnderrunHandlerNoop.patch b/tur/tor-browser/0011-use-UnderrunHandlerNoop.patch new file mode 100644 index 000000000..a0230fbbc --- /dev/null +++ b/tur/tor-browser/0011-use-UnderrunHandlerNoop.patch @@ -0,0 +1,23 @@ +UnderrunHandlerLinux not working due to SELinux rules + +--- a/dom/media/UnderrunHandlerLinux.cpp ++++ b/dom/media/UnderrunHandlerLinux.cpp +@@ -12,6 +12,8 @@ + #include "audio_thread_priority.h" + #include "nsDebug.h" + ++#ifndef __TERMUX__ ++ + namespace mozilla { + + Atomic gRealtimeLimitReached; +@@ -76,3 +78,9 @@ + } + + } // namespace mozilla ++ ++#else ++ ++#include "UnderrunHandlerNoop.cpp" ++ ++#endif diff --git a/tur/tor-browser/0012-do-not-use-adaptive-mutex.patch b/tur/tor-browser/0012-do-not-use-adaptive-mutex.patch new file mode 100644 index 000000000..805cb1d13 --- /dev/null +++ b/tur/tor-browser/0012-do-not-use-adaptive-mutex.patch @@ -0,0 +1,20 @@ +--- a/memory/build/Mutex.h ++++ b/memory/build/Mutex.h +@@ -57,7 +57,7 @@ + } + #elif defined(XP_DARWIN) + mMutex = OS_UNFAIR_LOCK_INIT; +-#elif defined(XP_LINUX) && !defined(ANDROID) ++#elif defined(XP_LINUX) && !defined(__TERMUX__) + pthread_mutexattr_t attr; + if (pthread_mutexattr_init(&attr) != 0) { + return false; +@@ -173,7 +173,7 @@ + + # if defined(XP_DARWIN) + # define STATIC_MUTEX_INIT OS_UNFAIR_LOCK_INIT +-# elif defined(XP_LINUX) && !defined(ANDROID) ++# elif defined(XP_LINUX) && !defined(__TERMUX__) + # define STATIC_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP + # else + # define STATIC_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER diff --git a/tur/tor-browser/0013-fix-rust-compile.patch b/tur/tor-browser/0013-fix-rust-compile.patch new file mode 100644 index 000000000..c90e443dc --- /dev/null +++ b/tur/tor-browser/0013-fix-rust-compile.patch @@ -0,0 +1,52 @@ +--- a/toolkit/components/extensions/storage/moz.build ++++ b/toolkit/components/extensions/storage/moz.build +@@ -17,7 +17,7 @@ + # a delegate for consumers to use instead. Android Components can then provide + # an implementation of the delegate that's backed by the Rust component. For + # details, please see bug 1626506, comment 4. +-if CONFIG["MOZ_WIDGET_TOOLKIT"] != "android": ++if False: + EXPORTS.mozilla.extensions.storage += [ + "ExtensionStorageComponents.h", + ] +--- a/toolkit/library/rust/shared/Cargo.toml ++++ b/toolkit/library/rust/shared/Cargo.toml +@@ -104,7 +104,6 @@ + # Since we're building with at least rustc 1.63, enable rust 1.57 features (use of try_reserve methods). + fallible_collections = { version = "0.4", features = ["rust_1_57"] } + +-[target.'cfg(not(target_os = "android"))'.dependencies] + viaduct = "0.1" + webext_storage_bridge = { path = "../../../components/extensions/storage/webext_storage_bridge" } + tabs = { version = "0.1" } +--- a/toolkit/library/rust/shared/lib.rs ++++ b/toolkit/library/rust/shared/lib.rs +@@ -51,20 +51,16 @@ + + extern crate audio_thread_priority; + +-#[cfg(not(target_os = "android"))] + extern crate webext_storage_bridge; + +-#[cfg(not(target_os = "android"))] + extern crate tabs; + +-#[cfg(not(target_os = "android"))] + mod reexport_appservices_uniffi_scaffolding { + tabs::uniffi_reexport_scaffolding!(); + relevancy::uniffi_reexport_scaffolding!(); + suggest::uniffi_reexport_scaffolding!(); + } + +-#[cfg(not(target_os = "android"))] + extern crate suggest; + + #[cfg(feature = "webrtc")] +@@ -93,7 +88,6 @@ + extern crate l10nregistry_ffi; + extern crate localization_ffi; + +-#[cfg(not(target_os = "android"))] + extern crate viaduct; + + extern crate gecko_logger; diff --git a/tur/tor-browser/0014-unset-thread-priority-scheduling-macro.patch b/tur/tor-browser/0014-unset-thread-priority-scheduling-macro.patch new file mode 100644 index 000000000..87f44c4bb --- /dev/null +++ b/tur/tor-browser/0014-unset-thread-priority-scheduling-macro.patch @@ -0,0 +1,15 @@ +THREAD_PRIORITY_SCHEDULING is introduced in API 28, but Termux compiles as API 24 + +--- a/nsprpub/pr/src/pthreads/ptthread.c ++++ b/nsprpub/pr/src/pthreads/ptthread.c +@@ -37,6 +37,10 @@ + #endif + #endif + ++#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && defined(__TERMUX__) && __ANDROID_API__ < 28 ++#undef _POSIX_THREAD_PRIORITY_SCHEDULING ++#endif ++ + /* + * Record whether or not we have the privilege to set the scheduling + * policy and priority of threads. 0 means that privilege is available. diff --git a/tur/tor-browser/0015-skia-termux.patch b/tur/tor-browser/0015-skia-termux.patch new file mode 100644 index 000000000..04c797adf --- /dev/null +++ b/tur/tor-browser/0015-skia-termux.patch @@ -0,0 +1,22 @@ +--- a/gfx/skia/skia/src/ports/SkDebug_android.cpp ++++ b/gfx/skia/skia/src/ports/SkDebug_android.cpp +@@ -8,7 +8,7 @@ + #include "include/private/base/SkDebug.h" + #include "include/private/base/SkFeatures.h" + +-#if defined(SK_BUILD_FOR_ANDROID) ++#if defined(SK_BUILD_FOR_ANDROID) && !defined(__TERMUX__) + + #include + +--- a/gfx/skia/skia/src/ports/SkDebug_stdio.cpp ++++ b/gfx/skia/skia/src/ports/SkDebug_stdio.cpp +@@ -9,7 +9,7 @@ + #include "include/private/base/SkFeatures.h" + #include "include/private/base/SkLoadUserConfig.h" + +-#if !defined(SK_BUILD_FOR_WIN) && !defined(SK_BUILD_FOR_ANDROID) ++#if (!defined(SK_BUILD_FOR_WIN) && !defined(SK_BUILD_FOR_ANDROID)) || defined(__TERMUX__) + + #include + #include diff --git a/tur/tor-browser/0016-protobuf-no-android-log.patch b/tur/tor-browser/0016-protobuf-no-android-log.patch new file mode 100644 index 000000000..f434bbeb4 --- /dev/null +++ b/tur/tor-browser/0016-protobuf-no-android-log.patch @@ -0,0 +1,20 @@ +--- a/toolkit/components/protobuf/src/google/protobuf/stubs/common.cc ++++ b/toolkit/components/protobuf/src/google/protobuf/stubs/common.cc +@@ -45,7 +45,7 @@ + #include + #define snprintf _snprintf // see comment in strutil.cc + #endif +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + #include + #endif + +@@ -121,7 +121,7 @@ + + namespace internal { + +-#if defined(__ANDROID__) ++#if defined(__ANDROID__) && !defined(__TERMUX__) + inline void DefaultLogHandler(LogLevel level, const char* filename, int line, + const std::string& message) { + if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) { diff --git a/tur/tor-browser/0017-icu-74.patch b/tur/tor-browser/0017-icu-74.patch new file mode 100644 index 000000000..5e2b22567 --- /dev/null +++ b/tur/tor-browser/0017-icu-74.patch @@ -0,0 +1,17 @@ +--- a/intl/lwbrk/LineBreaker.cpp ++++ b/intl/lwbrk/LineBreaker.cpp +@@ -434,7 +434,13 @@ + /* REGIONAL_INDICATOR = 39, [RI] */ CLASS_CHARACTER, + /* E_BASE = 40, [EB] */ CLASS_BREAKABLE, + /* E_MODIFIER = 41, [EM] */ CLASS_CHARACTER, +- /* ZWJ = 42, [ZWJ]*/ CLASS_CHARACTER}; ++ /* ZWJ = 42, [ZWJ]*/ CLASS_CHARACTER, ++ /* AKSARA = 43, [AK] */ CLASS_CHARACTER, ++ /* AKSARA_PREBASE = 44, [AP] */ CLASS_CHARACTER, ++ /* AKSARA_START = 45, [AS] */ CLASS_CHARACTER, ++ /* VIRAMA_FINAL = 46, [VF] */ CLASS_CHARACTER, ++ /* VIRAMA = 47, [VI] */ CLASS_CHARACTER, ++ }; + + static_assert(U_LB_COUNT == mozilla::ArrayLength(sUnicodeLineBreakToClass), + "Gecko vs ICU LineBreak class mismatch"); diff --git a/tur/tor-browser/0018-fix-include-dir-for-cpufeatures.patch b/tur/tor-browser/0018-fix-include-dir-for-cpufeatures.patch new file mode 100644 index 000000000..e3959f218 --- /dev/null +++ b/tur/tor-browser/0018-fix-include-dir-for-cpufeatures.patch @@ -0,0 +1,11 @@ +--- a/gfx/cairo/libpixman/src/pixman-arm.c ++++ b/gfx/cairo/libpixman/src/pixman-arm.c +@@ -96,7 +96,7 @@ + + #elif defined(__ANDROID__) || defined(ANDROID) /* Android */ + +-#include ++#include + + static arm_cpu_features_t + detect_cpu_features (void) diff --git a/tur/tor-browser/0019-fix-sigbus.patch b/tur/tor-browser/0019-fix-sigbus.patch new file mode 100644 index 000000000..5937475b2 --- /dev/null +++ b/tur/tor-browser/0019-fix-sigbus.patch @@ -0,0 +1,17 @@ +Fix SIGBUS Firefox error on Arm. Also apply to other arches just in case. + +https://github.com/termux/termux-packages/issues/15901 +https://github.com/mozilla/gecko-dev/commit/d7ba2cef0e9b74addedda4bc7f57daf10599a5dc +https://github.com/google/cityhash/blob/master/src/city.cc + +--- a/other-licenses/nsis/Contrib/CityHash/cityhash/city.cpp ++++ b/other-licenses/nsis/Contrib/CityHash/cityhash/city.cpp +@@ -33,7 +33,7 @@ + + using namespace std; + +-#if __sparc__ ++#if __sparc__ || __TERMUX__ + #include + static inline uint64 UNALIGNED_LOAD64(const char *p) { + uint64 val; diff --git a/tur/tor-browser/0020-do-not-call-get-pci-status.patch b/tur/tor-browser/0020-do-not-call-get-pci-status.patch new file mode 100644 index 000000000..45363e39b --- /dev/null +++ b/tur/tor-browser/0020-do-not-call-get-pci-status.patch @@ -0,0 +1,12 @@ +--- a/toolkit/xre/glxtest/glxtest.cpp ++++ b/toolkit/xre/glxtest/glxtest.cpp +@@ -946,7 +946,9 @@ + log("GLX_TEST: childgltest start\n"); + + // Get a list of all GPUs from the PCI bus. ++#if !defined(__TERMUX__) + get_pci_status(); ++#endif + + #ifdef MOZ_WAYLAND + if (aWayland) { diff --git a/tur/tor-browser/0021-fix-missing-include-for-zlib-module.patch b/tur/tor-browser/0021-fix-missing-include-for-zlib-module.patch new file mode 100644 index 000000000..7d326fcfb --- /dev/null +++ b/tur/tor-browser/0021-fix-missing-include-for-zlib-module.patch @@ -0,0 +1,11 @@ +--- a/modules/zlib/src/gzguts.h ++++ b/modules/zlib/src/gzguts.h +@@ -3,6 +3,8 @@ + * For conditions of distribution and use, see copyright notice in zlib.h + */ + ++#include ++ + #ifdef _LARGEFILE64_SOURCE + # ifndef _LARGEFILE_SOURCE + # define _LARGEFILE_SOURCE 1 diff --git a/tur/tor-browser/0022-configure-no-pack-relative-relocs.patch b/tur/tor-browser/0022-configure-no-pack-relative-relocs.patch new file mode 100644 index 000000000..eea0e90ad --- /dev/null +++ b/tur/tor-browser/0022-configure-no-pack-relative-relocs.patch @@ -0,0 +1,10 @@ +--- a/toolkit/moz.configure ++++ b/toolkit/moz.configure +@@ -1523,6 +1523,7 @@ + # packed relative relocations rather than elfhack. + if android_version: + return android_version >= 30 ++ return False + return have_arc4random + + @depends( diff --git a/tur/tor-browser/0023-check-if-dlpi_name-is-nullptr-before-using.patch b/tur/tor-browser/0023-check-if-dlpi_name-is-nullptr-before-using.patch new file mode 100644 index 000000000..b7c32b998 --- /dev/null +++ b/tur/tor-browser/0023-check-if-dlpi_name-is-nullptr-before-using.patch @@ -0,0 +1,13 @@ +https://github.com/termux/termux-packages/issues/19050 + +--- a/gfx/gl/GLContext.cpp ++++ b/gfx/gl/GLContext.cpp +@@ -2619,6 +2619,8 @@ + dl_iterate_phdr( + [](dl_phdr_info* info, size_t size, void* data) { + auto& foundPath = *reinterpret_cast*>(data); ++ // XXX: `dlpi_name` may be nullptr, see termux/termux-packages#19050. ++ if (info->dlpi_name == nullptr) return 0; + nsDependentCString thisPath(info->dlpi_name); + if (StringEndsWith(thisPath, "/swrast_dri.so"_ns)) { + foundPath.emplace(thisPath); diff --git a/tur/tor-browser/0024-fix-missing-include-for-macro-MOZ_TRY-in-TimeZone.cpp.patch b/tur/tor-browser/0024-fix-missing-include-for-macro-MOZ_TRY-in-TimeZone.cpp.patch new file mode 100644 index 000000000..2346358c2 --- /dev/null +++ b/tur/tor-browser/0024-fix-missing-include-for-macro-MOZ_TRY-in-TimeZone.cpp.patch @@ -0,0 +1,10 @@ +--- a/intl/components/src/TimeZone.cpp ++++ b/intl/components/src/TimeZone.cpp +@@ -4,6 +4,7 @@ + + #include "mozilla/intl/TimeZone.h" + ++#include "mozilla/Try.h" + #include "mozilla/Vector.h" + + #include diff --git a/tur/tor-browser/0025-disable-native-https-dns-resolve.patch b/tur/tor-browser/0025-disable-native-https-dns-resolve.patch new file mode 100644 index 000000000..166198d1a --- /dev/null +++ b/tur/tor-browser/0025-disable-native-https-dns-resolve.patch @@ -0,0 +1,32 @@ +It uses `android_res_nquery`, but this function only got added in API level 29 + +--- a/netwerk/dns/nsHostResolver.cpp ++++ b/netwerk/dns/nsHostResolver.cpp +@@ -237,6 +237,8 @@ + // native HTTPS records on Win 11 for now. + sNativeHTTPSSupported = StaticPrefs::network_dns_native_https_query_win10() || + mozilla::IsWin11OrLater(); ++#elif defined(__TERMUX__) ++ sNativeHTTPSSupported = false; + #elif defined(MOZ_WIDGET_ANDROID) + // android_res_nquery only got added in API level 29 + sNativeHTTPSSupported = jni::GetAPIVersion() >= 29; +--- a/netwerk/dns/moz.build ++++ b/netwerk/dns/moz.build +@@ -59,15 +59,7 @@ + "nsEffectiveTLDService.cpp", # Excluded from UNIFIED_SOURCES due to special build flags. + ] + +-if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": +- SOURCES += ["PlatformDNSWin.cpp"] +-elif CONFIG["OS_TARGET"] == "Linux" or CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa": +- SOURCES += ["PlatformDNSUnix.cpp"] +- OS_LIBS += ["resolv"] +-elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": +- SOURCES += ["PlatformDNSAndroid.cpp"] +-else: +- DEFINES["MOZ_NO_HTTPS_IMPL"] = 1 ++DEFINES["MOZ_NO_HTTPS_IMPL"] = 1 + + UNIFIED_SOURCES += [ + "ChildDNSService.cpp", diff --git a/tur/tor-browser/0026-partially-disable-unified-builds.patch b/tur/tor-browser/0026-partially-disable-unified-builds.patch new file mode 100644 index 000000000..30a79f8b5 --- /dev/null +++ b/tur/tor-browser/0026-partially-disable-unified-builds.patch @@ -0,0 +1,11 @@ +--- a/layout/style/moz.build ++++ b/layout/style/moz.build +@@ -171,7 +171,7 @@ + "StylePreloadKind.h", + ] + +-UNIFIED_SOURCES += [ ++SOURCES += [ + "AnimationCollection.cpp", + "AttributeStyles.cpp", + "CachedInheritingStyles.cpp", diff --git a/tur/tor-browser/0027-fix-compile-with-libcxx.patch b/tur/tor-browser/0027-fix-compile-with-libcxx.patch new file mode 100644 index 000000000..a6836b498 --- /dev/null +++ b/tur/tor-browser/0027-fix-compile-with-libcxx.patch @@ -0,0 +1,11 @@ +--- a/gfx/graphite2/src/MozGrMalloc.h ++++ b/gfx/graphite2/src/MozGrMalloc.h +@@ -12,7 +12,7 @@ + + #include "mozilla/mozalloc.h" + +-#if defined(XP_LINUX) ++#if defined(XP_LINUX) && !defined(_LIBCPP_VERSION) + + #define malloc moz_xmalloc + #define calloc moz_xcalloc diff --git a/tur/tor-browser/build.sh b/tur/tor-browser/build.sh new file mode 100644 index 000000000..61d22ba18 --- /dev/null +++ b/tur/tor-browser/build.sh @@ -0,0 +1,112 @@ +TERMUX_PKG_HOMEPAGE=https://www.torproject.org/ +TERMUX_PKG_DESCRIPTION="Tor Browser Bundle: anonymous browsing using Firefox and Tor" +TERMUX_PKG_LICENSE="MPL-2.0" +TERMUX_PKG_MAINTAINER="@termux" +TERMUX_PKG_VERSION="128.2.0esr-14.0-1-build3" +TERMUX_PKG_SRCURL=git+https://gitlab.torproject.org/tpo/applications/tor-browser +# ffmpeg and pulseaudio are dependencies through dlopen(3): +TERMUX_PKG_DEPENDS="ffmpeg, fontconfig, freetype, gdk-pixbuf, glib, gtk3, libandroid-shmem, libandroid-spawn, libc++, libcairo, libevent, libffi, libice, libicu, libjpeg-turbo, libnspr, libnss, libpixman, libsm, libvpx, libwebp, libx11, libxcb, libxcomposite, libxdamage, libxext, libxfixes, libxrandr, libxtst, pango, pulseaudio, tor, zlib" +TERMUX_PKG_BUILD_DEPENDS="libcpufeatures, libice, libsm" +TERMUX_PKG_BUILD_IN_SRC=true +TERMUX_PKG_AUTO_UPDATE=true +TERMUX_PKG_GIT_BRANCH="tor-browser-$TERMUX_PKG_VERSION" +TERMUX_PKG_UPDATE_TAG_TYPE="newest-tag" + +termux_step_post_get_source() { + local f="media/ffvpx/config_unix_aarch64.h" + echo "Applying sed substitution to ${f}" + sed -E '/^#define (CONFIG_LINUX_PERF|HAVE_SYSCTL) /s/1$/0/' -i ${f} +} + +termux_step_pre_configure() { + # XXX: flang toolchain provides libclang.so + termux_setup_flang + local __fc_dir="$(dirname $(command -v $FC))" + local __flang_toolchain_folder="$(realpath "$__fc_dir"/..)" + if [ ! -d "$TERMUX_PKG_TMPDIR/firefox-toolchain" ]; then + rm -rf "$TERMUX_PKG_TMPDIR"/firefox-toolchain-tmp + mv "$__flang_toolchain_folder" "$TERMUX_PKG_TMPDIR"/firefox-toolchain-tmp + + cp "$(command -v "$CC")" "$TERMUX_PKG_TMPDIR"/firefox-toolchain-tmp/bin/ + cp "$(command -v "$CXX")" "$TERMUX_PKG_TMPDIR"/firefox-toolchain-tmp/bin/ + cp "$(command -v "$CPP")" "$TERMUX_PKG_TMPDIR"/firefox-toolchain-tmp/bin/ + + mv "$TERMUX_PKG_TMPDIR"/firefox-toolchain-tmp "$TERMUX_PKG_TMPDIR"/firefox-toolchain + fi + export PATH="$TERMUX_PKG_TMPDIR/firefox-toolchain/bin:$PATH" + + termux_setup_nodejs + termux_setup_rust + + # https://github.com/rust-lang/rust/issues/49853 + # https://github.com/rust-lang/rust/issues/45854 + # Out of memory when building gkrust + # CI shows (signal: 9, SIGKILL: kill) + if [ "$TERMUX_DEBUG_BUILD" = false ]; then + case "${TERMUX_ARCH}" in + aarch64|arm|i686|x86_64) RUSTFLAGS+=" -C debuginfo=1" ;; + esac + fi + + cargo install cbindgen + + export HOST_CC=$(command -v clang) + export HOST_CXX=$(command -v clang++) + + export BINDGEN_CFLAGS="--target=$CCTERMUX_HOST_PLATFORM --sysroot=$TERMUX_PKG_TMPDIR/firefox-toolchain/sysroot" + local env_name=BINDGEN_EXTRA_CLANG_ARGS_${CARGO_TARGET_NAME@U} + env_name=${env_name//-/_} + export $env_name="$BINDGEN_CFLAGS" + + # https://reviews.llvm.org/D141184 + CXXFLAGS+=" -U__ANDROID__ -D_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC" + LDFLAGS+=" -landroid-shmem -landroid-spawn -llog" + + if [ "$TERMUX_ARCH" = "arm" ]; then + # For symbol android_getCpuFeatures + LDFLAGS+=" -l:libndk_compat.a" + fi +} + +termux_step_configure() { + if [ "$TERMUX_CONTINUE_BUILD" == "true" ]; then + termux_step_pre_configure + cd $TERMUX_PKG_SRCDIR + fi + + sed \ + -e "s|@TERMUX_HOST_PLATFORM@|${TERMUX_HOST_PLATFORM}|" \ + -e "s|@TERMUX_PREFIX@|${TERMUX_PREFIX}|" \ + -e "s|@CARGO_TARGET_NAME@|${CARGO_TARGET_NAME}|" \ + $TERMUX_PKG_BUILDER_DIR/mozconfig.cfg > .mozconfig + + if [ "$TERMUX_DEBUG_BUILD" = true ]; then + cat >>.mozconfig - < Date: Fri, 13 Sep 2024 23:17:52 +0800 Subject: [PATCH 3/4] ci: cleanup spaces for tor-browser --- .github/workflows/packages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 40f93c7fa..d6efe65aa 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -170,7 +170,7 @@ jobs: done - name: Free additional disk space (if necessary) run: | - if grep -Eq '^(chromium|code-server|code-oss|electron-headers-.*)$' ./built_tur_packages.txt; then + if grep -Eq '^(tor-browser|chromium|code-server|code-oss|electron-headers-.*)$' ./built_tur_packages.txt; then sudo apt purge -yq $(dpkg -l | grep '^ii' | awk '{ print $2 }' | grep -P '(cabal-|dotnet-|ghc-|libmono|php|aspnetcore)') \ mono-runtime-common monodoc-manual ruby sudo apt autoremove -yq From 8d0452d8994248ddf2c9e71f41b838e58bdc8892 Mon Sep 17 00:00:00 2001 From: Ronald Y Date: Wed, 18 Sep 2024 11:30:04 +0800 Subject: [PATCH 4/4] tor-browser: fix mozconfig and install components --- tur/tor-browser/build.sh | 46 ++++++++++++++++++++++++++++++++--- tur/tor-browser/mozconfig.cfg | 11 ++++++++- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/tur/tor-browser/build.sh b/tur/tor-browser/build.sh index 61d22ba18..748f9dbcd 100644 --- a/tur/tor-browser/build.sh +++ b/tur/tor-browser/build.sh @@ -2,15 +2,53 @@ TERMUX_PKG_HOMEPAGE=https://www.torproject.org/ TERMUX_PKG_DESCRIPTION="Tor Browser Bundle: anonymous browsing using Firefox and Tor" TERMUX_PKG_LICENSE="MPL-2.0" TERMUX_PKG_MAINTAINER="@termux" -TERMUX_PKG_VERSION="128.2.0esr-14.0-1-build3" +TERMUX_PKG_GIT_BRANCH="tor-browser-128.2.0esr-14.0-1-build5" +TERMUX_PKG_VERSION="14.0a5" TERMUX_PKG_SRCURL=git+https://gitlab.torproject.org/tpo/applications/tor-browser # ffmpeg and pulseaudio are dependencies through dlopen(3): TERMUX_PKG_DEPENDS="ffmpeg, fontconfig, freetype, gdk-pixbuf, glib, gtk3, libandroid-shmem, libandroid-spawn, libc++, libcairo, libevent, libffi, libice, libicu, libjpeg-turbo, libnspr, libnss, libpixman, libsm, libvpx, libwebp, libx11, libxcb, libxcomposite, libxdamage, libxext, libxfixes, libxrandr, libxtst, pango, pulseaudio, tor, zlib" TERMUX_PKG_BUILD_DEPENDS="libcpufeatures, libice, libsm" TERMUX_PKG_BUILD_IN_SRC=true -TERMUX_PKG_AUTO_UPDATE=true -TERMUX_PKG_GIT_BRANCH="tor-browser-$TERMUX_PKG_VERSION" -TERMUX_PKG_UPDATE_TAG_TYPE="newest-tag" +# TERMUX_PKG_AUTO_UPDATE=true +# TODO: termux_pkg_auto_update() to detect the appropriate TERMUX_PKG_GIT_BRANCH +# perhaps can be done by searching the directory of https://dist.torproject.org/torbrowser/$TERMUX_PKG_VERSION/ + + +# tor-browser needed components beside the firefox browser itself +# for more details, see the relationship between tor-browser and tor-browser-build +# https://gitlab.torproject.org/tpo/applications/team/-/wikis/Development-Information/Tor-Browser/Tor-Browser-Repository-Overview +# also https://gitlab.torproject.org/tpo/applications/tor-browser-build +# Here, we skip the hassle and extract directly from a release file. +termux_step_handle_host_build() { + # app logo + mkdir -p "$TERMUX_PREFIX/share/pixmaps" + cp "browser/branding/tb-release/content/about-logo.svg" "$TERMUX_PREFIX/share/pixmaps/tor-browser.svg" + # component files + local install_dir="$TERMUX_PREFIX/lib/tor-browser" + mkdir -p "$install_dir" + wget https://dist.torproject.org/torbrowser/${TERMUX_PKG_VERSION}/tor-browser-linux-x86_64-${TERMUX_PKG_VERSION}.tar.xz -O ./tor-browser-bin.tar.xz + if [[ "$(tar -tf ./tor-browser-bin.tar.xz | grep -E '^([^/]+/){2}[^/]+/$' | wc -l)" -ne 8 ]]; then + termux_error_exit "The number of folders in tor-browser has changed and please recheck the official release file. +If still in doubt, check the official tor-browser-build repo. +In particular, https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/tree/main/projects/browser." + fi + for folder in .config TorBrowser distribution fontconfig fonts icons; do + tar -C "$install_dir/" -xvf ./tor-browser-bin.tar.xz tor-browser/Browser/${folder} --strip-components=2 + done + rm ./tor-browser-bin.tar.xz + # handle architecture-dependent binaries + rm -rf "$install_dir/TorBrowser/Tor/"* + ln -s "$TERMUX_PREFIX/bin/tor" "$install_dir/TorBrowser/Tor/tor" + # TODO: TorBrowser/Tor/pluggable-transports, probably can be copied from + # https://dist.torproject.org/torbrowser/${TERMUX_PKG_VERSION}/tor-expert-bundle-android-${TERMUX_ARCH}-${TERMUX_PKG_VERSION}.tar.xz + # but not familiar how to test it, therefore not implemented. +} + + +############################## +# Firefox build script below # +# update when rebased # +############################## termux_step_post_get_source() { local f="media/ffvpx/config_unix_aarch64.h" diff --git a/tur/tor-browser/mozconfig.cfg b/tur/tor-browser/mozconfig.cfg index 7f7eeed8b..a3858162d 100644 --- a/tur/tor-browser/mozconfig.cfg +++ b/tur/tor-browser/mozconfig.cfg @@ -5,7 +5,7 @@ ac_add_options --with-sysroot=@TERMUX_PREFIX@ ac_add_options --custom-rust-target-triple=@CARGO_TARGET_NAME@ # Branding -ac_add_options --with-branding=browser/branding/official +ac_add_options --with-branding=browser/branding/tb-release # System libraries ac_add_options --enable-system-ffi @@ -43,3 +43,12 @@ ac_add_options --without-wasm-sandboxed-libraries # System addons ac_add_options --allow-addon-sideload + +# TOR +ac_add_options --disable-strip +ac_add_options --disable-install-strip + +ac_add_options --with-base-browser-version=dev-build +ac_add_options --disable-base-browser-update + +ac_add_options --with-app-name=tor-browser