work around git/environment/gecos/android suck
I don't know why, but I can't seem to set the environment variables inside git-annex to work around the git error caused by android's crappy username and hostname settings. This workaround works, and that's all that's good about it.
This commit is contained in:
parent
1b3b1675ab
commit
543ffa5b9f
2 changed files with 23 additions and 16 deletions
|
@ -5,6 +5,8 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Annex.Environment where
|
module Annex.Environment where
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
|
@ -27,8 +29,14 @@ checkEnvironmentIO :: IO ()
|
||||||
checkEnvironmentIO = do
|
checkEnvironmentIO = do
|
||||||
whenM (null <$> myUserGecos) $ do
|
whenM (null <$> myUserGecos) $ do
|
||||||
username <- myUserName
|
username <- myUserName
|
||||||
-- existing environment is not overwritten
|
ensureEnv "GIT_AUTHOR_NAME" username
|
||||||
setEnv "GIT_AUTHOR_NAME" username False
|
ensureEnv "GIT_COMMITTER_NAME" username
|
||||||
setEnv "GIT_COMMITTER_NAME" username False
|
where
|
||||||
hostname <- getHostName
|
#ifndef __ANDROID__
|
||||||
setEnv "EMAIL" (username ++ "@" ++ hostname) False
|
-- existing environment is not overwritten
|
||||||
|
ensureEnv var val = setEnv var val False
|
||||||
|
#else
|
||||||
|
-- Environment setting is broken on Android, so this is dealt with
|
||||||
|
-- in runshell instead.
|
||||||
|
ensureEnv _ _ = noop
|
||||||
|
#endif
|
||||||
|
|
|
@ -58,10 +58,10 @@ buildtree () {
|
||||||
}
|
}
|
||||||
|
|
||||||
install () {
|
install () {
|
||||||
|
if ! $cmd mkdir -p "$HOME"; then
|
||||||
|
$cmd echo "mkdir of $HOME failed!"
|
||||||
|
fi
|
||||||
if $cmd test ! -e "$base/bin/git-annex"; then
|
if $cmd test ! -e "$base/bin/git-annex"; then
|
||||||
if ! $cmd mkdir -p "$HOME"; then
|
|
||||||
$cmd echo "mkdir of $HOME failed!"
|
|
||||||
fi
|
|
||||||
if ! buildtree > $HOME/git-annex-install.log 2>&1; then
|
if ! buildtree > $HOME/git-annex-install.log 2>&1; then
|
||||||
$cmd 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"
|
||||||
$cmd sh
|
$cmd sh
|
||||||
|
@ -86,7 +86,7 @@ run () {
|
||||||
export ORIG_GIT_TEMPLATE_DIR
|
export ORIG_GIT_TEMPLATE_DIR
|
||||||
GIT_TEMPLATE_DIR="$base/templates"
|
GIT_TEMPLATE_DIR="$base/templates"
|
||||||
export GIT_TEMPLATE_DIR
|
export GIT_TEMPLATE_DIR
|
||||||
|
|
||||||
# Indicate which variables were exported above.
|
# Indicate which variables were exported above.
|
||||||
GIT_ANNEX_STANDLONE_ENV="GIT_EXEC_PATH GIT_TEMPLATE_DIR"
|
GIT_ANNEX_STANDLONE_ENV="GIT_EXEC_PATH GIT_TEMPLATE_DIR"
|
||||||
export GIT_ANNEX_STANDLONE_ENV
|
export GIT_ANNEX_STANDLONE_ENV
|
||||||
|
@ -98,18 +98,17 @@ run () {
|
||||||
# /tmp probably doesn't exist, so also use it as TMPDIR
|
# /tmp probably doesn't exist, so also use it as TMPDIR
|
||||||
TMPDIR=$GIT_ANNEX_TMP_DIR
|
TMPDIR=$GIT_ANNEX_TMP_DIR
|
||||||
export TMPDIR
|
export TMPDIR
|
||||||
|
|
||||||
|
if $cmd test ! -e "$HOME/.gitconfig"; then
|
||||||
|
git config --global user.email "git-annex@android"
|
||||||
|
git config --global user.name "android"
|
||||||
|
fi
|
||||||
|
|
||||||
if $cmd test "$1"; then
|
if $cmd test "$1"; then
|
||||||
cmd="$1"
|
cmd="$1"
|
||||||
shift 1
|
shift 1
|
||||||
exec "$cmd" "$@"
|
exec "$cmd" "$@"
|
||||||
else
|
else
|
||||||
# Ensure home directory exists, even if it got deleted
|
|
||||||
# somehow.
|
|
||||||
if ! $cmd mkdir -p "$HOME"; then
|
|
||||||
$cmd echo "mkdir of $HOME failed!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# As good a start point as any.
|
# As good a start point as any.
|
||||||
cd "$HOME"
|
cd "$HOME"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue