Browse Source

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

Ensure that scripts always use correct prefix-specific path.
emacs-27
Leonid Plyushch 5 years ago
parent
commit
aba5abe17b
No known key found for this signature in database GPG Key ID: 45F2964132545795
  1. 13
      packages/termux-tools/build.sh
  2. 4
      packages/termux-tools/chsh
  3. 10
      packages/termux-tools/login
  4. 4
      packages/termux-tools/termux-fix-shebang

13
packages/termux-tools/build.sh

@ -31,10 +31,13 @@ termux_step_make_install() {
chmod +x $WRAPPER_FILE chmod +x $WRAPPER_FILE
done 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/ for script in chsh dalvikvm login pkg su termux-fix-shebang termux-info \
perl -p -i -e "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" $TERMUX_PREFIX/bin/dalvikvm 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 install -Dm600 $TERMUX_PKG_BUILDER_DIR/motd $TERMUX_PREFIX/etc/motd
cd $TERMUX_PREFIX/bin ln -sfr $TERMUX_PREFIX/bin/termux-open $TERMUX_PREFIX/bin/xdg-open
ln -s -f termux-open xdg-open
} }

4
packages/termux-tools/chsh

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

10
packages/termux-tools/login

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

4
packages/termux-tools/termux-fix-shebang

@ -3,10 +3,10 @@
if [ $# = 0 -o "$1" = "-h" ]; then if [ $# = 0 -o "$1" = "-h" ]; then
echo 'usage: termux-fix-shebang <files>' echo 'usage: termux-fix-shebang <files>'
echo 'Rewrite shebangs in specified files for running under Termux,' 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 exit 1
fi fi
for file in "$@"; do 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 done

Loading…
Cancel
Save