termux-packages/scripts/build/termux_step_patch_package.sh
Henrik Grimler ecd214881a build-package: add new arg -c for "continue build"
As replacement for TERMUX_PKG_QUICK_REBUILD. Running
./build-package.sh -c <package> starts a build for <package>, but does
not extract and patch the source from scratch. Instead it sets up the
build variables and starts from termux_step_make.

When working on a big package that can take hours to build it is
convenient to be able to build until there is an error, then apply
some new patch (manually) to the source, and then continue from where
the build failed.
2021-08-24 21:40:46 +02:00

23 lines
858 B
Bash

termux_step_patch_package() {
[ "$TERMUX_PKG_METAPACKAGE" = "true" ] && return
cd "$TERMUX_PKG_SRCDIR"
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:
shopt -s nullglob
for patch in $TERMUX_PKG_BUILDER_DIR/*.patch{$TERMUX_ARCH_BITS,} $DEBUG_PATCHES; do
echo "Applying patch: $(basename $patch)"
test -f "$patch" && sed \
-e "s%\@TERMUX_APP_PACKAGE\@%${TERMUX_APP_PACKAGE}%g" \
-e "s%\@TERMUX_BASE_DIR\@%${TERMUX_BASE_DIR}%g" \
-e "s%\@TERMUX_CACHE_DIR\@%${TERMUX_CACHE_DIR}%g" \
-e "s%\@TERMUX_HOME\@%${TERMUX_ANDROID_HOME}%g" \
-e "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" \
"$patch" | patch --silent -p1
done
shopt -u nullglob
}