summaryrefslogtreecommitdiff
path: root/standalone/android
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-24 14:10:09 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-24 14:31:43 -0400
commit502e6aa7f9a247dc45fb79b4e5d0a02c00601b29 (patch)
treee6d1f436eed245631ee7490f157d7badf8252e70 /standalone/android
parent4fdfc09edbf9ae7cfa1a3f1a03d6cd1d3e1599b9 (diff)
Explicitly run every command as a busybox app
Seems that CONFIG_FEATURE_SH_STANDALONE is not working.
Diffstat (limited to 'standalone/android')
-rw-r--r--standalone/android/busybox_config2
-rwxr-xr-xstandalone/android/runshell74
-rw-r--r--standalone/android/start.c7
3 files changed, 41 insertions, 42 deletions
diff --git a/standalone/android/busybox_config b/standalone/android/busybox_config
index 05360c0d4..28ea880d9 100644
--- a/standalone/android/busybox_config
+++ b/standalone/android/busybox_config
@@ -947,7 +947,7 @@ CONFIG_ASH_GETOPTS=y
# CONFIG_ASH_MAIL is not set
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
# CONFIG_ASH_RANDOM_SUPPORT is not set
-CONFIG_ASH_EXPAND_PRMT=y
+# CONFIG_ASH_EXPAND_PRMT is not set
CONFIG_CTTYHACK=y
# CONFIG_HUSH is not set
# CONFIG_HUSH_BASH_COMPAT is not set
diff --git a/standalone/android/runshell b/standalone/android/runshell
index 438857e9a..1211cbcba 100755
--- a/standalone/android/runshell
+++ b/standalone/android/runshell
@@ -1,70 +1,70 @@
#!/system/bin/sh
# This is runs a shell in an environment configured for git-annex.
+# Nearly the only command that can be used in here is busybox!
+# lib.start.so will run us in the root of our app directory
+base=$(./busybox pwd)
+cmd=$base/busybox
set -e
prep () {
- # lib.start.so will run us in the root of our app directory
- base="$(pwd)"
-
# Cannot rely on Android providing a sane HOME
HOME="/sdcard/git-annex.home"
export HOME
}
buildtree () {
- echo "Installation starting to $base"
- cat "$base/lib/lib.version.so"
+ $cmd echo "Installation starting to $base"
+ $cmd cat "lib/lib.version.so"
- if [ -e "$base/bin" ]; then
- mv "$base/bin" "$base/bin.old"
+ if $cmd test -e "$base/bin"; then
+ $cmd mv "$base/bin" "$base/bin.old"
fi
- mkdir -p "$base/bin"
+ $cmd mkdir -p "$base/bin"
for prog in busybox git-annex git-shell git-upload-pack git gpg rsync ssh ssh-keygen; do
- echo "installing $prog"
- if [ -e "$base/bin/$prog" ]; then
- rm "$base/bin/$prog"
+ $cmd echo "installing $prog"
+ if $cmd test -e "$base/bin/$prog"; then
+ $cmd rm "$base/bin/$prog"
fi
- ln "$base/lib/lib.$prog.so" "$base/bin/$prog"
+ $cmd ln "$base/lib/lib.$prog.so" "$base/bin/$prog"
done
- $base/bin/busybox --install $base/bin
+ $cmd --install $base/bin
- $base/bin/rm -rf "$base/bin.old"
+ $cmd rm -rf "$base/bin.old"
- cd "$base"
- $base/bin/tar zxf $base/lib/lib.git.tar.gz.so
+ $cmd tar zxf $base/lib/lib.git.tar.gz.so
for prog in git git-shell git-upload-pack; do
- for link in $(cat "$base/links/$prog"); do
- echo "linking $link to $prog"
- if [ -e "$base/$link" ]; then
- rm "$base/$link"
+ for link in $($cmd cat "$base/links/$prog"); do
+ $cmd echo "linking $link to $prog"
+ if $cmd test -e "$base/$link"; then
+ $cmd rm "$base/$link"
fi
- ln "$base/bin/$prog" "$base/$link"
+ $cmd ln "$base/bin/$prog" "$base/$link"
done
- rm "$base/links/$prog"
+ $cmd rm "$base/links/$prog"
done
- mkdir -p "$base/templates"
- mkdir -p "$base/tmp"
+ $cmd mkdir -p "$base/templates"
+ $cmd mkdir -p "$base/tmp"
- cat "$base/lib/lib.version.so" > "$base/installed-version"
- echo "Installation complete"
+ $cmd cat "$base/lib/lib.version.so" > "$base/installed-version"
+ $cmd echo "Installation complete"
}
install () {
- if [ ! -e "$base/git-annex" ]; then
- if ! mkdir -p "$HOME"; then
- echo "mkdir of $HOME failed!"
+ if $cmd test ! -e "$base/git-annex"; then
+ if ! $cmd mkdir -p "$HOME"; then
+ $cmd echo "mkdir of $HOME failed!"
fi
if ! buildtree > $HOME/git-annex-install.log 2>&1; then
- echo "Installation failed! Please report a bug and attach $HOME/git-annex-install.log"
- sh
+ $cmd echo "Installation failed! Please report a bug and attach $HOME/git-annex-install.log"
+ $cmd sh
fi
- elif [ ! -e "$base/installed-version" ] || ! cmp "$base/installed-version" "$base/lib/lib.version.so" >/dev/null; then
+ elif $cmd test ! -e "$base/installed-version" || ! $cmd cmp "$base/installed-version" "$base/lib/lib.version.so" >/dev/null; then
if ! buildtree > $HOME/git-annex-install.log 2>&1; then
- echo "Upgrade failed! Please report a bug and attach $HOME/git-annex-install.log"
+ $cmd echo "Upgrade failed! Please report a bug and attach $HOME/git-annex-install.log"
fi
fi
}
@@ -95,21 +95,21 @@ run () {
GIT_ANNEX_TMP_DIR=$base/tmp
export GIT_ANNEX_TMP_DIR
- if [ "$1" ]; then
+ if $cmd test "$1"; then
cmd="$1"
shift 1
exec "$cmd" "$@"
else
- sh
+ $cmd sh
fi
}
if ! prep; then
- echo "prep failed. Please report a bug."
+ $cmd echo "prep failed. Please report a bug."
read line
fi
if ! install; then
- echo "install failed. Please report a bug."
+ $cmd echo "install failed. Please report a bug."
read line
fi
run
diff --git a/standalone/android/start.c b/standalone/android/start.c
index 1f54ba259..95822f107 100644
--- a/standalone/android/start.c
+++ b/standalone/android/start.c
@@ -39,14 +39,13 @@ main () {
}
/* If this is the first run, set up busybox link. */
- if (stat("bin/busybox", &st_buf) != 0) {
- mkdir("bin", 0777);
- if (link("lib/lib.busybox.so", "bin/busybox") != 0) {
+ if (stat("busybox", &st_buf) != 0) {
+ if (link("lib/lib.busybox.so", "busybox") != 0) {
perror("link busybox");
exit(1);
}
}
- execl("bin/busybox", "bin/busybox", "sh", "lib/lib.runshell.so", NULL);
+ execl("./busybox", "./busybox", "sh", "lib/lib.runshell.so", NULL);
perror("error running busybox sh");
}