summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonmar <unknown>2005-11-08 14:18:35 +0000
committersimonmar <unknown>2005-11-08 14:18:35 +0000
commitd76ab8dde14aedffd323034506bb4deae8855f60 (patch)
tree59b1e857907976fbf7a15ec300ebb769a70efd21
parent033418425ff8b4591580bf2bc4476b7ecc203ba6 (diff)
downloadhaskell-d76ab8dde14aedffd323034506bb4deae8855f60.tar.gz
[project @ 2005-11-08 14:18:35 by simonmar]
when GHC_PACKAGE_PATH is set, treat the database at the bottom of the stack as the "global" one, ie. the one we modify by default. This means that GHC_PACKAGE_PATH can be used to set up a virtual GHC package environment into which packages can be installed using Cabal, without setting anything other than GHC_PACKAGE_PATH.
-rw-r--r--ghc/utils/ghc-pkg/Main.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/ghc/utils/ghc-pkg/Main.hs b/ghc/utils/ghc-pkg/Main.hs
index 04170c4c43..2f8be4578d 100644
--- a/ghc/utils/ghc-pkg/Main.hs
+++ b/ghc/utils/ghc-pkg/Main.hs
@@ -314,6 +314,10 @@ getPkgDatabases modify flags = do
| otherwise -> cs
where cs = parseSearchPath path
+ -- The "global" database is always the one at the bottom of the stack.
+ -- This is the database we modify by default.
+ virt_global_conf = last env_stack
+
-- -f flags on the command line add to the database stack, unless any
-- of them are present in the stack already.
let flag_stack = filter (`notElem` env_stack)
@@ -327,10 +331,10 @@ getPkgDatabases modify flags = do
then return flag_stack
else let
go (FlagUser : fs) = modifying user_conf
- go (FlagGlobal : fs) = modifying global_conf
+ go (FlagGlobal : fs) = modifying virt_global_conf
go (FlagConfig f : fs) = modifying f
go (_ : fs) = go fs
- go [] = modifying global_conf
+ go [] = modifying virt_global_conf
modifying f
| f `elem` flag_stack = return (dropWhile (/= f) flag_stack)