windows: hack to ensure HOME is always set
This commit is contained in:
parent
8fdbd1190d
commit
d007d1ac0c
3 changed files with 48 additions and 5 deletions
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -8,6 +8,7 @@ git-annex (5.20140211) UNRELEASED; urgency=medium
|
||||||
* Add progress display for transfers to/from external special remotes.
|
* Add progress display for transfers to/from external special remotes.
|
||||||
* Windows webapp: Can set up box.com, Amazon S3 remotes.
|
* Windows webapp: Can set up box.com, Amazon S3 remotes.
|
||||||
* Windows webapp: Can create repos on removable drives.
|
* Windows webapp: Can create repos on removable drives.
|
||||||
|
* Windows: Ensure HOME is set, as needed by bundled cygwin utilities.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Mon, 10 Feb 2014 21:33:03 -0400
|
-- Joey Hess <joeyh@debian.org> Mon, 10 Feb 2014 21:33:03 -0400
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,11 @@ now! --[[Joey]]
|
||||||
Should try to get rid of the console, but only once ssh passwords
|
Should try to get rid of the console, but only once ssh passwords
|
||||||
(and possibly gpg) are not prompted there anymore.
|
(and possibly gpg) are not prompted there anymore.
|
||||||
* Local pairing seems to fail, after acking on Linux box, it stalls.
|
* Local pairing seems to fail, after acking on Linux box, it stalls.
|
||||||
* rsync.net setup failed. Seems to have generated a hostname including
|
* rsync.net setup failed. Ssh seems to not be looking for the config file
|
||||||
the directory somehow.
|
where git-annex puts it. Probably confusion over where the home directory
|
||||||
|
is.
|
||||||
|
* remote ssh server fails; password prompt appears but user input
|
||||||
|
seems not connected to it.
|
||||||
* gcrypt is not ported to windows (and as a shell script, may need
|
* gcrypt is not ported to windows (and as a shell script, may need
|
||||||
to be rewritten)
|
to be rewritten)
|
||||||
* webapp lets user choose to encrypt repo, and generate gpg key,
|
* webapp lets user choose to encrypt repo, and generate gpg key,
|
||||||
|
|
45
git-annex.hs
45
git-annex.hs
|
@ -1,13 +1,13 @@
|
||||||
{- git-annex main program stub
|
{- git-annex main program dispatch
|
||||||
-
|
-
|
||||||
- Copyright 2010-2013 Joey Hess <joey@kitenet.net>
|
- Copyright 2010-2014 Joey Hess <joey@kitenet.net>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
{-# LANGUAGE CPP #-}
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
import System.Environment
|
import System.Environment (getArgs, getProgName)
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
|
|
||||||
import qualified CmdLine.GitAnnex
|
import qualified CmdLine.GitAnnex
|
||||||
|
@ -16,6 +16,14 @@ import qualified CmdLine.GitAnnexShell
|
||||||
import qualified Test
|
import qualified Test
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef mingw32_HOST_OS
|
||||||
|
import Utility.UserInfo
|
||||||
|
import Utility.Env
|
||||||
|
import Config.Files
|
||||||
|
import System.Process
|
||||||
|
import System.Exit
|
||||||
|
#endif
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
ps <- getArgs
|
ps <- getArgs
|
||||||
|
@ -29,6 +37,37 @@ main = do
|
||||||
("test":ps') -> Test.main ps'
|
("test":ps') -> Test.main ps'
|
||||||
_ -> CmdLine.GitAnnex.run ps
|
_ -> CmdLine.GitAnnex.run ps
|
||||||
#else
|
#else
|
||||||
|
#ifdef mingw32_HOST_OS
|
||||||
|
winEnv CmdLine.GitAnnex.run ps
|
||||||
|
#else
|
||||||
|
#endif
|
||||||
CmdLine.GitAnnex.run ps
|
CmdLine.GitAnnex.run ps
|
||||||
#endif
|
#endif
|
||||||
isshell n = takeFileName n == "git-annex-shell"
|
isshell n = takeFileName n == "git-annex-shell"
|
||||||
|
|
||||||
|
#ifdef mingw32_HOST_OS
|
||||||
|
{- On Windows, if HOME is not set, probe it and set it, re-execing
|
||||||
|
- git-annex with the new environment.
|
||||||
|
-
|
||||||
|
- This is a workaround for some Cygwin commands needing HOME to be set,
|
||||||
|
- and for there being no known way to set environment variables on
|
||||||
|
- Windows, except by passing an environment in each call to a program.
|
||||||
|
- While ugly, this workaround is easier than trying to ensure HOME is set
|
||||||
|
- in all calls to the affected programs.
|
||||||
|
-}
|
||||||
|
winEnv :: ([String] -> IO ()) -> [String] -> IO ()
|
||||||
|
winEnv a ps = go =<< getEnv "HOME"
|
||||||
|
where
|
||||||
|
go (Just _) = a ps
|
||||||
|
go Nothing = do
|
||||||
|
home <- myHomeDir
|
||||||
|
e <- getEnvironment
|
||||||
|
let eoverride =
|
||||||
|
[ ("HOME", home)
|
||||||
|
, ("CYGWIN", "nodosfilewarning")
|
||||||
|
]
|
||||||
|
cmd <- readProgramFile
|
||||||
|
(_, _, _, proc) <- createProcess (proc cmd ps)
|
||||||
|
{ env = Just $ e ++ eoverride }
|
||||||
|
exitWith =<< waitForProcess proc
|
||||||
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue