Explicitly run every command as a busybox app

Seems that CONFIG_FEATURE_SH_STANDALONE is not working.
This commit is contained in:
Joey Hess 2013-02-24 14:10:09 -04:00
parent 7711ce5b13
commit 61a12ce47f
3 changed files with 41 additions and 42 deletions

View file

@ -947,7 +947,7 @@ CONFIG_ASH_GETOPTS=y
# CONFIG_ASH_MAIL is not set # CONFIG_ASH_MAIL is not set
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set # CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
# CONFIG_ASH_RANDOM_SUPPORT 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_CTTYHACK=y
# CONFIG_HUSH is not set # CONFIG_HUSH is not set
# CONFIG_HUSH_BASH_COMPAT is not set # CONFIG_HUSH_BASH_COMPAT is not set

View file

@ -1,70 +1,70 @@
#!/system/bin/sh #!/system/bin/sh
# This is runs a shell in an environment configured for git-annex. # 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 set -e
prep () { prep () {
# lib.start.so will run us in the root of our app directory
base="$(pwd)"
# Cannot rely on Android providing a sane HOME # Cannot rely on Android providing a sane HOME
HOME="/sdcard/git-annex.home" HOME="/sdcard/git-annex.home"
export HOME export HOME
} }
buildtree () { buildtree () {
echo "Installation starting to $base" $cmd echo "Installation starting to $base"
cat "$base/lib/lib.version.so" $cmd cat "lib/lib.version.so"
if [ -e "$base/bin" ]; then if $cmd test -e "$base/bin"; then
mv "$base/bin" "$base/bin.old" $cmd mv "$base/bin" "$base/bin.old"
fi 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 for prog in busybox git-annex git-shell git-upload-pack git gpg rsync ssh ssh-keygen; do
echo "installing $prog" $cmd echo "installing $prog"
if [ -e "$base/bin/$prog" ]; then if $cmd test -e "$base/bin/$prog"; then
rm "$base/bin/$prog" $cmd rm "$base/bin/$prog"
fi fi
ln "$base/lib/lib.$prog.so" "$base/bin/$prog" $cmd ln "$base/lib/lib.$prog.so" "$base/bin/$prog"
done 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" $cmd tar zxf $base/lib/lib.git.tar.gz.so
$base/bin/tar zxf $base/lib/lib.git.tar.gz.so
for prog in git git-shell git-upload-pack; do for prog in git git-shell git-upload-pack; do
for link in $(cat "$base/links/$prog"); do for link in $($cmd cat "$base/links/$prog"); do
echo "linking $link to $prog" $cmd echo "linking $link to $prog"
if [ -e "$base/$link" ]; then if $cmd test -e "$base/$link"; then
rm "$base/$link" $cmd rm "$base/$link"
fi fi
ln "$base/bin/$prog" "$base/$link" $cmd ln "$base/bin/$prog" "$base/$link"
done done
rm "$base/links/$prog" $cmd rm "$base/links/$prog"
done done
mkdir -p "$base/templates" $cmd mkdir -p "$base/templates"
mkdir -p "$base/tmp" $cmd mkdir -p "$base/tmp"
cat "$base/lib/lib.version.so" > "$base/installed-version" $cmd cat "$base/lib/lib.version.so" > "$base/installed-version"
echo "Installation complete" $cmd echo "Installation complete"
} }
install () { install () {
if [ ! -e "$base/git-annex" ]; then if $cmd test ! -e "$base/git-annex"; then
if ! mkdir -p "$HOME"; then if ! $cmd mkdir -p "$HOME"; then
echo "mkdir of $HOME failed!" $cmd echo "mkdir of $HOME failed!"
fi fi
if ! buildtree > $HOME/git-annex-install.log 2>&1; then if ! buildtree > $HOME/git-annex-install.log 2>&1; then
echo "Installation failed! Please report a bug and attach $HOME/git-annex-install.log" $cmd echo "Installation failed! Please report a bug and attach $HOME/git-annex-install.log"
sh $cmd sh
fi 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 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
fi fi
} }
@ -95,21 +95,21 @@ run () {
GIT_ANNEX_TMP_DIR=$base/tmp GIT_ANNEX_TMP_DIR=$base/tmp
export GIT_ANNEX_TMP_DIR export GIT_ANNEX_TMP_DIR
if [ "$1" ]; then if $cmd test "$1"; then
cmd="$1" cmd="$1"
shift 1 shift 1
exec "$cmd" "$@" exec "$cmd" "$@"
else else
sh $cmd sh
fi fi
} }
if ! prep; then if ! prep; then
echo "prep failed. Please report a bug." $cmd echo "prep failed. Please report a bug."
read line read line
fi fi
if ! install; then if ! install; then
echo "install failed. Please report a bug." $cmd echo "install failed. Please report a bug."
read line read line
fi fi
run run

View file

@ -39,14 +39,13 @@ main () {
} }
/* If this is the first run, set up busybox link. */ /* If this is the first run, set up busybox link. */
if (stat("bin/busybox", &st_buf) != 0) { if (stat("busybox", &st_buf) != 0) {
mkdir("bin", 0777); if (link("lib/lib.busybox.so", "busybox") != 0) {
if (link("lib/lib.busybox.so", "bin/busybox") != 0) {
perror("link busybox"); perror("link busybox");
exit(1); 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"); perror("error running busybox sh");
} }