aboutsummaryrefslogtreecommitdiff
path: root/Assistant/Install.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-11-27 17:05:29 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-11-27 17:05:29 -0400
commitaf2e65f1c25b72643dfec6ae2a9284ebeeb70ec5 (patch)
tree0246a2c6e0ef184c310920a4cc5e9e62a56ac0ab /Assistant/Install.hs
parentece8d76d67e2c22e33963f52a341f4b3a59d3ec4 (diff)
The standalone builds now unset their special path and library path variables before running the system web browser.
Should fix a crash reported on OSX.
Diffstat (limited to 'Assistant/Install.hs')
-rw-r--r--Assistant/Install.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/Assistant/Install.hs b/Assistant/Install.hs
index 635c265f4..475161c63 100644
--- a/Assistant/Install.hs
+++ b/Assistant/Install.hs
@@ -21,6 +21,7 @@ import Utility.OSX
import Utility.FreeDesktop
#endif
+import Data.AssocList
import System.Posix.Env
standaloneAppBase :: IO (Maybe FilePath)
@@ -68,3 +69,24 @@ ensureInstalled = go =<< standaloneAppBase
createDirectoryIfMissing True (parentDir shim)
writeFile shim content
modifyFileMode shim $ addModes [ownerExecuteMode]
+
+{- Returns a cleaned up environment that lacks settings used to make the
+ - standalone builds use their bundled libraries and programs.
+ - Useful when calling programs not included in the standalone builds.
+ -
+ - For a non-standalone build, returns Nothing.
+ -}
+cleanEnvironment :: IO (Maybe [(String, String)])
+cleanEnvironment = clean <$> getEnvironment
+ where
+ clean env
+ | null vars = Nothing
+ | otherwise = Just $ catMaybes $ map (restoreorig env) env
+ | otherwise = Nothing
+ where
+ vars = words $ lookup1 "GIT_ANNEX_STANDLONE_ENV" env
+ restoreorig oldenv p@(k, v)
+ | k `elem` vars = case lookup1 ("ORIG_" ++ k) oldenv of
+ "" -> Nothing
+ v' -> Just (k, v')
+ | otherwise = Just p