Commit a5c35062 authored by Jens Petersen's avatar Jens Petersen

add --override-reinstall-check option

This option flag overrides the new destructive reinstalls check,
allowing forcing overwriting already installed library versions.
The patch also documents this flag and other softer options
in the output of printPlanMessages, which is renamed to checkPrintPlan.
parent d2caa2f9
......@@ -142,7 +142,7 @@ planPackages verbosity comp fetchFlags
-- Reinstall the targets given on the command line so that the dep
-- resolver will decide that they need fetching, even if they're
-- already installed. Sicne we want to get the source packages of
-- already installed. Since we want to get the source packages of
-- things we might have installed (but not have the sources for).
reinstallTargets
......
......@@ -172,7 +172,7 @@ install verbosity packageDBs repos comp conf
comp configFlags configExFlags installFlags
installedPkgIndex sourcePkgDb pkgSpecifiers
printPlanMessages verbosity installedPkgIndex installPlan dryRun
checkPrintPlan verbosity installedPkgIndex installPlan installFlags
unless dryRun $ do
installPlan' <- performInstallations verbosity
......@@ -332,12 +332,12 @@ planPackages comp configFlags configExFlags installFlags
-- * Informational messages
-- ------------------------------------------------------------
printPlanMessages :: Verbosity
-> PackageIndex
-> InstallPlan
-> Bool
-> IO ()
printPlanMessages verbosity installed installPlan dryRun = do
checkPrintPlan :: Verbosity
-> PackageIndex
-> InstallPlan
-> InstallFlags
-> IO ()
checkPrintPlan verbosity installed installPlan installFlags = do
when nothingToInstall $
notice verbosity $
......@@ -354,13 +354,18 @@ printPlanMessages verbosity installed installPlan dryRun = do
printDryRun adaptedVerbosity lPlan
when containsReinstalls $
(if dryRun then notice adaptedVerbosity else die) $
"The install plan contains reinstalls which can break your "
++ "GHC installation."
-- TODO: Add pointers to flags once implemented.
(if dryRun || overrideReinstall then notice adaptedVerbosity else die) $
"The install plan contains reinstalls which can break "
++ "your GHC installation.\nYou can use the --avoid-reinstalls option "
++ "to try to avoid this or try\nto ghc-pkg unregister the version of "
++ "the package version to see its effect\non reverse dependencies. "
++ "If you know what you are doing you can use\nthe "
++ "--override-reinstall-check option to override this reinstall check."
where
nothingToInstall = null (InstallPlan.ready installPlan)
dryRun = fromFlag (installDryRun installFlags)
overrideReinstall = fromFlag (installOverrideReinstall installFlags)
linearizeInstallPlan :: PackageIndex
-> InstallPlan
......
......@@ -575,6 +575,7 @@ data InstallFlags = InstallFlags {
installDryRun :: Flag Bool,
installReinstall :: Flag Bool,
installAvoidReinstalls :: Flag Bool,
installOverrideReinstall :: Flag Bool,
installMaxBackjumps :: Flag Int,
installUpgradeDeps :: Flag Bool,
installReorderGoals :: Flag Bool,
......@@ -596,6 +597,7 @@ defaultInstallFlags = InstallFlags {
installDryRun = Flag False,
installReinstall = Flag False,
installAvoidReinstalls = Flag False,
installOverrideReinstall = Flag False,
installMaxBackjumps = Flag defaultMaxBackjumps,
installUpgradeDeps = Flag False,
installReorderGoals = Flag False,
......@@ -694,6 +696,11 @@ installOptions showOrParseArgs =
installAvoidReinstalls (\v flags -> flags { installAvoidReinstalls = v })
trueArg
, option [] ["override-reinstall-check"]
"Use to override the check that prevents reinstalling already installed versions of package dependencies."
installOverrideReinstall (\v flags -> flags { installOverrideReinstall = v })
trueArg
, option [] ["max-backjumps"]
("Maximum number of backjumps allowed while solving (default: " ++ show defaultMaxBackjumps ++ "). Use a negative number to enable unlimited backtracking. Use 0 to disable backtracking completely.")
installMaxBackjumps (\v flags -> flags { installMaxBackjumps = v })
......@@ -771,6 +778,7 @@ instance Monoid InstallFlags where
installDryRun = mempty,
installReinstall = mempty,
installAvoidReinstalls = mempty,
installOverrideReinstall = mempty,
installMaxBackjumps = mempty,
installUpgradeDeps = mempty,
installReorderGoals = mempty,
......@@ -790,6 +798,7 @@ instance Monoid InstallFlags where
installDryRun = combine installDryRun,
installReinstall = combine installReinstall,
installAvoidReinstalls = combine installAvoidReinstalls,
installOverrideReinstall = combine installOverrideReinstall,
installMaxBackjumps = combine installMaxBackjumps,
installUpgradeDeps = combine installUpgradeDeps,
installReorderGoals = combine installReorderGoals,
......
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