runshell for Android
This commit is contained in:
parent
f2cb275513
commit
2633c704bb
1 changed files with 61 additions and 0 deletions
61
standalone/android/runshell
Executable file
61
standalone/android/runshell
Executable file
|
@ -0,0 +1,61 @@
|
||||||
|
#!/system/bin/sh
|
||||||
|
# Runs a shell command (or interactive shell) using the binaries and
|
||||||
|
# libraries bundled with this app.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
base="$(dirname $0)"
|
||||||
|
|
||||||
|
if [ ! -d "$base" ]; then
|
||||||
|
echo "** cannot find base directory (I seem to be $0)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# Install busybox links.
|
||||||
|
if [ ! -e "$base/bin/sh" ]; then
|
||||||
|
"$base/bin/busybox" --install "$base/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get absolute path to base, to avoid breakage when things change directories.
|
||||||
|
orig="$(pwd)"
|
||||||
|
cd "$base"
|
||||||
|
base="$(pwd)"
|
||||||
|
cd "$orig"
|
||||||
|
|
||||||
|
# Put our binaries first, to avoid issues with out of date or incompatable
|
||||||
|
# system binaries.
|
||||||
|
ORIG_PATH="$PATH"
|
||||||
|
export ORIG_PATH
|
||||||
|
PATH=$base/bin:$PATH
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
ORIG_GIT_EXEC_PATH="$GIT_EXEC_PATH"
|
||||||
|
export ORIG_GIT_EXEC_PATH
|
||||||
|
GIT_EXEC_PATH=$base/libexec/git-core
|
||||||
|
export GIT_EXEC_PATH
|
||||||
|
|
||||||
|
ORIG_GIT_TEMPLATE_DIR="$GIT_TEMPLATE_DIR"
|
||||||
|
export ORIG_GIT_TEMPLATE_DIR
|
||||||
|
GIT_TEMPLATE_DIR="$base/templates"
|
||||||
|
export GIT_TEMPLATE_DIR
|
||||||
|
|
||||||
|
# Indicate which variables were exported above.
|
||||||
|
GIT_ANNEX_STANDLONE_ENV="PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR"
|
||||||
|
export GIT_ANNEX_STANDLONE_ENV
|
||||||
|
|
||||||
|
if [ "$1" ]; then
|
||||||
|
cmd="$1"
|
||||||
|
shift 1
|
||||||
|
exec "$cmd" "$@"
|
||||||
|
else
|
||||||
|
sh
|
||||||
|
fi
|
Loading…
Add table
Add a link
Reference in a new issue