summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-13 13:32:15 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-13 13:32:15 -0400
commitfeb7bd78d2865f7cbdf2d235b71194818ffce0eb (patch)
treea0631a5644d4acfbb443038811cb63d792bd44b1
parentc84f724875c78df53fbbd92a51c1245a8a9a31ff (diff)
runshell for Android
-rwxr-xr-xstandalone/android/runshell61
1 files changed, 61 insertions, 0 deletions
diff --git a/standalone/android/runshell b/standalone/android/runshell
new file mode 100755
index 000000000..32d0479a4
--- /dev/null
+++ b/standalone/android/runshell
@@ -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