Linux standalone: Work around problem that prevented it from working properly if unpacked into a directory that contains ":" or ";" in its name.

This commit is contained in:
Joey Hess 2015-08-04 16:08:19 -04:00
parent a42acc9a42
commit 7133b68afe
3 changed files with 33 additions and 2 deletions

3
debian/changelog vendored
View file

@ -19,6 +19,9 @@ git-annex (5.20150732) UNRELEASED; urgency=medium
* proxy: Fix behavior when run in subdirectory of git repo.
* Windows: Fix bug that caused git-annex sync to fail due to missing
environment variable.
* Linux standalone: Work around problem that prevented it from working
properly if unpacked into a directory that contains ":" or ";" in its
name.
-- Joey Hess <id@joeyh.name> Fri, 31 Jul 2015 12:31:39 -0400

View file

@ -39,3 +39,10 @@ git-annex: get: 1 failed
# End of transcript or log.
"""]]
> Actually, this bug is fixable. And I have! I made it detect the problem
> path, and then fall back to making a directory in /tmp, symlinking the
> git-annex.linux directory into it, and using that as its base directory.
>
> Of course, that's a suboptimal configuration, but better than having some
> configurations where it doesn't work. --[[Joey]]

View file

@ -26,6 +26,22 @@ cd "$base"
base="$(pwd)"
cd "$orig"
# --library-path won't work if $base contains : or ;
# Detect this problem, and work around it by using a temp directory.
if echo "$base" | grep -q '[:;]'; then
tbase=$(mktemp -d -p /tmp annexshimXXXXXXXXX 2>/dev/null || true)
if [ -z "$tbase" ]; then
tbase="/tmp/annexshim.$$"
mkdir "$tbase"
fi
ln -s "$base" "$tbase/link"
base="$tbase/link"
cleanuptbase () {
rm -rf "$tbase"
}
trap cleanuptbase EXIT
fi
# Install shim that's used to run git-annex-shell from ssh authorized_keys.
# The assistant also does this when run, but the user may not be using the
# assistant.
@ -63,7 +79,7 @@ export ORIG_PATH
PATH="$base/bin:$PATH"
export PATH
# This is used by the shim wrapper around each binary.
# These env vars are used by the shim wrapper around each binary.
for lib in $(cat "$base/libdirs"); do
GIT_ANNEX_LD_LIBRARY_PATH="$base/$lib:$GIT_ANNEX_LD_LIBRARY_PATH"
done
@ -103,7 +119,12 @@ export GIT_ANNEX_STANDLONE_ENV
if [ "$1" ]; then
cmd="$1"
shift 1
exec "$cmd" "$@"
if [ -z "$tbase" ]; then
exec "$cmd" "$@"
else
# allow EXIT trap to cleanup
"$cmd" "$@"
fi
else
sh
fi