From 32c67fa030ed8df08aee3c5b4f6b3499a07fd9d3 Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Wed, 1 Sep 2021 11:05:30 +0200 Subject: [PATCH] termux_step_patch_package: add support for on device patches Name a patch *.patch.ondevice for it to only be applied when building on device. This can be useful if for example a tool for building documentation is missing on device, or if a tool needed during build (but not runtime) uses something that triggers selinux, fdsan or some other android security thing. --- scripts/build/termux_step_patch_package.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/build/termux_step_patch_package.sh b/scripts/build/termux_step_patch_package.sh index 43aa4f072..0716b59b3 100644 --- a/scripts/build/termux_step_patch_package.sh +++ b/scripts/build/termux_step_patch_package.sh @@ -2,13 +2,22 @@ termux_step_patch_package() { [ "$TERMUX_PKG_METAPACKAGE" = "true" ] && return cd "$TERMUX_PKG_SRCDIR" + # Suffix patch with ".patch32" or ".patch64" to only apply for + # these bitnesses + local PATCHES=$(find $TERMUX_PKG_BUILDER_DIR -mindepth 1 -maxdepth 1 \ + -name \*.patch -o -name \*.patch$TERMUX_ARCH_BITS) local DEBUG_PATCHES="" if [ "$TERMUX_DEBUG_BUILD" = "true" ]; then DEBUG_PATCHES=$(find $TERMUX_PKG_BUILDER_DIR -mindepth 1 -maxdepth 1 -name \*.patch.debug) fi - # Suffix patch with ".patch32" or ".patch64" to only apply for these bitnesses: + local ON_DEVICE_PATCHES="" + # .patch.ondevice patches should only be applied when building + # on device + if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then + ON_DEVICE_PATCHES=$(find $TERMUX_PKG_BUILDER_DIR -mindepth 1 -maxdepth 1 -name \*.patch.ondevice) + fi shopt -s nullglob - for patch in $TERMUX_PKG_BUILDER_DIR/*.patch{$TERMUX_ARCH_BITS,} $DEBUG_PATCHES; do + for patch in $PATCHES $DEBUG_PATCHES $ON_DEVICE_PATCHES; do echo "Applying patch: $(basename $patch)" test -f "$patch" && sed \ -e "s%\@TERMUX_APP_PACKAGE\@%${TERMUX_APP_PACKAGE}%g" \