termux-tools: use @TERMUX_PREFIX@ instead of path in sources

Ensure that scripts always use correct prefix-specific path.
This commit is contained in:
Leonid Pliushch 2019-09-19 23:57:17 +03:00
parent 51cdbe0073
commit ccb9ab922a
4 changed files with 17 additions and 14 deletions

View File

@ -31,10 +31,13 @@ termux_step_make_install() {
chmod +x $WRAPPER_FILE
done
cp -p $TERMUX_PKG_BUILDER_DIR/{dalvikvm,su,termux-fix-shebang,termux-reload-settings,termux-setup-storage,chsh,termux-open-url,termux-wake-lock,termux-wake-unlock,login,pkg,termux-open,termux-info} $TERMUX_PREFIX/bin/
perl -p -i -e "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" $TERMUX_PREFIX/bin/dalvikvm
for script in chsh dalvikvm login pkg su termux-fix-shebang termux-info \
termux-open termux-open-url termux-reload-settings termux-setup-storage \
termux-wake-lock termux-wake-unlock; do
install -Dm700 $TERMUX_PKG_BUILDER_DIR/$script $TERMUX_PREFIX/bin/$script
perl -p -i -e "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" $TERMUX_PREFIX/bin/$script
done
cp $TERMUX_PKG_BUILDER_DIR/motd $TERMUX_PREFIX/etc/motd
cd $TERMUX_PREFIX/bin
ln -s -f termux-open xdg-open
install -Dm600 $TERMUX_PKG_BUILDER_DIR/motd $TERMUX_PREFIX/etc/motd
ln -sfr $TERMUX_PREFIX/bin/termux-open $TERMUX_PREFIX/bin/xdg-open
}

View File

@ -13,7 +13,7 @@ set_shell () {
exit 1
fi
mkdir -p $HOME/.termux
NEW_SHELL=$PREFIX/bin/$1
NEW_SHELL=@TERMUX_PREFIX@/bin/$1
if test -x $NEW_SHELL -a ! -d $NEW_SHELL; then
ln -f -s $NEW_SHELL $HOME/.termux/shell
else
@ -33,7 +33,7 @@ while true; do
done
DEFAULT_SHELL=bash
if [ ! -x $PREFIX/bin/$DEFAULT_SHELL ]; then DEFAULT_SHELL=ash; fi
if [ ! -x @TERMUX_PREFIX@/bin/$DEFAULT_SHELL ]; then DEFAULT_SHELL=ash; fi
echo Changing the login shell
echo Enter the new value, or press ENTER for the default

View File

@ -1,7 +1,7 @@
#!/bin/sh
if [ $# = 0 ] && [ -f $PREFIX/etc/motd ] && [ ! -f ~/.hushlogin ] && [ -z "$TERMUX_HUSHLOGIN" ]; then
cat $PREFIX/etc/motd
if [ $# = 0 ] && [ -f @TERMUX_PREFIX@/etc/motd ] && [ ! -f ~/.hushlogin ] && [ -z "$TERMUX_HUSHLOGIN" ]; then
cat @TERMUX_PREFIX@/etc/motd
else
# This variable shouldn't be kept set.
unset TERMUX_HUSHLOGIN
@ -10,7 +10,7 @@ fi
if [ -G ~/.termux/shell ]; then
export SHELL="`realpath ~/.termux/shell`"
else
for file in $PREFIX/bin/bash $PREFIX/bin/sh /system/bin/sh; do
for file in @TERMUX_PREFIX@/bin/bash @TERMUX_PREFIX@/bin/sh /system/bin/sh; do
if [ -x $file ]; then
export SHELL=$file
break
@ -18,8 +18,8 @@ else
done
fi
if [ -f $PREFIX/lib/libtermux-exec.so ]; then
export LD_PRELOAD=$PREFIX/lib/libtermux-exec.so
if [ -f @TERMUX_PREFIX@/lib/libtermux-exec.so ]; then
export LD_PRELOAD=@TERMUX_PREFIX@/lib/libtermux-exec.so
$SHELL -c "busybox true" > /dev/null 2>&1 || unset LD_PRELOAD
fi

View File

@ -3,10 +3,10 @@
if [ $# = 0 -o "$1" = "-h" ]; then
echo 'usage: termux-fix-shebang <files>'
echo 'Rewrite shebangs in specified files for running under Termux,'
echo 'which is done by rewriting #!*/bin/binary to #!$PREFIX/bin/binary.'
echo 'which is done by rewriting #!*/bin/binary to #!@TERMUX_PREFIX@/bin/binary.'
exit 1
fi
for file in "$@"; do
sed -i -E "1 s@^#\!(.*)/[sx]?bin/(.*)@#\!/data/data/com.termux/files/usr/bin/\2@" "$(realpath "${file}")"
sed -i -E "1 s@^#\!(.*)/[sx]?bin/(.*)@#\!@TERMUX_PREFIX@/bin/\2@" "$(realpath "${file}")"
done