ac0292df95
This should avoid relying on features of the Android builtin shell, and so hopefully avoid failures like this one http://git-annex.branchable.com/design/assistant/blog/day_197__template_haskell/#comment-07f90830f78f6495dcbdf90eb8636129 The C shim sets up busybox, and uses its builtin shell to run runshell. It's important that busybox be configured with CONFIG_FEATURE_SH_STANDALONE, so that while runshell is running, it does not rely on either system utilities, or busybox being already installed.
115 lines
2.6 KiB
Bash
Executable file
115 lines
2.6 KiB
Bash
Executable file
#!/system/bin/sh
|
|
# This is runs a shell in an environment configured for git-annex.
|
|
|
|
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"
|
|
|
|
if [ -e "$base/bin" ]; then
|
|
mv "$base/bin" "$base/bin.old"
|
|
fi
|
|
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"
|
|
fi
|
|
ln "$base/lib/lib.$prog.so" "$base/bin/$prog"
|
|
done
|
|
|
|
$base/bin/busybox --install $base/bin
|
|
|
|
$base/bin/rm -rf "$base/bin.old"
|
|
|
|
cd "$base"
|
|
$base/bin/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"
|
|
fi
|
|
ln "$base/bin/$prog" "$base/$link"
|
|
done
|
|
rm "$base/links/$prog"
|
|
done
|
|
|
|
mkdir -p "$base/templates"
|
|
mkdir -p "$base/tmp"
|
|
|
|
cat "$base/lib/lib.version.so" > "$base/installed-version"
|
|
echo "Installation complete"
|
|
}
|
|
|
|
install () {
|
|
if [ ! -e "$base/git-annex" ]; 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
|
|
fi
|
|
}
|
|
|
|
run () {
|
|
# 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
|
|
sh
|
|
fi
|
|
}
|
|
|
|
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
|
|
run
|