runshell: hacks for termux; add tip

Added some tweaks to make git-annex work in termux on Android. The regular
arm standalone tarball now works in termux.

I guess the test for "$base/bin/git" is not really necessary, since it
tests for git-annex. Since that gets deleted on android, removed that test.

These are pretty hackish hacks, especially adding it to PATH. The goal is
to make it work well enough out of the box on Android.

This commit was sponsored by Eric Drechsel on Patreon.
This commit is contained in:
Joey Hess 2018-04-25 13:47:43 -04:00
parent dd7ab91f97
commit 118ed8f92b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 90 additions and 13 deletions

View file

@ -4,6 +4,7 @@
set -e
os="$(uname -o 2>/dev/null || true)"
base="$(dirname "$0")"
if [ ! -d "$base" ]; then
@ -15,10 +16,6 @@ if [ ! -e "$base/bin/git-annex" ]; then
echo "** base directory $base does not contain bin/git-annex" >&2
exit 1
fi
if [ ! -e "$base/bin/git" ]; then
echo "** base directory $base does not contain bin/git" >&2
exit 1
fi
# Get absolute path to base, to avoid breakage when things change directories.
orig="$(pwd)"
@ -152,10 +149,36 @@ for localeenv in "$LANG" "$LANGUAGE" "$LC_CTYPE" "$LC_NUMERIC" "$LC_TIME" \
fi
done
# Indicate which variables were exported above and should be cleaned
# when running non-bundled programs.
GIT_ANNEX_STANDLONE_ENV="PATH GCONV_PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR MANPATH LOCPATH"
export GIT_ANNEX_STANDLONE_ENV
case "$os" in
# Make this bundle work well on Android.
Android)
if [ -e "$base/git" ]; then
echo "Running on Android.. Adding git-annex to PATH for you, and tuning for optimal behavior." >&2
# The bundled git does not work well on sdcard, so delete
# it and use termux's git which works better.
cd "$base"
find . | grep git | grep -v git-annex | grep -v git-remote-tor-annex | grep -v git-remote-gcrypt | xargs rm -rf
cd "$orig"
# Save the poor Android user the typing.
if ! [ -e "$HOME/.profile" ] || ! grep -q "$base" "$HOME/.profile"; then
echo 'PATH=$PATH:'"$base" >> $HOME/.profile
fi
fi
# Store ssh connection caching sockets outside of sdcard.
GIT_ANNEX_TMP_DIR="$TMPDIR"
export GIT_ANNEX_TMP_DIR
GIT_ANNEX_STANDLONE_ENV="PATH GCONV_PATH MANPATH LOCPATH"
export GIT_ANNEX_STANDLONE_ENV
;;
*)
# Indicate which variables were exported above and should be cleaned
# when running non-bundled programs.
GIT_ANNEX_STANDLONE_ENV="PATH GCONV_PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR MANPATH LOCPATH"
export GIT_ANNEX_STANDLONE_ENV
;;
esac
if [ "$1" ]; then
cmd="$1"