[commit: Cabal] master: Refactor to avoid problems when $HOME is not set (cbe5067)
Ian Lynagh
igloo at earth.li
Sun Apr 17 18:33:43 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/cbe506729799b8f44506559b6ba47644b0d75d2c
>---------------------------------------------------------------
commit cbe506729799b8f44506559b6ba47644b0d75d2c
Author: Ian Lynagh <igloo at earth.li>
Date: Sun Apr 17 15:41:35 2011 +0000
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).
>---------------------------------------------------------------
Distribution/Simple/InstallDirs.hs | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/Distribution/Simple/InstallDirs.hs b/Distribution/Simple/InstallDirs.hs
index 1d7fb95..b9b240f 100644
--- a/Distribution/Simple/InstallDirs.hs
+++ b/Distribution/Simple/InstallDirs.hs
@@ -217,21 +217,23 @@ type InstallDirTemplates = InstallDirs PathTemplate
defaultInstallDirs :: CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates
defaultInstallDirs comp userInstall _hasLibs = do
- windowsProgramFilesDir <- getWindowsProgramFilesDir
- userInstallPrefix <- getAppUserDataDirectory "cabal"
- lhcPrefix <- getAppUserDataDirectory "lhc"
+ installPrefix <-
+ if userInstall
+ 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 {
- prefix = if userInstall
- then userInstallPrefix
- else case buildOS of
- Windows -> windowsProgramFilesDir </> "Haskell"
- _other -> "/usr/local",
+ prefix = installPrefix,
bindir = "$prefix" </> "bin",
- libdir = case buildOS of
- Windows -> "$prefix"
- _other -> case comp of
- LHC | userInstall -> lhcPrefix
- _ -> "$prefix" </> "lib",
+ libdir = installLibDir,
libsubdir = case comp of
Hugs -> "hugs" </> "packages" </> "$pkg"
JHC -> "$compiler"
More information about the Cvs-libraries
mailing list