Fix bug introduced in the last release that broke git-annex sync when git-annex was installed from the standalone tarball.

This was introduced by commit 450ee53ab6

However, the same problem could affect other calls to programPath,
specifically some on the assistant. So, I fixed it at a deeper level.
This commit is contained in:
Joey Hess 2015-03-27 12:55:18 -04:00
parent 00a6f5500f
commit 5be536e523
5 changed files with 23 additions and 52 deletions

View file

@ -11,7 +11,9 @@ module Annex.Path where
import Common
import Config.Files
import System.Environment
import Utility.Env
import System.Environment (getExecutablePath)
{- A fully qualified path to the currently running git-annex program.
-
@ -19,15 +21,22 @@ import System.Environment
- well, it returns the complete path to the program. But, on other OSs,
- it might return just the basename. Fall back to reading the programFile,
- or searching for the command name in PATH.
-
- The standalone build runs git-annex via ld.so, and defeats
- getExecutablePath. It sets GIT_ANNEX_PROGRAMPATH to the correct path
- to the wrapper script to use.
-}
programPath :: IO FilePath
programPath = do
programPath = go =<< getEnv "GIT_ANNEX_PROGRAMPATH"
where
go (Just p) = return p
go Nothing = do
#if MIN_VERSION_base(4,6,0)
exe <- getExecutablePath
p <- if isAbsolute exe
then return exe
else readProgramFile
exe <- getExecutablePath
p <- if isAbsolute exe
then return exe
else readProgramFile
#else
p <- readProgramFile
p <- readProgramFile
#endif
maybe cannotFindProgram return =<< searchPath p
maybe cannotFindProgram return =<< searchPath p