Browse Source

Modify setup in wrappers for /system/bin/ commands

On several devices several tools in /system/bin/ requires
LD_LIBRARY_PATH to contain /system/lib(64). Check for the bit-ness
with `getprop ro.product.cpu.abilist64`  and setup the environment
accordingly.

Closes #193.
Closes #206.
android-5
Fredrik Fornwall 9 years ago
parent
commit
8353c56c0b
  1. 2
      packages/jack/build.sh
  2. 9
      packages/jack/jack.sh
  3. 2
      packages/termux-api/build.sh
  4. 11
      packages/termux-api/termux-api.c
  5. 20
      packages/termux-tools/build.sh
  6. 2
      packages/termux-tools/termux-reload-settings
  7. 2
      packages/termux-tools/termux-setup-storage

2
packages/jack/build.sh

@ -4,7 +4,7 @@
TERMUX_PKG_HOMEPAGE=http://tools.android.com/tech-docs/jackandjill TERMUX_PKG_HOMEPAGE=http://tools.android.com/tech-docs/jackandjill
TERMUX_PKG_DESCRIPTION="Java Android Compiler Kit" TERMUX_PKG_DESCRIPTION="Java Android Compiler Kit"
TERMUX_PKG_VERSION="1.1-mr2" TERMUX_PKG_VERSION="1.1-mr2"
TERMUX_PKG_BUILD_REVISION=2 TERMUX_PKG_BUILD_REVISION=3
TERMUX_PKG_PLATFORM_INDEPENDENT=true TERMUX_PKG_PLATFORM_INDEPENDENT=true
termux_step_make () { termux_step_make () {

9
packages/jack/jack.sh

@ -4,15 +4,6 @@
export ANDROID_DATA=@TERMUX_PREFIX@/var/android/ export ANDROID_DATA=@TERMUX_PREFIX@/var/android/
mkdir -p $ANDROID_DATA/dalvik-cache mkdir -p $ANDROID_DATA/dalvik-cache
# Find the right lib folder for dalvikvm. We cannot take LD_LIBRARY_PATH
# as is since it contains Termux-supplied libraries which may clash with
# system ones.
LIBFOLDER=/system/lib
if test -d /system/lib64; then
LIBFOLDER=/system/lib64
fi
LD_LIBRARY_PATH=$LIBFOLDER \
exec dalvikvm -Xmx256m \ exec dalvikvm -Xmx256m \
-Djava.io.tmpdir=@TERMUX_PREFIX@/tmp \ -Djava.io.tmpdir=@TERMUX_PREFIX@/tmp \
-cp @TERMUX_PREFIX@/share/dex/jack.jar com.android.jack.Main \ -cp @TERMUX_PREFIX@/share/dex/jack.jar com.android.jack.Main \

2
packages/termux-api/build.sh

@ -1,6 +1,6 @@
TERMUX_PKG_HOMEPAGE=http://termux.com/add-ons/api/ TERMUX_PKG_HOMEPAGE=http://termux.com/add-ons/api/
TERMUX_PKG_DESCRIPTION="Termux API commands" TERMUX_PKG_DESCRIPTION="Termux API commands"
TERMUX_PKG_VERSION=0.13 TERMUX_PKG_VERSION=0.14
termux_step_make_install () { termux_step_make_install () {
mkdir -p $TERMUX_PREFIX/bin mkdir -p $TERMUX_PREFIX/bin

11
packages/termux-api/termux-api.c

@ -32,12 +32,6 @@ void exec_am_broadcast(int argc, char** argv, char* input_address_string, char*
// Close stdin: // Close stdin:
close(STDIN_FILENO); close(STDIN_FILENO);
char const* const file = "/system/bin/am";
// Avoid the system am binary from linking to wrong libraries:
unsetenv("LD_LIBRARY_PATH");
// Ensure /system/bin/app_process is in path, which is needed by am in some systems:
putenv("PATH=/system/bin");
// The user is calculated from the uid in android.os.UserHandle#getUserId(int uid) as "uid / 100000", so we do the same: // The user is calculated from the uid in android.os.UserHandle#getUserId(int uid) as "uid / 100000", so we do the same:
uid_t current_uid = getuid(); uid_t current_uid = getuid();
int android_user_id = current_uid / 100000; int android_user_id = current_uid / 100000;
@ -73,7 +67,10 @@ void exec_am_broadcast(int argc, char** argv, char* input_address_string, char*
// End with NULL: // End with NULL:
child_argv[argc + extra_args] = NULL; child_argv[argc + extra_args] = NULL;
execv(file, child_argv); // Use an a executable taking care of PATH and LD_LIBRARY_PATH:
char const* const am_executable = "/data/data/com.termux/files/usr/bin/am";
execv(am_executable, child_argv);
perror("execv(\"/system/bin/am\")"); perror("execv(\"/system/bin/am\")");
exit(1); exit(1);
} }

20
packages/termux-tools/build.sh

@ -1,21 +1,27 @@
TERMUX_PKG_HOMEPAGE=http://termux.com/ TERMUX_PKG_HOMEPAGE=http://termux.com/
TERMUX_PKG_DESCRIPTION="Some tools for Termux" TERMUX_PKG_DESCRIPTION="Some tools for Termux"
TERMUX_PKG_VERSION=0.24 TERMUX_PKG_VERSION=0.25
termux_step_make_install () { 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 $CXX $CFLAGS $LDFLAGS -std=c++14 -Wall -Wextra -pedantic -Werror $TERMUX_PKG_BUILDER_DIR/*.cpp -o $TERMUX_PREFIX/bin/termux-elf-cleaner
# Remove LD_LIBRARY_PATH from environment to avoid conflicting # Remove LD_LIBRARY_PATH from environment to avoid conflicting
# with system libraries that am may link against. # with system libraries that am may link against.
for tool in am dalvikvm df getprop logcat ping ping6 ip pm; do for tool in am dalvikvm df getprop logcat ping ping6 ip pm settings; do
WRAPPER_FILE=$TERMUX_PREFIX/bin/$tool WRAPPER_FILE=$TERMUX_PREFIX/bin/$tool
echo '#!/bin/sh' > $WRAPPER_FILE echo '#!/bin/sh' > $WRAPPER_FILE
if [ $tool = am -o $tool = pm ]; then
# These tools require having /system/bin/app_process in the PATH, # Some of these tools (am,dalvikvm,?) requires LD_LIBRARY_PATH setup on at least some devices:
# at least on a Nexus 6p running Android 6.0. if [ $tool != getprop ]; then
echo -n 'PATH=$PATH:/system/bin ' >> $WRAPPER_FILE echo 'if [ -n "`getprop ro.product.cpu.abilist64`" ]; then BITS=64; else BITS=; fi' >> $WRAPPER_FILE
echo -n 'LD_LIBRARY_PATH=/system/lib$BITS ' >> $WRAPPER_FILE
fi fi
echo "LD_LIBRARY_PATH= exec /system/bin/$tool \$@" >> $WRAPPER_FILE
# Some tools require having /system/bin/app_process in the PATH,
# at least am&pm on a Nexus 6p running Android 6.0:
echo -n 'PATH=$PATH:/system/bin ' >> $WRAPPER_FILE
echo "exec /system/bin/$tool \$@" >> $WRAPPER_FILE
chmod +x $TERMUX_PREFIX/bin/$tool chmod +x $TERMUX_PREFIX/bin/$tool
done done

2
packages/termux-tools/termux-reload-settings

@ -9,4 +9,4 @@ if [ "$#" != "0" ]; then
exit exit
fi fi
LD_LIBRARY_PATH= am broadcast --user 0 -a com.termux.app.reload_style com.termux > /dev/null am broadcast --user 0 -a com.termux.app.reload_style com.termux > /dev/null

2
packages/termux-tools/termux-setup-storage

@ -7,6 +7,6 @@ if [ "$#" != "0" ]; then
exit exit
fi fi
LD_LIBRARY_PATH= am broadcast --user 0 \ am broadcast --user 0 \
--es com.termux.app.reload_style storage \ --es com.termux.app.reload_style storage \
-a com.termux.app.reload_style com.termux > /dev/null -a com.termux.app.reload_style com.termux > /dev/null

Loading…
Cancel
Save