Commit c5a8b0b3 authored by Duncan Coutts's avatar Duncan Coutts

Change the install and configure modules to use the extended config flags

parent 04f10838
......@@ -29,7 +29,7 @@ import Distribution.Client.InstallPlan (InstallPlan)
import Distribution.Client.IndexUtils as IndexUtils
( getAvailablePackages )
import Distribution.Client.Setup
( InstallFlags(..), configureCommand, filterConfigureFlags )
( ConfigExFlags(..), configureCommand, filterConfigureFlags )
import Distribution.Client.Types as Available
( AvailablePackage(..), AvailablePackageSource(..), Repo(..)
, AvailablePackageDb(..), ConfiguredPackage(..) )
......@@ -74,14 +74,16 @@ configure :: Verbosity
-> Compiler
-> ProgramConfiguration
-> ConfigFlags
-> InstallFlags
-> ConfigExFlags
-> [String]
-> IO ()
configure verbosity packageDB repos comp conf configFlags installFlags extraArgs = do
configure verbosity packageDB repos comp conf
configFlags configExFlags extraArgs = do
installed <- getInstalledPackages verbosity comp packageDB conf
available <- getAvailablePackages verbosity repos
progress <- planLocalPackage verbosity comp configFlags installFlags
progress <- planLocalPackage verbosity comp configFlags configExFlags
installed available
notice verbosity "Resolving dependencies..."
......@@ -107,7 +109,7 @@ configure verbosity packageDB repos comp conf configFlags installFlags extraArgs
where
setupScriptOptions index = SetupScriptOptions {
useCabalVersion = maybe AnyVersion ThisVersion
(flagToMaybe (installCabalVersion installFlags)),
(flagToMaybe (configCabalVersion configExFlags)),
useCompiler = Just comp,
-- Hack: we typically want to allow the UserPackageDB for finding the
-- Cabal lib when compiling any Setup.hs even if we're doing a global
......@@ -130,11 +132,11 @@ configure verbosity packageDB repos comp conf configFlags installFlags extraArgs
-- and all its dependencies.
--
planLocalPackage :: Verbosity -> Compiler
-> ConfigFlags -> InstallFlags
-> ConfigFlags -> ConfigExFlags
-> Maybe (PackageIndex InstalledPackageInfo)
-> AvailablePackageDb
-> IO (Progress String String InstallPlan)
planLocalPackage verbosity comp configFlags installFlags installed
planLocalPackage verbosity comp configFlags configExFlags installed
(AvailablePackageDb _ availablePrefs) = do
pkg <- readPackageDescription verbosity =<< defaultPackageDesc verbosity
let -- The trick is, we add the local package to the available index and
......@@ -156,7 +158,7 @@ planLocalPackage verbosity comp configFlags installFlags installed
++ [ PackageVersionConstraint name ver
| Dependency name ver <- configConstraints configFlags ]
preferences = mergePackagePrefs PreferLatestForSelected
availablePrefs installFlags
availablePrefs configExFlags
return $ resolveDependenciesWithProgress buildPlatform (compilerId comp)
installed' available' preferences constraints targets
......@@ -164,16 +166,16 @@ planLocalPackage verbosity comp configFlags installFlags installed
mergePackagePrefs :: PackagesPreferenceDefault
-> Map.Map PackageName VersionRange
-> InstallFlags
-> ConfigExFlags
-> PackagesPreference
mergePackagePrefs defaultPref availablePrefs installFlags =
mergePackagePrefs defaultPref availablePrefs configExFlags =
PackagesPreference defaultPref $
-- The preferences that come from the hackage index
[ PackageVersionPreference name ver
| (name, ver) <- Map.toList availablePrefs ]
-- additional preferences from the config file or command line
++ [ PackageVersionPreference name ver
| Dependency name ver <- installPreferences installFlags ]
| Dependency name ver <- configPreferences configExFlags ]
-- | Call an installer for an 'AvailablePackage' but override the configure
-- flags with the ones given by the 'ConfiguredPackage'. In particular the
......
......@@ -48,7 +48,7 @@ import qualified Distribution.Client.InstallPlan as InstallPlan
import Distribution.Client.InstallPlan (InstallPlan)
import Distribution.Client.Setup
( ConfigFlags(..), configureCommand, filterConfigureFlags
, InstallFlags(..) )
, ConfigExFlags(..), InstallFlags(..) )
import Distribution.Client.Config
( defaultLogsDir, defaultCabalDir )
import Distribution.Client.Tar (extractTarGzFile)
......@@ -126,27 +126,35 @@ install, upgrade
-> Compiler
-> ProgramConfiguration
-> ConfigFlags
-> ConfigExFlags
-> InstallFlags
-> [UnresolvedDependency]
-> IO ()
install verbosity packageDB repos comp conf configFlags installFlags deps =
install verbosity packageDB repos comp conf
configFlags configExFlags installFlags deps =
installWithPlanner planner
verbosity packageDB repos comp conf configFlags installFlags
verbosity packageDB repos comp conf
configFlags configExFlags installFlags
where
planner :: Planner
planner | null deps = planLocalPackage verbosity
comp configFlags installFlags
comp configFlags configExFlags
| otherwise = planRepoPackages PreferLatestForSelected
comp configFlags installFlags deps
comp configFlags configExFlags installFlags deps
upgrade verbosity packageDB repos comp conf
configFlags configExFlags installFlags deps =
upgrade verbosity packageDB repos comp conf configFlags installFlags deps =
installWithPlanner planner
verbosity packageDB repos comp conf configFlags installFlags
verbosity packageDB repos comp conf
configFlags configExFlags installFlags
where
planner :: Planner
planner | null deps = planUpgradePackages comp configFlags installFlags
planner | null deps = planUpgradePackages
comp configFlags configExFlags
| otherwise = planRepoPackages PreferAllLatest
comp configFlags installFlags deps
comp configFlags configExFlags installFlags deps
type Planner = Maybe (PackageIndex InstalledPackageInfo)
-> AvailablePackageDb
......@@ -161,9 +169,12 @@ installWithPlanner ::
-> Compiler
-> ProgramConfiguration
-> ConfigFlags
-> ConfigExFlags
-> InstallFlags
-> IO ()
installWithPlanner planner verbosity packageDB repos comp conf configFlags installFlags = do
installWithPlanner planner verbosity packageDB repos comp conf
configFlags configExFlags installFlags = do
installed <- getInstalledPackages verbosity comp packageDB conf
available <- getAvailablePackages verbosity repos
......@@ -243,7 +254,7 @@ installWithPlanner planner verbosity packageDB repos comp conf configFlags insta
rootCmd = if fromFlag (configUserInstall configFlags)
then Nothing -- ignore --root-cmd if --user.
else flagToMaybe (installRootCmd installFlags),
libVersion = flagToMaybe (installCabalVersion installFlags)
libVersion = flagToMaybe (configCabalVersion configExFlags)
}
storeDetailedBuildReports :: Verbosity -> FilePath
......@@ -282,8 +293,8 @@ storeDetailedBuildReports verbosity logsDir reports = sequence_
-- and all its dependencies.
--
planLocalPackage :: Verbosity -> Compiler
-> ConfigFlags -> InstallFlags -> Planner
planLocalPackage verbosity comp configFlags installFlags installed
-> ConfigFlags -> ConfigExFlags -> Planner
planLocalPackage verbosity comp configFlags configExFlags installed
(AvailablePackageDb available availablePrefs) = do
pkg <- readPackageDescription verbosity =<< defaultPackageDesc verbosity
let -- The trick is, we add the local package to the available index and
......@@ -305,7 +316,7 @@ planLocalPackage verbosity comp configFlags installFlags installed
++ [ PackageVersionConstraint name ver
| Dependency name ver <- configConstraints configFlags ]
preferences = mergePackagePrefs PreferLatestForSelected
availablePrefs installFlags
availablePrefs configExFlags
return $ resolveDependenciesWithProgress buildPlatform (compilerId comp)
installed' available' preferences constraints targets
......@@ -313,10 +324,11 @@ planLocalPackage verbosity comp configFlags installFlags installed
-- | Make an 'InstallPlan' for the given dependencies.
--
planRepoPackages :: PackagesPreferenceDefault -> Compiler
-> ConfigFlags -> InstallFlags
-> ConfigFlags -> ConfigExFlags -> InstallFlags
-> [UnresolvedDependency] -> Planner
planRepoPackages defaultPref comp configFlags installFlags deps installed
(AvailablePackageDb available availablePrefs) = do
planRepoPackages defaultPref comp configFlags configExFlags installFlags
deps installed (AvailablePackageDb available availablePrefs) = do
deps' <- IndexUtils.disambiguateDependencies available deps
let installed'
| fromFlagOrDefault False (installReinstall installFlags)
......@@ -326,7 +338,7 @@ planRepoPackages defaultPref comp configFlags installFlags deps installed
constraints = dependencyConstraints deps'
++ [ PackageVersionConstraint name ver
| Dependency name ver <- configConstraints configFlags ]
preferences = mergePackagePrefs defaultPref availablePrefs installFlags
preferences = mergePackagePrefs defaultPref availablePrefs configExFlags
return $ resolveDependenciesWithProgress buildPlatform (compilerId comp)
installed' available preferences constraints targets
where
......@@ -334,14 +346,14 @@ planRepoPackages defaultPref comp configFlags installFlags deps installed
foldr PackageIndex.deletePackageName index
[ name | UnresolvedDependency (Dependency name _) _ <- pkgs ]
planUpgradePackages :: Compiler -> ConfigFlags -> InstallFlags -> Planner
planUpgradePackages comp configFlags installFlags (Just installed)
planUpgradePackages :: Compiler -> ConfigFlags -> ConfigExFlags -> Planner
planUpgradePackages comp configFlags configExFlags (Just installed)
(AvailablePackageDb available availablePrefs) = return $
resolveDependenciesWithProgress buildPlatform (compilerId comp)
(Just installed) available preferences constraints targets
where
deps = upgradableDependencies installed available
preferences = mergePackagePrefs PreferAllLatest availablePrefs installFlags
preferences = mergePackagePrefs PreferAllLatest availablePrefs configExFlags
constraints = [ PackageVersionConstraint name ver
| Dependency name ver <- deps ]
++ [ PackageVersionConstraint name ver
......@@ -355,16 +367,16 @@ planUpgradePackages comp _ _ _ _ =
mergePackagePrefs :: PackagesPreferenceDefault
-> Map.Map PackageName VersionRange
-> InstallFlags
-> ConfigExFlags
-> PackagesPreference
mergePackagePrefs defaultPref availablePrefs installFlags =
mergePackagePrefs defaultPref availablePrefs configExFlags =
PackagesPreference defaultPref $
-- The preferences that come from the hackage index
[ PackageVersionPreference name ver
| (name, ver) <- Map.toList availablePrefs ]
-- additional preferences from the config file or command line
++ [ PackageVersionPreference name ver
| Dependency name ver <- installPreferences installFlags ]
| Dependency name ver <- configPreferences configExFlags ]
printDryRun :: Verbosity -> Maybe (PackageIndex InstalledPackageInfo)
-> InstallPlan -> IO ()
......
......@@ -168,13 +168,13 @@ configureAction (configFlags, configExFlags) extraArgs globalFlags = do
let verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
config <- loadConfig verbosity (globalConfigFile globalFlags)
(configUserInstall configFlags)
let configFlags' = savedConfigureFlags config `mappend` configFlags
installFlags' = savedInstallFlags config --TODO: `mappend` installFlags
globalFlags' = savedGlobalFlags config `mappend` globalFlags
let configFlags' = savedConfigureFlags config `mappend` configFlags
configExFlags' = savedConfigureExFlags config `mappend` configExFlags
globalFlags' = savedGlobalFlags config `mappend` globalFlags
(comp, conf) <- configCompilerAux configFlags'
configure verbosity
(configPackageDB' configFlags') (globalRepos globalFlags')
comp conf configFlags' installFlags' extraArgs
comp conf configFlags' configExFlags' extraArgs
installAction :: (ConfigFlags, ConfigExFlags, InstallFlags)
-> [String] -> GlobalFlags -> IO ()
......@@ -190,13 +190,14 @@ installAction (configFlags, configExFlags, installFlags)
let verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
config <- loadConfig verbosity (globalConfigFile globalFlags)
(configUserInstall configFlags)
let configFlags' = savedConfigureFlags config `mappend` configFlags
installFlags' = savedInstallFlags config `mappend` installFlags
globalFlags' = savedGlobalFlags config `mappend` globalFlags
let configFlags' = savedConfigureFlags config `mappend` configFlags
configExFlags' = savedConfigureExFlags config `mappend` configExFlags
installFlags' = savedInstallFlags config `mappend` installFlags
globalFlags' = savedGlobalFlags config `mappend` globalFlags
(comp, conf) <- configCompilerAux configFlags'
install verbosity
(configPackageDB' configFlags') (globalRepos globalFlags')
comp conf configFlags' installFlags'
comp conf configFlags' configExFlags' installFlags'
[ UnresolvedDependency pkg (configConfigurationsFlags configFlags')
| pkg <- pkgs ]
......@@ -248,13 +249,14 @@ upgradeAction (configFlags, configExFlags, installFlags)
let verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
config <- loadConfig verbosity (globalConfigFile globalFlags)
(configUserInstall configFlags)
let configFlags' = savedConfigureFlags config `mappend` configFlags
installFlags' = savedInstallFlags config `mappend` installFlags
globalFlags' = savedGlobalFlags config `mappend` globalFlags
let configFlags' = savedConfigureFlags config `mappend` configFlags
configExFlags' = savedConfigureExFlags config `mappend` configExFlags
installFlags' = savedInstallFlags config `mappend` installFlags
globalFlags' = savedGlobalFlags config `mappend` globalFlags
(comp, conf) <- configCompilerAux configFlags'
upgrade verbosity
(configPackageDB' configFlags') (globalRepos globalFlags')
comp conf configFlags' installFlags'
comp conf configFlags' configExFlags' installFlags'
[ UnresolvedDependency pkg (configConfigurationsFlags configFlags')
| pkg <- pkgs ]
......
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