Skip to content

Commit

Permalink
Add a ForcePackageDBStack argument to configPackageDB'.
Browse files Browse the repository at this point in the history
We use userInstallDirs in sandbox mode to prevent cabal-install from doing
unnecessary things like invoking itself via 'sudo' (see commit
7b2e363 and 'rootCmd' in D.C.Install), but in
this particular case we want userInstall to be False to prevent UserPackageDB
from being added to the package DB stack (see haskell#1183 and interpretPackageDbFlags
in D.S.Configure).
  • Loading branch information
23Skidoo committed Mar 24, 2013
1 parent 0c9284f commit 39af2cb
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions cabal-install/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ configureAction (configFlags, configExFlags) extraArgs globalFlags = do
globalFlags' = savedGlobalFlags config `mappend` globalFlags
(comp, platform, conf) <- configCompilerAux configFlags'
configure verbosity
(configPackageDB' configFlags') (globalRepos globalFlags')
(configPackageDB' configFlags' DontForceGlobalInstall)
(globalRepos globalFlags')
comp platform conf configFlags' configExFlags' extraArgs

buildAction :: BuildFlags -> [String] -> GlobalFlags -> IO ()
Expand Down Expand Up @@ -376,7 +377,8 @@ installAction (configFlags, configExFlags, installFlags, haddockFlags)
globalFlags' = savedGlobalFlags config `mappend` globalFlags
(comp, platform, conf) <- configCompilerAux' configFlags'
install verbosity
(configPackageDB' configFlags') (globalRepos globalFlags')
(configPackageDB' configFlags' DontForceGlobalInstall)
(globalRepos globalFlags')
comp platform conf globalFlags' configFlags' configExFlags'
installFlags' haddockFlags
targets
Expand Down Expand Up @@ -423,7 +425,7 @@ listAction listFlags extraArgs globalFlags = do
globalFlags' = savedGlobalFlags config `mappend` globalFlags
(comp, _, conf) <- configCompilerAux' configFlags
list verbosity
(configPackageDB' configFlags)
(configPackageDB' configFlags DontForceGlobalInstall)
(globalRepos globalFlags')
comp
conf
Expand All @@ -439,7 +441,7 @@ infoAction infoFlags extraArgs globalFlags = do
globalFlags' = savedGlobalFlags config `mappend` globalFlags
(comp, _, conf) <- configCompilerAux configFlags
info verbosity
(configPackageDB' configFlags)
(configPackageDB' configFlags DontForceGlobalInstall)
(globalRepos globalFlags')
comp
conf
Expand Down Expand Up @@ -480,7 +482,8 @@ fetchAction fetchFlags extraArgs globalFlags = do
globalFlags' = savedGlobalFlags config `mappend` globalFlags
(comp, platform, conf) <- configCompilerAux' configFlags
fetch verbosity
(configPackageDB' configFlags) (globalRepos globalFlags')
(configPackageDB' configFlags DontForceGlobalInstall)
(globalRepos globalFlags')
comp platform conf globalFlags' fetchFlags
targets

Expand Down Expand Up @@ -582,7 +585,7 @@ initAction initFlags _extraArgs globalFlags = do
let configFlags = savedConfigureFlags config
(comp, _, conf) <- configCompilerAux' configFlags
initCabal verbosity
(configPackageDB' configFlags)
(configPackageDB' configFlags DontForceGlobalInstall)
comp
conf
initFlags
Expand Down Expand Up @@ -623,11 +626,16 @@ win32SelfUpgradeAction _ _ _ = return ()
-- Utils (transitionary)
--

configPackageDB' :: ConfigFlags -> PackageDBStack
configPackageDB' cfg =
data ForceGlobalInstall = DontForceGlobalInstall
| ForceGlobalInstall

configPackageDB' :: ConfigFlags -> ForceGlobalInstall -> PackageDBStack
configPackageDB' cfg force =
interpretPackageDbFlags userInstall (configPackageDBs cfg)
where
userInstall = fromFlagOrDefault True (configUserInstall cfg)
userInstall = case force of
ForceGlobalInstall -> False
DontForceGlobalInstall -> fromFlagOrDefault True (configUserInstall cfg)

configCompilerAux' :: ConfigFlags
-> IO (Compiler, Platform, ProgramConfiguration)
Expand Down

0 comments on commit 39af2cb

Please sign in to comment.