termux-tools: Fix the am and pm wrapper
authorFredrik Fornwall <fredrik@fornwall.net>
Tue, 22 Mar 2016 02:42:11 +0000 (22:42 -0400)
committerFredrik Fornwall <fredrik@fornwall.net>
Tue, 22 Mar 2016 02:42:11 +0000 (22:42 -0400)
packages/termux-tools/build.sh

index c1efcb2..fbb89f2 100644 (file)
@@ -1,6 +1,6 @@
 TERMUX_PKG_HOMEPAGE=http://termux.com/
 TERMUX_PKG_DESCRIPTION="Some tools for Termux"
-TERMUX_PKG_VERSION=0.18
+TERMUX_PKG_VERSION=0.19
 
 termux_step_make_install () {
        $CXX $CFLAGS $LDFLAGS -std=c++14 -Wall -Wextra -pedantic -Werror $TERMUX_PKG_BUILDER_DIR/*.cpp -o $TERMUX_PREFIX/bin/termux-elf-cleaner
@@ -8,8 +8,14 @@ termux_step_make_install () {
        # Remove LD_LIBRARY_PATH from environment to avoid conflicting
        # with system libraries that am may link against.
        for tool in am dalvikvm df logcat ping pm; do
-               echo '#!/bin/sh' > $TERMUX_PREFIX/bin/$tool
-               echo "LD_LIBRARY_PATH= exec /system/bin/$tool \$@" >> $TERMUX_PREFIX/bin/$tool
+               WRAPPER_FILE=$TERMUX_PREFIX/bin/$tool
+               echo '#!/bin/sh' > $WRAPPER_FILE
+               if [ $tool = am -o $tool = pm ]; then
+                       # These tools require having /system/bin/app_process in the PATH,
+                       # at least on a Nexus 6p running Android 6.0.
+                       echo -n 'PATH=$PATH:/system/bin ' >> $WRAPPER_FILE
+               fi
+               echo "LD_LIBRARY_PATH= exec /system/bin/$tool \$@" >> $WRAPPER_FILE
                chmod +x $TERMUX_PREFIX/bin/$tool
        done