2019-02-27 19:58:17 +01:00
termux_step_massage( ) {
2019-08-14 19:29:58 +02:00
[ " $TERMUX_PKG_METAPACKAGE " = "true" ] && return
2019-02-27 19:58:17 +01:00
cd " $TERMUX_PKG_MASSAGEDIR / $TERMUX_PREFIX "
# Remove lib/charset.alias which is installed by gettext-using packages:
rm -f lib/charset.alias
# Remove locale files we're not interested in::
rm -Rf share/locale
# Remove old kept libraries (readline):
2019-08-06 14:39:42 +02:00
find . -name '*.old' -print0 | xargs -0 -r rm -f
2019-02-27 19:58:17 +01:00
# Move over sbin to bin:
for file in sbin/*; do if test -f " $file " ; then mv " $file " bin/; fi ; done
2019-08-06 14:39:42 +02:00
# Remove world permissions and make sure that user still have read-write permissions.
chmod -Rf u+rw,g-rwx,o-rwx . || true
2019-02-27 19:58:17 +01:00
2021-08-21 16:50:05 +02:00
if [ " $TERMUX_DEBUG_BUILD " = "false" ] ; then
2019-02-27 19:58:17 +01:00
# Strip binaries. file(1) may fail for certain unusual files, so disable pipefail.
set +e +o pipefail
2022-03-22 21:07:57 +01:00
find . \( -path "./bin/*" -o -path "./lib/*" -o -path "./libexec/*" \) -type f |
xargs -r file | grep -E "ELF .+ (executable|shared object)" | cut -f 1 -d : |
xargs -r " $STRIP " --strip-unneeded --preserve-dates
2019-02-27 19:58:17 +01:00
set -e -o pipefail
fi
2019-08-06 14:39:42 +02:00
2020-10-01 18:33:58 +02:00
if [ " $TERMUX_PKG_NO_ELF_CLEANER " != "true" ] ; then
# Remove entries unsupported by Android's linker:
2021-07-29 21:38:21 +02:00
find . \( -path "./bin/*" -o -path "./lib/*" -o -path "./libexec/*" -o -path "./opt/*" \) -type f -print0 | xargs -r -0 " $TERMUX_ELF_CLEANER "
2020-10-01 18:33:58 +02:00
fi
2019-02-27 19:58:17 +01:00
2021-10-25 11:47:13 +02:00
if [ " $TERMUX_PKG_NO_SHEBANG_FIX " != "true" ] ; then
# Fix shebang paths:
while IFS = read -r -d '' file; do
2022-03-22 21:07:57 +01:00
head -c 100 " $file " | grep -E "^#\!.*\\/bin\\/.*" | grep -q -E -v "^#\! ?\\/system" &&
2021-10-25 11:47:13 +02:00
sed --follow-symlinks -i -E " 1 s@^#\!(.*)/bin/(.*)@#\! $TERMUX_PREFIX /bin/\2@ " " $file "
done < <( find -L . -type f -print0)
fi
2019-02-27 19:58:17 +01:00
2020-07-07 18:22:00 +02:00
# Delete the info directory file.
rm -rf ./share/info/dir
2021-03-01 23:17:36 +01:00
# Mostly specific to X11-related packages.
rm -f ./share/icons/hicolor/icon-theme.cache
2019-02-27 19:58:17 +01:00
test ! -z " $TERMUX_PKG_RM_AFTER_INSTALL " && rm -Rf $TERMUX_PKG_RM_AFTER_INSTALL
find . -type d -empty -delete # Remove empty directories
if [ -d share/man ] ; then
2019-08-06 14:39:42 +02:00
# Remove non-english man pages:
find share/man -mindepth 1 -maxdepth 1 -type d ! -name man\* | xargs -r rm -rf
2019-02-27 19:58:17 +01:00
# Compress man pages with gzip:
2019-04-09 16:45:43 +02:00
find share/man -type f ! -iname \* .gz -print0 | xargs -r -0 gzip
2019-02-27 19:58:17 +01:00
# Update man page symlinks, e.g. unzstd.1 -> zstd.1:
2022-03-22 21:07:57 +01:00
while IFS = read -r -d '' file; do
2019-02-27 19:58:17 +01:00
local _link_value
_link_value = $( readlink $file )
rm $file
ln -s $_link_value .gz $file .gz
2019-04-09 16:45:43 +02:00
done < <( find share/man -type l ! -iname \* .gz -print0)
2019-02-27 19:58:17 +01:00
fi
2021-05-16 18:55:31 +02:00
# Check so files were actually installed. Exclude
# share/doc/$TERMUX_PKG_NAME/ as a license file is always
# installed there.
if [ " $( find . -type f -not -path " ./share/doc/ $TERMUX_PKG_NAME /* " ) " = "" ] ; then
termux_error_exit "No files in package. Maybe you need to run autoreconf -fi before configuring?"
fi
local HARDLINKS
HARDLINKS = " $( find . -type f -links +1) "
if [ -n " $HARDLINKS " ] ; then
termux_error_exit " Package contains hard links: $HARDLINKS "
fi
2022-04-02 10:26:26 +02:00
# Check so that package is not affected by https://github.com/android/ndk/issues/1614
2022-04-06 06:25:05 +02:00
SYMBOLS = " $( readelf -s $( $TERMUX_HOST_PLATFORM -clang -print-libgcc-file-name) | grep "FUNC GLOBAL HIDDEN" | awk '{print $8}' ) "
2022-04-10 04:31:03 +02:00
# Also check for unresolved symbols defined in libandroid-* (#9944)
SYMBOLS += " $( echo libandroid_{ sem_{ open,close,unlink} ,shm{ ctl,get,at,dt} } ) "
2022-04-05 21:21:29 +02:00
LIBRARIES = ""
if [ -d "lib" ] ; then
LIBRARIES = " $( find lib -name "*.so" ) "
fi
2022-04-02 10:26:26 +02:00
for lib in $LIBRARIES ; do
for sym in $SYMBOLS ; do
if ! readelf -h $lib & > /dev/null; then
continue
fi
if readelf -s $lib | egrep 'NOTYPE[[:space:]]+GLOBAL[[:space:]]+DEFAULT[[:space:]]+UND[[:space:]]+' $sym '$' & > /dev/null; then
termux_error_exit " $lib contains undefined symbol $sym "
fi
done
done
2021-09-10 18:10:02 +02:00
if [ " $TERMUX_PACKAGE_FORMAT " = "debian" ] ; then
termux_create_debian_subpackages
elif [ " $TERMUX_PACKAGE_FORMAT " = "pacman" ] ; then
termux_create_pacman_subpackages
fi
2019-02-27 19:58:17 +01:00
2022-03-09 19:56:10 +01:00
# Remove unnecessary files in haskell pacakges:
2022-03-22 21:07:57 +01:00
if [ [ " ${ TERMUX_PKG_NAME } " != "ghc-libs" ] ] && [ [ " ${ TERMUX_PKG_NAME } " != "ghc" ] ] ; then
test -d ./lib/ghc-* && rm -rf ./lib/ghc-* 2>/dev/null # Remove full ghc-* dir since cross compiler installs packages in "./lib/${TERMUX_ARCH}-android-ghc-X.Y.Z"
fi
2022-03-09 19:56:10 +01:00
2019-02-27 19:58:17 +01:00
# .. remove empty directories (NOTE: keep this last):
find . -type d -empty -delete
}