build-package.sh: introduce TERMUX_PKG_NO_SHEBANG_FIX

This variable will disable shebang fixing during massage step. Normally
such fix shouldn't be disabled, but there are packages where it causes
a huge overhead and is not needed anyway.

Packages that are known to be affected by overhead and take long time
for building:

 * papirus-icon-theme from x11-packages
This commit is contained in:
Leonid Pliushch 2021-10-25 12:47:13 +03:00
parent 44b0ebe951
commit 6572b28692
No known key found for this signature in database
GPG Key ID: 45F2964132545795
2 changed files with 8 additions and 6 deletions

View File

@ -32,12 +32,13 @@ termux_step_massage() {
find . \( -path "./bin/*" -o -path "./lib/*" -o -path "./libexec/*" -o -path "./opt/*" \) -type f -print0 | xargs -r -0 "$TERMUX_ELF_CLEANER"
fi
# Fix shebang paths:
while IFS= read -r -d '' file
do
head -c 100 "$file" | grep -E "^#\!.*\\/bin\\/.*" | grep -q -E -v "^#\! ?\\/system" && \
sed --follow-symlinks -i -E "1 s@^#\!(.*)/bin/(.*)@#\!$TERMUX_PREFIX/bin/\2@" "$file"
done < <(find -L . -type f -print0)
if [ "$TERMUX_PKG_NO_SHEBANG_FIX" != "true" ]; then
# Fix shebang paths:
while IFS= read -r -d '' file; do
head -c 100 "$file" | grep -E "^#\!.*\\/bin\\/.*" | grep -q -E -v "^#\! ?\\/system" && \
sed --follow-symlinks -i -E "1 s@^#\!(.*)/bin/(.*)@#\!$TERMUX_PREFIX/bin/\2@" "$file"
done < <(find -L . -type f -print0)
fi
# Delete the info directory file.
rm -rf ./share/info/dir

View File

@ -135,6 +135,7 @@ termux_step_setup_variables() {
TERMUX_PKG_TMPDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/tmp
TERMUX_PKG_SERVICE_SCRIPT=() # Fill with entries like: ("daemon name" 'script to execute'). Script is echoed with -e so can contain \n for multiple lines
TERMUX_PKG_GROUPS="" # https://wiki.archlinux.org/title/Pacman#Installing_package_groups
TERMUX_PKG_NO_SHEBANG_FIX=false # if true, skip fixing shebang accordingly to TERMUX_PREFIX
unset CFLAGS CPPFLAGS LDFLAGS CXXFLAGS
}