Commit cbe50672 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Refactor to avoid problems when $HOME is not set

We now avoid calling getWindowsProgramFilesDir and
getAppUserDataDirectory when we don't need to know their results.
This means that a GHC build goes through when $HOME is unset
(GHC trac #5047).
parent fdeb93ab
...@@ -217,21 +217,23 @@ type InstallDirTemplates = InstallDirs PathTemplate ...@@ -217,21 +217,23 @@ type InstallDirTemplates = InstallDirs PathTemplate
defaultInstallDirs :: CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates defaultInstallDirs :: CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates
defaultInstallDirs comp userInstall _hasLibs = do defaultInstallDirs comp userInstall _hasLibs = do
windowsProgramFilesDir <- getWindowsProgramFilesDir installPrefix <-
userInstallPrefix <- getAppUserDataDirectory "cabal" if userInstall
lhcPrefix <- getAppUserDataDirectory "lhc" then getAppUserDataDirectory "cabal"
else case buildOS of
Windows -> do windowsProgramFilesDir <- getWindowsProgramFilesDir
return (windowsProgramFilesDir </> "Haskell")
_ -> return "/usr/local"
installLibDir <-
case buildOS of
Windows -> return "$prefix"
_ -> case comp of
LHC | userInstall -> getAppUserDataDirectory "lhc"
_ -> return ("$prefix" </> "lib")
return $ fmap toPathTemplate $ InstallDirs { return $ fmap toPathTemplate $ InstallDirs {
prefix = if userInstall prefix = installPrefix,
then userInstallPrefix
else case buildOS of
Windows -> windowsProgramFilesDir </> "Haskell"
_other -> "/usr/local",
bindir = "$prefix" </> "bin", bindir = "$prefix" </> "bin",
libdir = case buildOS of libdir = installLibDir,
Windows -> "$prefix"
_other -> case comp of
LHC | userInstall -> lhcPrefix
_ -> "$prefix" </> "lib",
libsubdir = case comp of libsubdir = case comp of
Hugs -> "hugs" </> "packages" </> "$pkg" Hugs -> "hugs" </> "packages" </> "$pkg"
JHC -> "$compiler" JHC -> "$compiler"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment