2013-02-13 17:32:15 +00:00
|
|
|
#!/system/bin/sh
|
2013-02-21 16:47:16 +00:00
|
|
|
# This is run by the Android app, and runs a shell in an environment
|
|
|
|
# configured for git-annex.
|
2013-02-13 17:32:15 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2013-02-23 05:08:15 +00:00
|
|
|
prep () {
|
|
|
|
# I'm installed as lib/lib.runshell.so
|
|
|
|
orig="$(pwd)"
|
|
|
|
cd "$0/../.."
|
|
|
|
base="$(pwd)"
|
|
|
|
|
|
|
|
# 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-21 16:47:16 +00:00
|
|
|
echo "Installation starting to $base"
|
2013-02-22 19:03:12 +00:00
|
|
|
cat "$base/lib/lib.version.so"
|
|
|
|
|
2013-02-22 20:20:41 +00:00
|
|
|
if [ -e "$base/bin" ]; then
|
|
|
|
mv "$base/bin" "$base/bin.old"
|
|
|
|
fi
|
2013-02-21 16:47:16 +00:00
|
|
|
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-21 16:47:16 +00:00
|
|
|
echo "installing $prog"
|
2013-02-22 19:49:11 +00:00
|
|
|
if [ -e "$base/bin/$prog" ]; then
|
|
|
|
rm "$base/bin/$prog"
|
|
|
|
fi
|
2013-02-22 19:03:12 +00:00
|
|
|
ln "$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-22 20:20:41 +00:00
|
|
|
$base/bin/busybox --install $base/bin
|
2013-02-22 19:03:12 +00:00
|
|
|
|
2013-02-22 20:20:41 +00:00
|
|
|
$base/bin/rm -rf "$base/bin.old"
|
|
|
|
|
|
|
|
cd "$base"
|
2013-02-22 19:49:11 +00:00
|
|
|
$base/bin/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-22 20:20:41 +00:00
|
|
|
for link in $(cat "$base/links/$prog"); do
|
2013-02-21 16:47:16 +00:00
|
|
|
echo "linking $link to $prog"
|
2013-02-22 20:06:21 +00:00
|
|
|
if [ -e "$base/$link" ]; then
|
2013-02-22 19:49:11 +00:00
|
|
|
rm "$base/$link"
|
|
|
|
fi
|
2013-02-22 19:03:12 +00:00
|
|
|
ln "$base/bin/$prog" "$base/$link"
|
2013-02-21 16:47:16 +00:00
|
|
|
done
|
2013-02-22 19:49:11 +00:00
|
|
|
rm "$base/links/$prog"
|
2013-02-21 16:47:16 +00:00
|
|
|
done
|
2013-02-13 17:32:15 +00:00
|
|
|
|
2013-02-21 16:47:16 +00:00
|
|
|
mkdir -p "$base/templates"
|
|
|
|
mkdir -p "$base/tmp"
|
2013-02-22 19:03:12 +00:00
|
|
|
|
2013-02-22 19:49:11 +00:00
|
|
|
cat "$base/lib/lib.version.so" > "$base/installed-version"
|
2013-02-21 16:47:16 +00:00
|
|
|
echo "Installation complete"
|
|
|
|
}
|
|
|
|
|
2013-02-23 05:08:15 +00:00
|
|
|
install () {
|
|
|
|
if [ ! -d "$base/bin" ]; then
|
|
|
|
if ! mkdir -p "$HOME"; then
|
|
|
|
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
|
|
|
|
fi
|
|
|
|
elif [ ! -e "$base/installed-version" ] || ! 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"
|
|
|
|
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
|
|
|
# As good a start point as any.
|
|
|
|
cd "$HOME"
|
|
|
|
|
|
|
|
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="GIT_EXEC_PATH GIT_TEMPLATE_DIR"
|
|
|
|
export GIT_ANNEX_STANDLONE_ENV
|
|
|
|
|
|
|
|
# This is a temporary directory on a non-crippled filesystem.
|
|
|
|
# This needs to be as short a path as possible.
|
|
|
|
GIT_ANNEX_TMP_DIR=$base/tmp
|
|
|
|
export GIT_ANNEX_TMP_DIR
|
|
|
|
|
|
|
|
if [ "$1" ]; then
|
|
|
|
cmd="$1"
|
|
|
|
shift 1
|
|
|
|
exec "$cmd" "$@"
|
|
|
|
else
|
2013-02-21 16:47:16 +00:00
|
|
|
sh
|
|
|
|
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
|
|
|
|
echo "prep failed. Please report a bug."
|
|
|
|
read line
|
|
|
|
fi
|
|
|
|
if ! install; then
|
|
|
|
echo "install failed. Please report a bug."
|
|
|
|
read line
|
|
|
|
fi
|
2013-02-23 18:50:14 +00:00
|
|
|
run
|