2013-02-13 17:32:15 +00:00
|
|
|
#!/system/bin/sh
|
2013-02-24 17:25:55 +00:00
|
|
|
# This is runs a shell in an environment configured for git-annex.
|
2013-02-24 18:10:09 +00:00
|
|
|
# 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
|
2013-02-13 17:32:15 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2013-02-23 05:08:15 +00:00
|
|
|
prep () {
|
|
|
|
# Cannot rely on Android providing a sane HOME
|
|
|
|
HOME="/sdcard/git-annex.home"
|
|
|
|
export HOME
|
|
|
|
}
|
2013-02-13 17:32:15 +00:00
|
|
|
|
2013-02-23 05:08:15 +00:00
|
|
|
buildtree () {
|
2013-02-24 18:10:09 +00:00
|
|
|
$cmd echo "Installation starting to $base"
|
|
|
|
$cmd cat "lib/lib.version.so"
|
2013-02-22 19:03:12 +00:00
|
|
|
|
2013-02-24 18:10:09 +00:00
|
|
|
if $cmd test -e "$base/bin"; then
|
|
|
|
$cmd mv "$base/bin" "$base/bin.old"
|
2013-02-22 20:20:41 +00:00
|
|
|
fi
|
2013-02-24 18:10:09 +00:00
|
|
|
$cmd mkdir -p "$base/bin"
|
2013-02-22 20:20:41 +00:00
|
|
|
|
2013-02-21 20:03:00 +00:00
|
|
|
for prog in busybox git-annex git-shell git-upload-pack git gpg rsync ssh ssh-keygen; do
|
2013-02-24 18:10:09 +00:00
|
|
|
$cmd echo "installing $prog"
|
|
|
|
if $cmd test -e "$base/bin/$prog"; then
|
2013-02-28 23:18:56 +00:00
|
|
|
$cmd rm -f "$base/bin/$prog"
|
2013-02-22 19:49:11 +00:00
|
|
|
fi
|
2013-05-23 17:54:49 +00:00
|
|
|
$cmd ln -s "$base/lib/lib.$prog.so" "$base/bin/$prog"
|
2013-02-21 16:47:16 +00:00
|
|
|
done
|
2013-02-13 17:32:15 +00:00
|
|
|
|
2013-02-24 18:10:09 +00:00
|
|
|
$cmd --install $base/bin
|
2013-02-22 19:03:12 +00:00
|
|
|
|
2013-02-24 18:10:09 +00:00
|
|
|
$cmd rm -rf "$base/bin.old"
|
2013-02-22 20:20:41 +00:00
|
|
|
|
2013-02-24 18:10:09 +00:00
|
|
|
$cmd tar zxf $base/lib/lib.git.tar.gz.so
|
2013-02-21 16:47:16 +00:00
|
|
|
for prog in git git-shell git-upload-pack; do
|
2013-02-24 18:10:09 +00:00
|
|
|
for link in $($cmd cat "$base/links/$prog"); do
|
|
|
|
$cmd echo "linking $link to $prog"
|
|
|
|
if $cmd test -e "$base/$link"; then
|
2013-02-28 23:18:56 +00:00
|
|
|
$cmd rm -f "$base/$link"
|
2013-02-22 19:49:11 +00:00
|
|
|
fi
|
2013-05-23 17:54:49 +00:00
|
|
|
$cmd ln -s "$base/bin/$prog" "$base/$link"
|
2013-02-21 16:47:16 +00:00
|
|
|
done
|
2013-02-28 23:18:56 +00:00
|
|
|
$cmd rm -f "$base/links/$prog"
|
2013-02-21 16:47:16 +00:00
|
|
|
done
|
2013-02-13 17:32:15 +00:00
|
|
|
|
2013-02-24 18:10:09 +00:00
|
|
|
$cmd mkdir -p "$base/templates"
|
|
|
|
$cmd mkdir -p "$base/tmp"
|
2013-02-22 19:03:12 +00:00
|
|
|
|
2013-05-03 17:17:01 +00:00
|
|
|
$cmd echo "#!/system/bin/sh" > "$base/runshell"
|
|
|
|
$cmd echo "exec $base/lib/lib.start.so" >> "$base/runshell"
|
|
|
|
$cmd chmod 755 runshell
|
2013-05-02 05:43:22 +00:00
|
|
|
|
2013-02-24 18:10:09 +00:00
|
|
|
$cmd cat "$base/lib/lib.version.so" > "$base/installed-version"
|
|
|
|
$cmd echo "Installation complete"
|
2013-02-21 16:47:16 +00:00
|
|
|
}
|
|
|
|
|
2013-02-23 05:08:15 +00:00
|
|
|
install () {
|
2013-05-03 18:08:26 +00:00
|
|
|
if ! $cmd mkdir -p "$HOME"; then
|
|
|
|
$cmd echo "mkdir of $HOME failed!"
|
|
|
|
fi
|
2013-02-28 23:12:54 +00:00
|
|
|
if $cmd test ! -e "$base/bin/git-annex"; then
|
2013-02-23 05:08:15 +00:00
|
|
|
if ! buildtree > $HOME/git-annex-install.log 2>&1; then
|
2013-02-24 18:10:09 +00:00
|
|
|
$cmd echo "Installation failed! Please report a bug and attach $HOME/git-annex-install.log"
|
|
|
|
$cmd sh
|
2013-02-23 05:08:15 +00:00
|
|
|
fi
|
2013-02-24 18:10:09 +00:00
|
|
|
elif $cmd test ! -e "$base/installed-version" || ! $cmd cmp "$base/installed-version" "$base/lib/lib.version.so" >/dev/null; then
|
2013-02-23 05:08:15 +00:00
|
|
|
if ! buildtree > $HOME/git-annex-install.log 2>&1; then
|
2013-02-24 18:10:09 +00:00
|
|
|
$cmd echo "Upgrade failed! Please report a bug and attach $HOME/git-annex-install.log"
|
2013-02-23 05:08:15 +00:00
|
|
|
fi
|
2013-02-21 16:47:16 +00:00
|
|
|
fi
|
2013-02-23 05:08:15 +00:00
|
|
|
}
|
|
|
|
|
2013-02-23 18:33:12 +00:00
|
|
|
run () {
|
2013-02-23 05:08:15 +00:00
|
|
|
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
|
2013-05-03 18:08:26 +00:00
|
|
|
|
2013-02-23 05:08:15 +00:00
|
|
|
# Indicate which variables were exported above.
|
|
|
|
GIT_ANNEX_STANDLONE_ENV="GIT_EXEC_PATH GIT_TEMPLATE_DIR"
|
|
|
|
export GIT_ANNEX_STANDLONE_ENV
|
|
|
|
|
|
|
|
# This is a temporary directory on a non-crippled filesystem.
|
2013-05-03 15:51:58 +00:00
|
|
|
# Needs to be as short a path as possible, for ssh sockets.
|
2013-02-23 05:08:15 +00:00
|
|
|
GIT_ANNEX_TMP_DIR=$base/tmp
|
|
|
|
export GIT_ANNEX_TMP_DIR
|
2013-05-03 15:56:53 +00:00
|
|
|
# /tmp probably doesn't exist, so also use it as TMPDIR
|
|
|
|
TMPDIR=$GIT_ANNEX_TMP_DIR
|
|
|
|
export TMPDIR
|
2013-05-03 18:08:26 +00:00
|
|
|
|
|
|
|
if $cmd test ! -e "$HOME/.gitconfig"; then
|
|
|
|
git config --global user.email "git-annex@android"
|
|
|
|
git config --global user.name "android"
|
|
|
|
fi
|
|
|
|
|
2013-02-24 18:10:09 +00:00
|
|
|
if $cmd test "$1"; then
|
2013-02-23 05:08:15 +00:00
|
|
|
cmd="$1"
|
|
|
|
shift 1
|
|
|
|
exec "$cmd" "$@"
|
|
|
|
else
|
2013-05-03 05:02:38 +00:00
|
|
|
# As good a start point as any.
|
|
|
|
cd "$HOME"
|
|
|
|
|
2013-02-24 18:34:47 +00:00
|
|
|
/system/bin/sh
|
2013-02-21 16:47:16 +00:00
|
|
|
fi
|
2013-02-23 05:08:15 +00:00
|
|
|
}
|
2013-02-19 18:56:24 +00:00
|
|
|
|
2013-02-23 05:08:15 +00:00
|
|
|
if ! prep; then
|
2013-02-24 18:10:09 +00:00
|
|
|
$cmd echo "prep failed. Please report a bug."
|
2013-02-23 05:08:15 +00:00
|
|
|
read line
|
|
|
|
fi
|
|
|
|
if ! install; then
|
2013-02-24 18:10:09 +00:00
|
|
|
$cmd echo "install failed. Please report a bug."
|
2013-02-23 05:08:15 +00:00
|
|
|
read line
|
|
|
|
fi
|
2013-02-23 18:50:14 +00:00
|
|
|
run
|